# 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.

## 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 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 on other sites
yes
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;}

• 38
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631365
• Total Posts
2999585
×