Advertisement

How do I find the directional vector

Started by July 30, 2002 09:58 PM
3 comments, last by crossbow 22 years, 6 months ago
I have the pitch, roll, and yaw from user input in my OpenGL program and I want to calculate the directional vector from this and the position of the object. Can somebody please explain to me how I do this? Thanks!
Assume that the direction vector is and the position of your object is P.

D.x = P.x + sin(yaw) * sin(pitch+90º)
D.y = P.y + cos(yaw)
D.z = P.z + cos(yaw) * -sin(pitch+90º)

I''d explain the math but it''s been a year since I wrote the code that implements this so I probably don''t remember the math myself

No, HTML is not an OO language.
Advertisement
ok I implemented that, but I don''t think it works. If I add the normalized view vector to the position of the object, I should get the objects position, right? well i did that and the thing doesn''t move in the right direction. Humm...does anybody have some sample code to show this. This thing is driving me crazy and I don''t want to have to figure it out! Thanks anyways
you should probably convert the rotation to radians first.
search for deg2rad or something (degrees to radians)
btw, and maybe im missing something, but that bit of code didnt include anything about roll, only pitch and yaw...

This topic is closed to new replies.

Advertisement