This is part of the code I used for my first so called 3d engine some 7 years ago. It calculates a perspective projection (you know that x2d = x3d / z3d; y2d = y3d / z3d thingie) Hey, I''ve figured out all these formulas by myself

repeat k:=k+1;{-------------------X---------------} delta:=ungle(a,b,points3[k,1],points3[k,2]); alfa1:=un(alfa-180); if (delta>alfa) and (deltaalfa1) then v:=1 else v:=-1; if alfa>=180 then v:=v*(-1); gama:=un(alfa-delta); if gama>180 then gama:=gama-180; if cos(gama*rad)=0 then points2[k,1]:=mx else points2[k,1]:=mx+v*abs(sin(gama*rad)/cos(gama*rad))*n;{-------------------Y---------------} if (sqrt((a-points3[k,1])*(a-points3[k,1])+(b-points3[k,2])*(b-points3[k,2])))=0 then gama:=90 else gama:=arctan(abs(points3[k,3]-c)/(sqrt((a-points3[k,1])*(a-points3[k,1]) +(b-points3[k,2])*(b-points3[k,2])))); points2[k,2]:=my-35/48*sign(points3[k,3]-c)*sin(gama)/cos(gama)*n;{---------------dist----------------} points2[k,3]:=sqrt(sqr(c-points3[k,3])+sqr(a-points3[k,1])+sqr(b-points3[k,2]));{-----------------------------------} until k=m;