pan
tilt
roll
The Euler angles that describe
rotations about the Z, Y, and X axis (in degrees, 0..360).
An entity can be rotated by changing
these values.
Range:
pan: 0 .. 360
tilt: -90 .. +90
roll: 0 .. 360
Type:
var; entity.pan can also
be passed as
ANGLE* vector to functions.
Remarks:
-
Angles are given in degrees (0 to 360) and counted counter-clockwise.
For rotations in three dimensions the so-called Euler angles are
used: pan is the horizontal angle (0..360) about the upright
Z axis, tilt is the vertical angle (-90..+90) about the
rotated Y axis, and roll is the angle (0..360) about the
rotated and tilted X axis (see image). For a pan angle, 0 degrees is equivalent to
the positive direction of the X-axis coordinate, which points to the east
of the map. 90 degrees is north, 180 degrees west, and 270 degrees south.
- By
changing any of these values, the entity rotates relative to the
world coordinate system. This is not the same as rotating the entity about
it's own axes that may be arbitrarily tilted when the entity was rotated
byfore. For
rotating
an entity about it's own axis,
which is
often required for flight or spaceship simulators, use the ang_add or ang_rotate functions.
- For orienting the entity in a certain direction or towards a certain point
in space, use the vec_to_angle function.
-
Angles have a special meaning with sprites. If all angles are at zero,
the sprite will stand upright and horizontally face the camera. If its pan or tilt angle
is nonzero, the sprite is oriented in world space according to its angles.
If pan and tilt both
are 0, but the roll angle is nonzero, the sprite is always perpendicular
to the camera. This is useful for spherical
objects, like fireballs or explosions. For an angle to be nonzero it's sufficient
to set it at a small amount, like 0.01.
- Exceeding the angle ranges given above is possible. But be aware of
ambiguities in entity orientation, and of 'gimbal lock' problems. If you
don't know what angle ambiguities and gimbal lock problems are and how to
deal with them, better do not exceed the angle limits.
- Don't change entity angles more than once per frame.
This could otherwise cause
problems with intermediate rotations because Euler angles are internally
converted to a rotation matrix resp. a quaternion.
Example:
action rotator()
{
while(1)
{
my.pan += time_step;
wait(1);
}
}
See also:
ang_add, vec_rotate, vec_to_angle
► latest
version online