mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[mathlib] Clean up AngleVectors comments a little
They're still slightly confusing, but the situation itself is confusing, but the comments should be a little more helpful now as they are more explicit about the orientation of the matrices and just which axis points where.
This commit is contained in:
parent
ef850d97ea
commit
16440bce2d
1 changed files with 18 additions and 11 deletions
|
@ -504,13 +504,21 @@ BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, plane_t *p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
angles is a left(?) handed system: 'pitch yaw roll' with x (pitch) axis to
|
angles is a left handed system: 'pitch yaw roll' with x (pitch) axis to
|
||||||
the right, y (yaw) axis up and z (roll) axis forward.
|
the right, y (yaw) axis up and z (roll) axis forward. However, the
|
||||||
|
rotations themselves are right-handed in that they follow the right-hand
|
||||||
|
rule for the world axes: pitch around +y, yaw around +z, and roll around
|
||||||
|
+x.
|
||||||
|
|
||||||
The math in AngleVectors has the entity frame as left handed with x
|
This results in the entity frame having forward pointed along the world +x
|
||||||
(forward) axis forward, y (right) axis to the right and z (up) up. However,
|
axis, right along the world -y axis, and up along the world +z axis.
|
||||||
the world is a right handed system with x forward, y to the left and
|
Whether this means the entity frame is left-handed depends on whether
|
||||||
z up, thus the negation for right.
|
forward is local X and right is local Y (left handed), or forward is local
|
||||||
|
Y and right is local X (right handed).
|
||||||
|
|
||||||
|
NOTE: these matrices have forward, left and up vectors horizontal rather
|
||||||
|
than vertical and are thus the inverse of the matrices to produce the
|
||||||
|
actual rotation.
|
||||||
|
|
||||||
pitch =
|
pitch =
|
||||||
cp 0 -sp
|
cp 0 -sp
|
||||||
|
@ -551,11 +559,10 @@ AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
|
||||||
forward[0] = cp * cy;
|
forward[0] = cp * cy;
|
||||||
forward[1] = cp * sy;
|
forward[1] = cp * sy;
|
||||||
forward[2] = -sp;
|
forward[2] = -sp;
|
||||||
// need to flip right because it's a left handed system in a right handed
|
// need to flip right because the trig produces +Y but right is -Y
|
||||||
// world
|
right[0] = -(sr * sp * cy + cr * -sy);
|
||||||
right[0] = -1 * (sr * sp * cy + cr * -sy);
|
right[1] = -(sr * sp * sy + cr * cy);
|
||||||
right[1] = -1 * (sr * sp * sy + cr * cy);
|
right[2] = -(sr * cp);
|
||||||
right[2] = -1 * (sr * cp);
|
|
||||||
up[0] = (cr * sp * cy + -sr * -sy);
|
up[0] = (cr * sp * cy + -sr * -sy);
|
||||||
up[1] = (cr * sp * sy + -sr * cy);
|
up[1] = (cr * sp * sy + -sr * cy);
|
||||||
up[2] = cr * cp;
|
up[2] = cr * cp;
|
||||||
|
|
Loading…
Reference in a new issue