what does AngleVectors method in quake 3 source code does

Posted by kypronite on Game Development See other posts from Game Development or by kypronite
Published on 2012-11-06T18:08:12Z Indexed on 2012/11/06 23:21 UTC
Read the original article Hit count: 469

Filed under:
|
|

I just downloaded quake 3 for learning purposes.
I know some of some linear algebra(basic vector math ie: dot,cross product).
However I can't decipher what below method does, I know what is yaw,pitch and roll.
But I can't connect these with vector.
Worse, I'm not sure this fall under what math 'category', so I don't really know how to google.
Hence the question here.
Anyone?

void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) {
float       angle;
static float        sr, sp, sy, cr, cp, cy;
// static to help MS compiler fp bugs

angle = angles[YAW] * (M_PI*2 / 360);
sy = sin(angle);
cy = cos(angle);
angle = angles[PITCH] * (M_PI*2 / 360);
sp = sin(angle);
cp = cos(angle);
angle = angles[ROLL] * (M_PI*2 / 360);
sr = sin(angle);
cr = cos(angle);

if (forward)
{
    forward[0] = cp*cy;
    forward[1] = cp*sy;
    forward[2] = -sp;
}
if (right)
{
    right[0] = (-1*sr*sp*cy+-1*cr*-sy);
    right[1] = (-1*sr*sp*sy+-1*cr*cy);
    right[2] = -1*sr*cp;
}
if (up)
{
    up[0] = (cr*sp*cy+-sr*-sy);
    up[1] = (cr*sp*sy+-sr*cy);
    up[2] = cr*cp;
}
}

ddddd

© Game Development or respective owner

Related posts about vector

Related posts about angles