vec_rotate (VECTOR* vDir, ANGLE* vAng)

Rotates a direction vector by pan, tilt and roll Euler angle.

vec_rotateback (VECTOR* vDir, ANGLE* vAng)

Inverse rotation: rotates a direction vector that was rotated by an Euler angle back to its original orientation ( A7.08 ).

vec_rotateaxis (VECTOR* vDir,VECTOR* vAxis,var angle)

Quaternion rotation: rotates a direction vector by an angle about a given rotation axis ( A7.08 ).


vDir Pointer to a direction vector that is rotated.
vAng Pointer to an Euler angle vector. Only the pan and tilt components are used.
vAxis Pointer to a direction vector that serves as rotation axis.
angle Rotation about vAxis in 0..360 degrees counterclockwise.








A position can be rotated around a center by subtracting the center vector from the position, rotating the result, and then adding the center vector again.


var direction[3] = { 10, 0, 0 }; // vector of length 10, pointing straight eastwards in the XYZ coordinate system
var angle[3] = { 90, 45, 0 };    // pan 90 degrees, tilt 45 degrees

The direction vector now has the new values 0, 7.07, 7.07. It was rotated by 90 degrees counterclockwise and tilted by 45 degrees upwards, so it now points to the north and halfway upwards.

See also:

Vectors, angles, ang_add, vec_to_angle, vec_for_angle

► latest version online