Value > Basic Data Values > Quat Values |
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 right-hand-rule, namely positive angles rotate counter-clockwise about positive axes, consistent with the convention in the 3ds Max UI.
The x, y, z values make up the vector portion. w is the angle of rotation about the vector.
quat <degrees_float> <axis_point3>
<angleaxis> as quat
<eulerangle> as quat
<matrix3> as quat --extracts the rotation component as a quat
Access quaternion complex components as Floats.
Access derived properties - an angle in degrees and a rotation axis
Quaternion algebra using rotation portion of the matrix3
quats can convert to Matrix3's, Angleaxis's, Eulerangle's
Creates a new copy of the quat value.
The new value contains a copy of the input quat value, and is independent of the input quat value.
Returns true if the quaternion is equal to the identity quaternion (x=y=z=0.0; w=1.0).
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.
Returns the inverse of the quaternion (1/q).
Returns the conjugate of a quaternion.
Returns the natural logarithm of UNIT quaternion.
Returns the exponentiated quaternion (where q.w=0).
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>.
Returns the "log difference" of two quaternions as:
Compute a , the term used in Boehm-type interpolation:
Returns quat rotated by 180 degrees (quaternion space metric) about the specified axis axis_point3 .
Returns the transformation of the specified quaternion by the specified matrix.
squadrev <angle_number> <axis_point3> <start_quat> <start_tangent_quat> <end_tangent_quat> <end_quat> <number>
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 .
Returns a random rotation between the two quats, using Slerp.
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:
Returns the same Euler value for the given Quaternion as shown in the Transform Type-In dialog.Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions .
Returns an array of smooth Euler values from the Quat array.Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.
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: