Reputation: 3059
I have a 3D modeling problem which is unrelated to 3D frameworks like XNA. In other words, I have to run the calculations myself (using some framework functionality is OK though).
I have a set of N 3D points, let's call them p1 to pN. While these points are unknown, I know what their projected 2D location is (pp1 to ppN) when the camera has an ORIENTATION described by a unit vector U1.
How can I find out the projection of these points when the camera is oriented differently, as described by a different vector U2?
Any help is appreciated :)
Thanks
Upvotes: 0
Views: 196
Reputation: 90062
I could be totally wrong here, as I haven't touched 3D math or matrices in a long time.
Based off of http://www.songho.ca/opengl/gl_transform.html.
The formula:
D * M * P * W * V = S
Data * Model * Perspective * W * Viewport = Screen
You know M1
, P1
, W1
, V1
, and S1
.
You are looking for S2
given a M2
, P2=P1
, W2=W1
, V2=V1
.
Also, you know that D1=D2
(3D point doesn't move).
D1 * M1 * P1 * W1 * V1 = S1
D1 * M2 * P1 * W1 * V1 = S2
Solve for D1 and equate them:
D1 = S1 * M1^-1 * P1^-1 * W1^-1 * V1^-1
D1 = S2 * M2^-1 * P1^-1 * W1^-1 * V1^-1
S1 * M1^-1 * P1^-1 * W1^-1 * V1^-1 = S2 * M2^-1 * P1^-1 * W1^-1 * V1^-1
Remove like terms:
S1 * M1^-1 = S2 * M2^-1
Now solve for S2:
S1 * M1^-1 * M2 = S2
Upvotes: 1
Reputation: 59705
You cannot. When you only know the camera location and orientation and the projection of a point, you don't know where the point actually is - it can be anywhere on a line from the camera through the projection plane into infinity. Hence you are not even able to tell (in the genral case) if the point is visible to a camera at a different location and orientation.
But if you know something about the points - for example they form a cube of known size - you can use this knowledge and the projection of the points to calculate the location of the points and in turn find the projection of the points for other camera locations and orientations.
Upvotes: 1