Projecting 3d space to 2d
Does anyone know where to find formulae for projecting a point in 3-dimensional Euclidean space to a 2-d plane? The formula for cases when the plane is centered at the origin is trivial: (x',y') = (x/z,y/z) . Any information on cases where the plane is not centered at the origin would be appreciated,as well as any information on n -> n-1 dimensional cases.
[ 04-16-2002: Message edited by: Rick1138 ]</p>
[ 04-16-2002: Message edited by: Rick1138 ]</p>
Comments
I'm afraid I am only familiar in working in 3d space with homogenous coordinates (x, y, z, w).
For parallel projection, first divide all the components by w. Then plot (x,y) components (assuming the model has been transformed to screen space).
Perspective projection is a bit more complicated. I can type that out if you need that too.
a) the position of the perspective frame
b) its orientation,or basis
c) the position of the projection point,if the projection is non-parallel
[ 04-16-2002: Message edited by: Rick1138 ]</p>
What I mean by the point of view is called in computer graphics the camera position.In Open GL the pyramid constructed by the camera position and the projection plane is called the view frustrum.
In general I am interested in types of transforms created when the camera is a scanner,and either the camera is moving,or objects in the scene are moving.I think I am dealing with a new type of geometry that is based on rotation groups and projective geometry,but also different from both.
The basic for idea for rotation is like what I said before. Working in homogenous coords:
1) Translate all objects such that the eye position is now at the origin.
2) Rotate the objects such that the vector from the eye to the center of interest is aligned with the z-axis. This done by what is called the "general rotation matrix".
3) Divide all x,y,z values of a point by it's w.
Here is a bit of code I wrote for my last project. It calculated the GRM. (note: y is up, x is back and forth, z is out -- different from typical mathematical 3d space [where z is up])
[code]
void calculateGRM(double grm[4][4])
{
double Vx[3], Vy[3], Vz[3]; // three vectors that form a right 3d space
double topVector[3] = {0, 1, 0}; // some vector that is points straight up.
Vz[0] = coiX - posX; // let Vz = the vector from the eye to the center of interest
Vz[1] = coiY - posY;
Vz[2] = coiZ - posZ;
/*Cross Vz with straight up vector to find Vx*/
VectorOps3d::cross(topVector, Vz, Vx);\t// cross of topVector and Vz stored to Vx
/* Cross Vz w/ Vx to find Vy */
VectorOps3d::cross(Vz, Vx, Vy);\t\t// cross of Vz and Vx stored to Vy
VectorOps3d::normalize(Vx);
VectorOps3d::normalize(Vy);
VectorOps3d::normalize(Vz);
for(int i = 0; i < 3; i++)
{
grm[0][i] = Vx[i];
grm[1][i] = Vy[i];
grm[2][i] = Vz[i];
}
}
</pre><hr></blockquote>
Note that the forth row and columns are all = 0 except for grm[3][3] -- that is = 1.
Now simply take all your points and multiply them by grm (grm should be on the left).