1
votes

I have a similarity transformation S from world coordinate system 1 to 2. I also have a set of 3D points x_i and projection matrices P_j (3x4 or 4x4) of cameras in either world coordinate system 1 or 2.

I now want to transform the cameras (projection matrices) in system 1 to system 2.

Transforming the 3D points works as expected, but how would I do it with the projection matrices?

My approach was the following:

S = [Ss*SR | St]
P = [R | t]

Invert the projection matrix:

PP = inv(P) = [R.T | -R.T*t] = [RR | tt]

Rotate the orientation of camera:

RR' = SR * RR

Scale, Rotate and translate position:

tt' = Ss*SR*tt + St
PP' = [RR' | tt']

Invert the transformed matrix to obtain the projection matrix again:

P' = inv(PP')

where P and P' are the projection matrices in system 1 and 2, respectively.

2
Please check your question. You say you have "projection matrices P_j .. in world coordinate systems 1 and 2." Then you say "I now want to transform ... projection matrices from system 1 to 2." If you have both, then transformation isn't necessary.Gene
@Gene This was not clearly phrased. I changed my question accordingly.user2970139
I would say this question belongs on math.stackexchange.comvallentin
downvote explain yourself please.Anton D
This is a reasonable OpenGL programming question. I upvoted.Gene

2 Answers

1
votes

Your question is unclear. Similarity transform is not conventional OpenGL terminology. The pipeline starts with object coordinates. A model transform M takes these to world coordinates (there is only one world coordinate system). A view transform V takes these to eye coordinates. Sometimes the view matrix is called the camera matrix because V takes a hypothetical camera line of sight vector and eye point to the world negative z axis and origin respectively. A projection transform P takes the eye coordinates to homogenous (4d) clip coordinates. In parallel projections, these are the same as normalized device coordinates. For perspective, the division needs still to be performed, but this can't be represented as 4x4 matrix ops and isn't important for what you want. So the whole pipe in 4d is

d = P V M x

where d is a clip/normalized device coordinate and x is an object coordinate. You can change any or all of the pipe as a scene is rendered. But it's unusual to change P or V.

So your question doesn't make much sense. A camera matrix V is described with a point and vector in eye coordinates. If you want to see where those lie in object space, just multiply by inv(M). Perhaps (I am guessing) what you have is two object spaces and corresponding model matrices to take these to a common world:

d = P V M_1 x_1
d = P V M_2 x_2

Now if you have an eye point and vector in object system 1 and need to get them to system 2, do the obvious thing. Solve for x_2 in terms of x_1:

x_2 = inv(M_2) M_1 x_1

To say a camera matrix is "in" any particular coordinate system doesn't have meaning. The matrix is between coordinate systems.

1
votes

I found the solution myself:

Projection matrix P1 projects 3D points to image plane and thus to 2D points in the source coordinate system:

x' = P1 * X1

3D points can be transformed to the destination system by applying the similarity transformation S:

X2 = S * X1

To obtain the projection matrix P2 that transforms the 3D point in the destination system to the 2D points, which do not change:

x' = P2 * X2 = P2 * S * X1 = P1 * S^-1 * S * X1 = P1 * I * X1

and thus:

P2' = P1 * S^-1

Finally, a normalization by the scaling factor is necessary:

P2 = s * P2'