Skip to content
Prev 22303 / 398502 Next

What does persp() return?

David Brahm  <brahm at alum.mit.edu> writes:
Yes, that's what it is for. Classic computational graphics stuff:

I used to be much better at it, but the basic idea is that you
representing 3D points in 4D "homogeneous coordinates", (x,y,z,t) with
t != 0 and so that the usual cartesian coordinates (X,Y,Z) = (x,y,z)/t
(obviously, t is not unique). The main trick is that affine
transformations become linear in this system, e.g. a translation is
obtained by multiplying with

 1 0 0 a
 0 1 0 b
 0 0 1 c
 0 0 0 1

Rotations and reflections and scaling are easily accomplished with
suitable matrices as well. This is why "3D accelerated" CPUs and
graphics processors contain highly optimized 4x4 matrix multipliers,
btw.

I don't know exactly how we do the perspective viewing transformations
(you have the source too...), but one way is to rotate and scale the
scene so that the eye is at zero and looking in the Z direction
through a a projection plane at Z=1; then the coordinates of the
projected points are simply (u/w,v/w) where (u,v,w,s)' = T(x,y,z,1)'.
Yes. Somewhere in dreamspace lies the possibility of interfacing to a
"real" 3D rendering system (vtk is an option I look at once in a while).