The Quat class provides a compact representation for orientation in three space and provides methods to perform Quaternion algebra. Quaternions are used to store object rotations in 3ds Max. A quaternion is made up of four terms: a real scalar part which specifies the amount of rotation and an imaginary vector part which defines the axis of rotation. If the quaternion is normalized, the scalar term equals the cosine of half the angle of rotation, the vector term is the axis of rotation, and the magnitude of the vector term equals the sine of half the angle of rotation.
Interpolation between two key frame orientations is much easier using quaternions and produces smooth and natural motion. Unlike Euler angles, no numerical integration is necessary; quaternions provide an analytic result (no approximations).
Rotations in MAXScript follow the righthandrule, namely positive angles rotate counterclockwise about positive axes, consistent with the convention in the 3ds Max UI.
Constructors
quat
The x, y, z values make up the vector portion. w is the angle of rotation about the vector.
quat
Properties
quaternion complex components as Floats
derived properties  an angle in degrees and a rotation axis
Operators

Quaternion algebra
Quaternion algebra using rotation portion of the matrix3
quats can convert to Matrix3's, Angleaxis's, Eulerangle's
copy
Creates a new copy of the quat value. For example:
newQuat = copy oldQuat
The new value contains a copy of the input quat value, and is independent of the input quat value.
isIdentity
Returns true if the quaternion is equal to the identity quaternion (x=y=z=0.0; w=1.0).
normalize
Returns a normalized quat, dividing each term of the input quat by a scale factor such that the resulting sum of the squares of all parts equals unity.
inverse
Returns the inverse of the quaternion (1/q).
conjugate
Returns the conjugate of a quaternion.
logN
Returns the natural logarithm of UNIT quaternion.
exp
Returns the exponentiated quaternion (where q.w=0).
slerp
Returns a spherical linear interpolation of UNIT quaternions. As number goes from 0 to 1, the returned value goes from start_quat to end_quat.
LnDif
Returns the "log difference" of two quaternions as:
logN ((inverse p_quat)*q_quat)
qCompA
Compute a, the term used in Boehmtype interpolation:
a = now_quat * exp((1/4)*(logN((inverse now_quat)*next_quat)+ logN((inverse now_quat)*prev_quat)))
?
squad
slerp (slerp p_quat q_quat number) \
(slerp a_quat b_quat number) \
(2*(1number)*number)
qorthog
Returns quat rotated by 180 degrees (quaternion space metric) about the specified axis axis_point3.
transform
Returns the transformation of the specified quaternion by the specified matrix.
squadrev
Returns quaternion interpolation for angles > 2PI where angle_number is angle of rotation, and axis_point3 is axis of rotation. As number goes from 0 to 1, the returned value goes from start_quat to end_quat.
random
Returns a random rotation between the two quats, using Slerp.
quatToEuler
eulerToQuat
Convert between quat and euler angle values. The optional order parameter specifies the order of application of the angles. If not specified, XYZ ordering is used. Its value can be any of the following:
1  XYZ
2  XZY
3  YZX
4  YXZ
5  ZXY
6  ZYX
7  XYX
8  YZY
9  ZXZ
getEulerQuatAngleRatio
When converting a series of quat values to eulerAngles values, it is possible for sign flips to occur in the eulerAngles values. This is due to the fact that one single quat value can be expressed through many different eulerAngles values. This flip can be detected by based on the eulerAngles/quat ratio. The eulerAngles/quat ratio is the relation of the angle difference in eulerAngles space to the angle difference in quat space. If this ratio is bigger than PI the rotation between the two quat to eulerAngles conversions. This method returns the eulerAngles/quat angle ratio between the two quat to eulerAngles conversions as a float value. The actual detection of the flip is dependent on the amount of rotation in between conversions. The smaller the amount of rotation, the more accurate the detection is. The parameters to this method are:
quat1 and quat2 are the previous and current rotation values.
eulerAngles1 and eulerAngles2 are the previous and current converted rotation angles.
The optional eulertype_integer parameter specifies the order of application of the angles. If not specified, XYZ ordering is used. Its value can be any of the following:
1  XYZ
2  XZY
3  YZX
4  YXZ
5  ZXY
6  ZYX
7  XYX
8  YZY
9  ZXZ