Click to See Complete Forum and Search --> : Perspective projection with arbitrary camera


Amn
August 27th, 2003, 08:57 AM
Hi all!

I know how to project 3d models to a plane using perspective projection, but only when the camera (projection) is aligned with the coordinate system (read projection center at (0, 0, 0), optical axis at the Z axis).


screenX = x * f / z;
screenY = y * f / z;


I need to implement perspective projection given that the projection system is at arbitary point in space, with arbitrary azimuth, tilt etc. I.e. camera may be positioned freely in space.

Any documentation on Internet about this ? Or maybe some fast hint from someone ?

Thanks !

galathaea
August 27th, 2003, 04:03 PM
Just do your calculations in a transformed coordinate system.

If the coordinates of the camera in your working coordinate system are (x1, y1, z1) do the transformation:

x' = x - x1;
y' = y - y1;
z' = z - z1;

to move your camera to the origin (0, 0, 0) and the rest of the space stays relatively positioned.

Then rotate that new coordinate system to set the cameras Euler angles to thetaZ = 0, thetaX and thetaY = p / 2. In that coordinate system, you can use your original formula.

Amn
August 28th, 2003, 03:22 AM
Thanks ;)

I originally had this in mind, but then I began counting instructions and thought there is a faster alg. Still, thanks a lot, this will do great ! :)