ang_diff(ANGLE* a, ANGLE* a1, ANGLE* a2)

Calculates the difference of two Euler angles. When the angle a2 is rotated by the result angle a, it ends up at a1.

Parameters:

a1 - destination angle.
a2 - initial angle.
a - angle difference between a1 and a2.

Speed:

Medium

Remarks:

Example (lite-C):

// Calculate an angle that aligns an axis to a vector 
// (see also the ang_for_axis example for a different method) 
function ang_align(ANGLE* ang,VECTOR* to,VECTOR* axis)
{
ANGLE axis_angle,target_angle;
vec_to_angle(axis_angle,axis); // f.i. (0,0,1) for the vertical axis
vec_to_angle(target_angle,to); // target angle to align to
ang_diff(ang,target_angle,axis_angle); // rotate angle by the difference of the axis and vector
}

See also:

pan, tilt, roll, vec_to_angle, ang, ang_for_axis, ang_rotate, vec_diff

► latest version online