Can someone explain to me how adding and subtracting a rotational vector from position vector works?

Hello. I’m really new to Unity and C#. While going through the guides that people made for third person camera, I came across this script line that people use to place themselves in the back.

public class FollowCamera : MonoBehaviour {
    public GameObject target;
    public float damping = 1;
    Vector3 offset;
    
    void Start() {
        offset = target.transform.position - transform.position;
    }
    
    void LateUpdate() {
        float currentAngle = transform.eulerAngles.y;
        float desiredAngle = target.transform.eulerAngles.y;
        float angle = Mathf.LerpAngle(currentAngle, desiredAngle, Time.deltaTime * damping);
        
        Quaternion rotation = Quaternion.Euler(0, angle, 0);
        transform.position = target.transform.position - (rotation * offset);
        
        transform.LookAt(target.transform);
    }
}

In this code, I see this script line and I don’t get how this works.

transform.position = target.transform.position - (rotation * offset);

I know that you can subtract two positional vectors to get the distance between them but how can one subtract rotational quaternion values from the position which are vector 3 values?
I don’t see them combining since one is about the world position but the other is about the rotation itself. Is the rotation not relative to its own local axes? – like, how does it place you at the back of your target? Wouldn’t mess your position up if you were to just combine them? please explain this to me and how this subtraction works… Thank you!

rotation is a quaternion, but offset is a standard vector, representing a direction and a length. When you multiply a quaternion and a vector, it is essentially a transformation of the vector according to the rotation represented by the quaternion. The result is therefore another vector, pointing in a different direction but with the same length. Subtracting this vector from position then creates an offset from position in that direction and by that length.

You are adding to the “offset” vector the “rotation” vector. You are using the first 3 values x, y, z of the quaternion (x, y, z, w ). You can use Debug.Log() or inspector to look to the values and understand how the math combine.