trig problem

Posted by noshenim on July 30, 2010, 8:41 p.m.

ax,ay,az (point to draw)

cx,cy,cz (camera)

rx,ry,rz (camera rotation)

ex,ey,ez (the viewer's position relative to the display surface)

-> bx,by (2D projection of a)

Quote:
dx=cos(rx)*(sin(rz)*(ay-cy)+cos(rz)*(ax-cx))-sin(ry)*(az-cz)

dy=sin(rx)*(cos(ry)*(az-cz)+sin(ry)*(sin(rz)*(ay-cy)+cos(rz)*(ax-cx)))+cos(rx)*(cos(rz)*(ay-cy)-sin(rz)*(ax-cx))

dz=cos(rx)*(cos(ry)*(az-cz)+sin(ry)*(sin(rz)*(ay-cy)+cos(rz)*(ax-cx)))+sin(rx)*(cos(rz)*(ay-cy)-sin(rz)*(ax-cx))

bx=(dx-ex)*(ez/dz)

by=(dy-ey)*(ez/dz)

Solve for ax,y,z.

This will convert a point on the screen to a direction in 3D space.

bx,by (2D projection of a)

cx,cy,cz (camera)

rx,ry,rz (camera rotation)

ex,ey,ez (the viewer's position relative to the display surface)

-> ax,ay,az (point to draw)

#

Comments