Hi,
I am trying to perform a simple perspective projection of various 3D structures, defined as a plurality of 3D polygons (different z's), each comprising a plurality of points. The structure will be viewed by a number of different cameras that I define. These cameras are defined by placing a world camera(eye) at (0,0,z) in my world coordinates, look(0,0,0) and up(0,1,0) and rotating the world axes by alpha (about x-axis), beta(about y) and gamma(about z), thereby creating my local coordinates system for that particular camera. [I realise that I could do this with OpenGL but I want to try and do this myself and understand it, rather than using a black box]
The basis of my global camera is defined using the vectors u,v and w where w=(eye-look).normalised =(0,0,1); u=up.cross(w)=(1,0,0) and v=w.cross(u)=(0,1,0)
I am working with homogeneous coordinates so my transformation matrix for u_dashed,v_dashed,w_dashed looks as follows:
T(px,py,pz) = [1,0,0,px;0,1,0,py;0,0,1,pz;0,0,0,1] and R = [u,0;v,0;w,0;0,0,0,1]
so putting it all together I get
Tr=T(eye-look) x R' x R_zyx x R x T(-(eye-look)) where R' is the transpose of R and R_zyx is the combined forward rotation matrix (world => local coordinates) I then multiply the orthogonal projection matrix (O) with the perspective transform matrix (P) (http://www.cs.uu.nl/docs/vakken/gr/Slides/06-projection.pdf) to determine the combined transformation:
C=O x P x Tr
Finally proj=(C x 4Dpoint) and do the perspective divide i.e. (proj.x/proj.w, proj.y,pro.w)
Or would I be better of determining the coordinates of each camera i.e. R_zyx x [0;0;z;1] and u,v and w by Rzyx x [ux,vx,wx,0;uy,vy,wy,0;uz,vz,wz,0;0,0,0,0]?