   3D Graphics Theory
  I am trying to write a very simple 3d game consists of lines. I want to write all engine by myself so how can i convert the object''s model space to world space (which is projected on 2d device). i have find an equation as follow(x,y,z) = a/z(x,y,z) = (x*a/z, y*a/z, a)so in this equation we can re calculate our models x,y,z values into x,y values only with a scaling(zoom) factor ''a''. so this can be used. but when i try to use a camera, things are getting complexed.imagine that i am rotating a simple cube (consists of 12 lines). what i want is rotating this cube and get viewed from a primitive  camera. how can i calculate this  
templatevoid VERTEX::Rotate3d( float yaw,float pitch,float roll ) { register int ii; float px,py,pz; float a,b,c,d,e,f,g,h,i; float cosx,cosy,cosz,sinx,siny,sinz;  yaw  *=__DEGTORAD;  pitch*=__DEGTORAD;  roll *=__DEGTORAD;  sinx=(float) sin( yaw   );  siny=(float) sin( pitch );  sinz=(float) sin( roll  );  cosx=(float) cos( yaw   );  cosy=(float) cos( pitch );  cosz=(float) cos( roll  );   a=cosy*cosz;  b=cosy*sinz;  c=-siny;  d=sinx*siny*cosz-cosx*sinz;  e=sinx*siny*sinz+cosx*cosz;  f=sinx*cosy;  g=cosx*siny*cosz+sinx*sinz;  h=cosx*siny*sinz-sinx*cosz;  i=cosx*cosy; for ( ii=0; ii<(int)(items); ii+=stride) {px=array[ii  ];py=array[ii+1];pz=array[ii+2];array[ii  ]=a*px+b*py+c*pz;array[ii+1]=d*px+e*py+f*pz;array[ii+2]=g*px+h*py+i*pz; }}this code is taken from my vertex stl-like structureyou should replace the ''stride'' offset with 1the array is allocated in a linear fashion but you acces the x,y,z item using an offset ( 0,1,2 ) in this case, anyway these are not the most important bits, take a look at the 9 coeeficients they are taken from the matrix multiplication, this is a fast hack, you should take a look at the theory behind ( matrix multiplication and so on ) there are a lot , lot of tutorial over the net , just do some ''goggling''i hope it helps. ;  thanks for your reply. i have no problem on rotating, translating or shearing objects. i have problem on converting object coordinates, which is 3 dimensional (x,y,z) to screen coordinates, which is 2 dimensional (x,y). how can i do it.  ;  Hi!X2D = focus * X3D / Z3D + X_center_of_screenY2D = focus * Y3D / Z3D + Y_center_of_screen;  so if i use a camera then...would following algorithm work ??for each object in scene    translate and rotate object matrixmultiply this matrix with camera matrix    then calculate world coords of each object using newmatrix    render objectend for