3d vector question
Hi,
given yaw, pitch and roll, how do I find the 3d vector of x magnitude?
Many Thanks.
November 06, 2001 01:38 PM
Depends on what your starting vector is.
If you want your starting vector to be looking down the z axis..then the resultant pyr vector is.
f32 cosP,sinP,cosY,sinY,PYRVec[3];
cosP = cosf(pitch);
sinP = sinf(pitch);
cosY = cosf(yaw);
sinY = sinf(yaw);
PYRVec[0] = cosP * sinY;
PYRVec[1] = -sinP;
PYRVec[2] = cosP * cosY;
Roll isnt calculated into the above because it is not needed for the beginning lookat. PYRVec now contains the normalized direction, so you can now multiply in the magnitude x.
PYRVec[0] *= x;
PYRVec[1] *= x;
PYRVec[2] *= x;
If you want your starting vector to be looking down the z axis..then the resultant pyr vector is.
f32 cosP,sinP,cosY,sinY,PYRVec[3];
cosP = cosf(pitch);
sinP = sinf(pitch);
cosY = cosf(yaw);
sinY = sinf(yaw);
PYRVec[0] = cosP * sinY;
PYRVec[1] = -sinP;
PYRVec[2] = cosP * cosY;
Roll isnt calculated into the above because it is not needed for the beginning lookat. PYRVec now contains the normalized direction, so you can now multiply in the magnitude x.
PYRVec[0] *= x;
PYRVec[1] *= x;
PYRVec[2] *= x;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement