Original Post
Hi there, I have been working on a custom 3D engine for a while (like everyone else :)) - but this one is in flash. Just bear with me though... I have a camera object with a 'position' vector and a 'target' vector. Using these two vectors I am trying to figure out the rotation of the camera (in radians) for each of the three axis. The camera actually never 'leans' over, so there is no rotation around the z axis (as yet) but I may add the 'up' vector (orientation vector) at a later stage. Currently, my code is like this: // subtract vectors: target-position to get resultant vector fViewDirection = subtractV( fTarget, fPosition ); // calculate roll, pitch and yaw fRotation.x = -Math.atan2(fViewDirection.y, fViewDirection.x); fRotation.y = -Math.atan2(fViewDirection.z, fViewDirection.y); fRotation.z = -Math.atan2(fViewDirection.x, fViewDirection.z); I want the angles to be 0,0,0 when the camera is looking down the -ve z axis. The code above gives me some wierd results. What am i doing wrong? TIA Peter [Edited by - petervullings on July 8, 2004 7:33:49 PM]