ang_rotate(ANGLE* angle1, ANGLE* angle2)

ang_add(ANGLE* angle1, ANGLE* angle2)

Rotates an Euler angle by another Euler angle, in order to rotate an object or view about its local axes, rather than the X Y Z axis of the world coordinate system. This is mostly used for rotating aircraft or spaceship about their own axes, rather than the world axes. ang_rotate rotates angle1 by angle2, ang_add rotates angle2 by angle1. The result is always stored in angle1, which can also be an entity or view pan angle.


angle1 - pan/tilt/roll Euler angle to be modified
angle2 - pan/tilt/roll Euler angle used for rotation.



Examples (lite-C):

// An entity rotates about its vertical axis, regardless of its orientation in space
function ent_rotatepan(ENTITY* ent)
  while(1) {

// A camera is hunting a target and turns with it, keeping the target always in the middle of the view.
function chase_camera(ENTITY* ent)
// calculate the camera view's direction angle to the target
  var cam_dist[3] = {-200,-100,-100}; // xyz distance vector from the camera to the target
  var cam_ang[3] = {0,0,0}; // direction angle of the camera to the target.

  while (1)
// place the camera at the right position to the target
// Set the camera angles to the camera view direction 
// and rotate it about the target angle 

See also:

pan, tilt, roll, vec_to_angle, vec_rotate, c_rotate

► latest version online