Jump to content
  • Advertisement
Sign in to follow this  

How to get vector end position

This topic is 3053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Y is vertical axis, X and Z are horizontal. If i have a vector V with yaw rotation angle angY and pitch angle angP and a distance Dist. How can i compute his final position? I know that i can get the horzontal position by pos.X += distance * cos( angY * degToRadians ); pos.Z -= distance * sin( angY * degToRadians ); but that can't take account for the vertical angle. Thanks in advance

Share this post

Link to post
Share on other sites
You're probably interested in spherical coordinates, especially its section 3.1 which handles conversion to/from cartesian coordinates.

On the other hand, you speak of yaw and pitch; do you mean you have Euler angles?

[Edited by - haegarr on February 8, 2010 2:04:55 PM]

Share this post

Link to post
Share on other sites
and found something in irrlicht forum similar to your response and tried to adapt. Not sure if is ok.

core::vector3df VecEndPosition( const core::vector3df &v1, const float Phi, const float Theta, const float dist )
float DEG2RAD = 3.141592 / 180.0;

float sinOfPhi = sinf(Phi * DEG2RAD);
float cosOfPhi = cosf(Phi * DEG2RAD);

float sinOfTheta = sinf(Theta * DEG2RAD);
float cosOfTheta = cosf(Theta * DEG2RAD);

core::vector3df offset = v1;

offset.X += dist * sinOfTheta * sinOfPhi;
offset.Y += dist * cosOfPhi;
offset.Z += dist * cosOfTheta * sinOfPhi;

return offset;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!