Heading / Pitch
BlitzMax Forums/OpenGL Module/Heading / Pitch
| ||
Hi All, What is the fastest way to calculate the Heading / Pitch from an incoming vector/normal? i.e. I have an incoming vector (a Ray) heading to a point. When it reaches the point, I want to (for example) be able to turn the object at the point to point down the direction of the incoming ray (roll is not important in this case). Now I know you can something along those lines with GluLookAt(), but I'm after making a simple GetHeadingandPitch(NX:Float,NY:Float,NZ:Float, Heading:Float Var, Pitch:Float Var) function. (I would prefer to do it without resorting to using a Matrix) Any ideas? |
| ||
Tried Marks geom code? http://blitzbasic.com/Community/posts.php?topic=42657 Check the pitch & yaw methods of his vector class. I guess you'd want to reverse the incoming vector first though. |
| ||
Thanks Tom, From that so far I would expect: Heading = -atan2(-x,-z) Pitch = -atan2(-y,sqr( -x*-x+-z*-z ) ) |