Reputation: 413
I'm trying to solve the attached question after reading some material about pinhole cameras and how their projection matrix are set and I'm still not sure I understand all the math.
in the attached question, when moving the COP of the camera to -2Zp as I understand I basically increase the focal view for the camera which basically gives me the same matrix as the one given only now the 3rd element of row 3 is 1/3Zp and not 1/Zp, is that correct?
if so, how would you calculate the new position of t, multiplying it by the new matrix I got give me (0, Yp, 2/3)T. is the solution to make sure that the last number is 1 and not 2/3 so I get (0,2Yp/3, 1). can someone explain how homogeneous coordinates work in this case?
Besides that c is pretty clear, I will get an orthographic projection. Can someone help with section d?
Upvotes: 3
Views: 2371
Reputation: 413
ok so now regarding C and D. in C I assume that if you move COP along the Z axis to infinity you get an orthographic projection. but I'm not sure if the matrix would be:
( 1 0 0 0 )
M = ( 0 1 0 0 )
( 0 0 0 0 )
or
( 1 0 0 0 )
M = ( 0 1 0 0 )
( 0 0 0 Zp )
With D I have not idea, you need to somehow keep the ratio so that t will be projected the same way, and I understand that you have to pick the Z coordinate for PP as a function of the new COP, but I'm not sure where to go from here.
Upvotes: 0
Reputation: 7824
It might help to draw a diagram. You can make things simpler by ignoring the x coordinate which puts everything in 2D. In this simpler diagram to find the projection of a point t, onto the plane PP simply draw a line from the position of the pinhole to the point. This makes it very easy to work out from the diagram where each point should be projected to. You can use this to check your calculations from the matrices.
You have half the answer, if we had a pinhole at the origin and the plane was a distance 3Zp away the matrix would be
( 1 0 0 0 )
M = ( 0 1 0 0 )
( 0 0 1/3Zp 0 )
This only works if the pinhole is at the origin. In part a) its not.
What you need to do is apply a translation. In case a) translate everything so COP2 is at the origin, apply the projection, then apply the inverse of the translation. Thing work easier if we add a forth row to M
( 1 0 0 0 )
M = ( 0 1 0 0 )
( 0 0 1 0 )
( 0 0 1/3Zp 0 ) Note modified form.
A translation of distance d along the z axis is given by
( 1 0 0 0 )
T = ( 0 1 0 0 )
( 0 0 1 d )
( 0 0 0 1 )
The inverse will simply be
( 1 0 0 0 )
T'= ( 0 1 0 0 )
( 0 0 1 -d )
( 0 0 0 1 )
To get your final projection matrix find
T' M T.
Finally we go from 4D (x,y,z,w) to 3D (x,y,w) by dropping the third coordinate. You can do this by multiplying by a 3X4 matrix.
Note see Transformation matrix section perspective projection for the correct form of the perspective projection.
To make thing explicit let a=Zp. The translation is
( 1 0 0 0 )
T = ( 0 1 0 0 )
( 0 0 1 -2 a )
( 0 0 0 1 )
and the projection onto a plane 3Zp from origin is
( 1 0 0 0 )
M = ( 0 1 0 0 )
( 0 0 1 0 )
( 0 0 -1/(3a) 0 )
Find T' M T which turns out to be
( 1 0 0 0 )
N = ( 0 1 0 0 )
( 0 0 1/3 -2/3 a )
( 0 0 -1/(3a) 2/3 )
We apply to our two points
( 0 ) ( 0 ) ( 0 )
N ( Yp ) = ( Yp ) -> ( Yp )
( -a ) ( -a ) ( -a )
( 1 ) ( 1 )
( 0 ) ( 0 ) ( 0 )
N ( Yp ) = ( Yp ) -> ( 3/4 Yp )
( -2a ) ( -4/3 a ) ( -a )
( 1 ) ( 4/3 )
Where the last step is dividing by w so we have (x,y,z) coordinates lying on the plane z=-a=-Zp. These agree with what we get from the diagram. If you want you could drop the 3rd row of N.
Upvotes: 1