The picture below shows the way I rotate. These are the angles I need to calculate.

(The only difference is I'm rotating the object in the order X,Y,Z and not Z,Y,X)

This is the code I'm using but its not working for me:

// x, y, z represent a fractional value between -[1] and [1]

// a "unit vector" of the point I need to rotate towards

yaw = Math.atan2( y, x )

pitch = Math.atan2( z, Math.sqrt( x * x + y * y ) )

[Edited by - Jenko on October 22, 2010 10:04:08 PM]