Sign in to follow this  

How to get vector end position

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this