opmfan
opmfan

Reputation: 191

Different between rotating the camera vs rotating the scene point (only the point, not the entire scene)?

I think rotating the camera and taking the photo of a scene would yield the same result with keeping the camera stable and rotating the scene in reverse way.

Assume that the original camera rotation matrix is R1. Rotating the camera means that we apply another rotation matrix R12 (so R2=R12*R1 is the new rotation matrix). Assume that X is the realworld coordinate of scene point. Rotating the scene point in the reverse way means that we apply the reverse rotation matrix R12^-1 to X (this might be wrong).

So why (R12*R1)X != R1(R12^-1*X) ?

Can anyone explain me what I'm wrong?

p.s. I'm not asking about programing as well as complexity of the two method. I just want to know

(1) the mathematical equation for the action "rotating the scene"

(2) if my assumed equation for "rotating the scene" is correct, why doesn't the mathematical equations reflect the phenomenon in the real world as I described.

Edit 1: According to Spektre's answer, when I rotate the entire scene with the rotation matrix R, then the new camera rotation matrix is

R^-1*R1

In this case, I rotate the entire scene with the rotation matrix R12^-1, then the new camera rotation matrix is

(R12^-1)^-1*R1=R12*R1

However, what if I consider that rotating the camera is equivalent to rotating the scene point X (only the scene point X, not the entire scene). At that time, the rotation matrix of the camera is still R1. But the scene point X now become X'. And the image coordinate of X' is R1*X'. What is the equation for X' ? Note that

R1*X' = R12*R1*X

Of course, you can answer that

X'=R1^-1*R12*R1*X

But I think X' should be defined only by R12 and X (R1 doesn't need to be known to form X'). That's why I ask "what is the mathematical equation for rotating the scene point". X' is the result of the action "rotating X" by some rotation matrix related to R12.

I have another example when the camera does not rotate but move. Assume that I'm taking the photo of a model who is standing right in front of me. Her position is X. My position is C. In the first case, I move to the right (of me) and take the first photo. In the second case, I don't move but the model move the left (of me) with the same steps and I take the second photo. The position of the model in the two image must be identical. This is expressed by the mathematical equation

[R1 -R1*(C+d)]*X = [R1 -R1*C]*(X-d)

In the equation above (which I checked to be true), -R1*C is the translation vector, -R1*(C+d) is the translation vector when I move to the right of me, (X-d) is the position of the model when she move to the left of me.

In the above example, X' = X-d (so X' is defined through X and my movement d). In the case of rotating the camera, what is X'?

Edit 2: Since Spektre still don't understand my question. There's a need to emphasize that in the second case, I DO NOT rotate the ENTIRE world, I ONLY rotate the point X. (If I rotate the entire world, the world coordinate of X remains the same after its world rotate. But if I rotate only X, its world coordinate will be changed to X').

Just imagine the example about taking the photo of the model. In the first case, I rotate the camera and take the first photo of her (and her boy friend standing next to her).

In the second case, I rotate ONLY the model in the reverse direction (her boy friend is stable), then I take the second photo. When I compare the two photos, the position of the model is the same (the position of her boy friend would be different).

In both case, the real world position of her boy friend are the same. But the real world position of the model is changed in the second case since I rotated her. My question is what is the real world position of the girl after I rotate her?

Upvotes: 2

Views: 1451

Answers (1)

Spektre
Spektre

Reputation: 51873

The answer to Title is: mathematically they are both almost the same (except inversion of all operations) but physically rotating camera means changing single matrix but to rotate scene you have to rotate all the objects in your world (can be thousands and more) which is a lot slower ...

But I assume the title and text is misleading as the real question is about linear algebra matrix equations.

Let R1,R2,R12 be square matrices of size N x N and X is vector of size N. If we ignore the vector orientation (1 x N vs N x 1) then for your convention:

R2 = R12.R1
R1 = Inverse(R12).R2

so:

R12.R1.X == R12.Inverse(R12).R2.X == R2.X

As you can see equation in your Question is wrong because you change the matrix multiplication order which is wrong because:

R1.R12 != R12.R1

If you want to know more closely why then study linear algebra.

[Edit1] simple 1x1 example

let:

R1 = 1
R12= 2
R2 = R12.R1 = 2

so rewriting your wrong equation:

R12*R1*X != R1*Inverse(R12)*X
  2* 1*X !=  1*         0.5*X
     2*X != 0.5*X

and using the correct one

R12*R1*X == R12*Inverse(R12)*R2*X == R2*X
  2* 1*X ==   2*         0.5* 2*X ==  2*X
     2*X == 2*X == 2*X

[Edit2] simple 2D example

I see you are still confused so here an 2D example of the problem:

2D exmaple

On the left you got rotated camera by R1 so for rendering transforming world point (x,y) into its local coordinates (x1,y1). On the right is the situation reversed so camera coordinate system is axis aligned (unit matrix) and the scene is rotated in reverse by Inverse(R1). That is how it works (where R1 is the relative matrix in this case).

Now if I try to port it to your matrix names and convention so the relative matrix is R12 and R1 is the camera :

(R1.R12).(x,y) = (x1,y1)
Inverse(R1.R12).(x1,y1) = (x,y)

Upvotes: 1

Related Questions