3ds Max C++ API Reference
Loading...
Searching...
No Matches
Quat Class Reference

#include <quat.h>

Public Member Functions

 Quat ()=default
 
 Quat (const Quat &)=default
 
 Quat (Quat &&)=default
 
Quatoperator= (const Quat &)=default
 
Quatoperator= (Quat &&)=default
 
 Quat (float X, float Y, float Z, float W)
 
 Quat (double X, double Y, double Z, double W)
 
 Quat (float af[4])
 
 Quat (const Matrix3 &mat)
 
 Quat (const AngAxis &aa)
 
 Quat (const Point3 &V, float W)
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
float Scalar ()
 
Point3 Vector ()
 
 operator float * ()
 
Quat operator- () const
 
Quat operator+ () const
 
Quat Inverse () const
 
Quat Conjugate () const
 
Quat LogN () const
 
Quat Exp () const
 
Quatoperator-= (const Quat &)
 
Quatoperator+= (const Quat &)
 
Quatoperator*= (const Quat &)
 
Quatoperator*= (float)
 
Quatoperator/= (float)
 
QuatSet (float X, float Y, float Z, float W)
 
QuatSet (double X, double Y, double Z, double W)
 
QuatSet (const Matrix3 &mat)
 
QuatSet (const AngAxis &aa)
 
QuatSet (const Point3 &V, float W)
 
QuatSetEuler (float X, float Y, float Z)
 
QuatInvert ()
 
QuatMakeClosest (const Quat &qto)
 
int operator== (const Quat &a) const
 
int operator!= (const Quat &a) const
 
int Equals (const Quat &a, float epsilon=1E-6f) const
 
void Identity ()
 
int IsIdentity () const
 
void Normalize ()
 
void MakeMatrix (Matrix3 &mat, bool flag=false) const
 
void GetEuler (float *X, float *Y, float *Z) const
 
Quat operator- (const Quat &) const
 
Quat operator+ (const Quat &) const
 
Quat operator* (const Quat &) const
 
Quat operator/ (const Quat &) const
 
float operator% (const Quat &) const
 
Quat Plus (const Quat &) const
 
Quat Minus (const Quat &) const
 

Public Attributes

float x = 0.f
 
float y = 0.f
 
float z = 0.f
 
float w = 1.f
 

Detailed Description

See also
Class Point3, Class Matrix3, Class AngAxis.

Description:
This class provides a compact representation for orientation in three space and provides methods to perform Quaternion algebra.

Quaternions provide an alternative representation for orientation in three-space. To reduce computing, you can substitute quaternion multiplication for rotation-matrix composition.

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).

The rotation convention in the 3ds Max API is the left-hand-rule. Note that this is different from the right-hand-rule used in the 3ds Max user interface.

For additional information see: Quaternion operations:

From "Quaternion Calculus and Fast Animation",

by Ken Shoemake, in notes for SIGGRAPH 1987 Course # 10,

"Computer Animation: 3-D Motion Specification and Control".

All methods of this class are implemented by the system.
Data Members:
float x,y,z,w;

The x, y, z values make up the vector portion. w is the angle of rotation about the vector (see remarks above for details).

Constructor & Destructor Documentation

◆ Quat() [1/9]

Quat ( )
default
Remarks
Constructor.

◆ Quat() [2/9]

Quat ( const Quat )
default

◆ Quat() [3/9]

Quat ( Quat &&  )
default

◆ Quat() [4/9]

Quat ( float  X,
float  Y,
float  Z,
float  W 
)
inline
Remarks
Constructor. The data members are initialized to the values passed.
193 : x(X)
194 , y(Y)
195 , z(Z)
196 , w(W)
197 {
198 }
float w
Definition: quat.h:179
float y
Definition: quat.h:177
float x
Definition: quat.h:176
float z
Definition: quat.h:178

◆ Quat() [5/9]

Quat ( double  X,
double  Y,
double  Z,
double  W 
)
inline
Remarks
Constructor. The data members are initialized to the values passed (cast as floats).
203 : Quat(float(X), float(Y), float(Z), float(W))
204 {
205 }
Quat()=default

◆ Quat() [6/9]

Quat ( float  af[4])
inline
Remarks
Constructor. The data members are initialized to the values passed.

x = af[0]; y = af[1]; z = af[2]; w = af[3];
211 {
212 x = af[0];
213 y = af[1];
214 z = af[2];
215 w = af[3];
216 }

◆ Quat() [7/9]

Quat ( const Matrix3 mat)
Remarks
Constructor. Convert the specified 3x3 rotation matrix to a unit quaternion.

◆ Quat() [8/9]

Quat ( const AngAxis aa)
Remarks
Constructor. The Quat is initialized to the AngAxis passed.

◆ Quat() [9/9]

Quat ( const Point3 V,
float  W 
)
Remarks
Constructor. The quaternion is initialized from the vector V and angle W passed. The quaternion is then normalized.

Member Function Documentation

◆ operator=() [1/2]

Quat & operator= ( const Quat )
default

◆ operator=() [2/2]

Quat & operator= ( Quat &&  )
default

◆ operator[]() [1/2]

float & operator[] ( int  i)
inline
Remarks
Array access operator. Valid i values: 0=x, 1=y, 2=z, 3=w.
231 {
232 return (&x)[i];
233 }

◆ operator[]() [2/2]

const float & operator[] ( int  i) const
inline
Remarks
Array access operator. Valid i values: 0=x, 1=y, 2=z, 3=w.
237 {
238 return (&x)[i];
239 }

◆ Scalar()

float Scalar ( )
inline
242 {
243 return w;
244 }

◆ Vector()

Point3 Vector ( )
inline
246 {
247 return Point3(x, y, z);
248 }
Definition: point3.h:54

◆ operator float *()

operator float * ( )
inline
Remarks
Returns the address of the Quaternion.

Unary operators
254 {
255 return (&x);
256 }

◆ operator-() [1/2]

Quat operator- ( ) const
inline
Remarks
Unary negation. Returns Quat(-x,-y,-z,-w).
261 {
262 return (Quat(-x, -y, -z, -w));
263 }

◆ operator+() [1/2]

Quat operator+ ( ) const
inline
Remarks
Unary +. Returns the Quat unaltered.

Assignment operators
267 {
268 return *this;
269 }

◆ Inverse()

Quat Inverse ( ) const
Remarks
Returns the inverse of this quaternion (1/q).

◆ Conjugate()

Quat Conjugate ( ) const
Remarks
Returns the conjugate of a quaternion.

◆ LogN()

Quat LogN ( ) const
Remarks
Returns the natural logarithm of a UNIT quaternion.

◆ Exp()

Quat Exp ( ) const
Remarks
Returns the exponentiate quaternion (where q.w==0).
Operators:

◆ operator-=()

Quat & operator-= ( const Quat )
Remarks
This operator is the same as the /= operator.

◆ operator+=()

Quat & operator+= ( const Quat )
Remarks
This operator is the same as the *= operator..

◆ operator*=() [1/2]

Quat & operator*= ( const Quat )
Remarks
Multiplies this quaternion by a quaternion.

◆ operator*=() [2/2]

Quat & operator*= ( float  )
Remarks
Multiplies this quaternion by a floating point value.

◆ operator/=()

Quat & operator/= ( float  )
Remarks
Divides this quaternion by a floating point value.

◆ Set() [1/5]

Quat & Set ( float  X,
float  Y,
float  Z,
float  W 
)
inline
296 {
297 x = X;
298 y = Y;
299 z = Z;
300 w = W;
301 return *this;
302 }
@ X
Using the X axis as the slice axis.
@ Z
Using the Z axis as the slice axis.
@ Y
Using the Y axis as the slice axis.

◆ Set() [2/5]

Quat & Set ( double  X,
double  Y,
double  Z,
double  W 
)
inline
304 {
305 x = (float)X;
306 y = (float)Y;
307 z = (float)Z;
308 w = (float)W;
309 return *this;
310 }

◆ Set() [3/5]

Quat & Set ( const Matrix3 mat)

◆ Set() [4/5]

Quat & Set ( const AngAxis aa)

◆ Set() [5/5]

Quat & Set ( const Point3 V,
float  W 
)
inline
314 {
315 x = V.x;
316 y = V.y;
317 z = V.z;
318 w = W;
319 return *this;
320 }
float y
Definition: point3.h:57
float x
Definition: point3.h:56
float z
Definition: point3.h:58

◆ SetEuler()

Quat & SetEuler ( float  X,
float  Y,
float  Z 
)

◆ Invert()

Quat & Invert ( )

◆ MakeClosest()

Quat & MakeClosest ( const Quat qto)
Remarks
Modifies q so it is on same side of hypersphere as qto.

◆ operator==()

int operator== ( const Quat a) const
Remarks
Returns nonzero if the quaternions are equal; otherwise 0.

◆ operator!=()

int operator!= ( const Quat a) const

◆ Equals()

int Equals ( const Quat a,
float  epsilon = 1E-6f 
) const

◆ Identity()

void Identity ( )
inline
Remarks
Sets this quaternion to the identity quaternion (x=y=z=0.0; w=1.0).
337 {
338 x = y = z = 0.0f;
339 w = 1.0f;
340 }

◆ IsIdentity()

int IsIdentity ( ) const
Remarks
Returns nonzero if the quaternion is the identity; otherwise 0.

◆ Normalize()

void Normalize ( )
Remarks
Normalizes this quaternion, dividing each term by a scale factor such that the resulting sum or the squares of all parts equals unity.

◆ MakeMatrix()

void MakeMatrix ( Matrix3 mat,
bool  flag = false 
) const
Remarks
Converts the quaternion to a 3x3 rotation matrix. The quaternion need not be unit magnitude.
Parameters:
Matrix3 &mat

The matrix.

BOOL b=FALSE

This parameter is available in release 4.0 and later only.

When this argument is set to false (or omitted), each function performs as it did before version 4.0. When the boolean is TRUE, the matrix is made with its terms transposed. When this transposition is specified, EulerToQuat() and QuatToEuler() are consistent with one another. (In 3ds Max 3, they have opposite handedness).

◆ GetEuler()

void GetEuler ( float *  X,
float *  Y,
float *  Z 
) const

◆ operator-() [2/2]

Quat operator- ( const Quat ) const
Remarks
This operator is the same as the / operator.

◆ operator+() [2/2]

Quat operator+ ( const Quat ) const
Remarks
This operator is the same as the * operator.

◆ operator*()

Quat operator* ( const Quat ) const
Remarks
Returns the product of two quaternions.

◆ operator/()

Quat operator/ ( const Quat ) const
Remarks
Returns the ratio of two quaternions: This creates a result quaternion r = p/q, such that q*r = p. (Order of multiplication is important)

◆ operator%()

float operator% ( const Quat ) const

◆ Plus()

Quat Plus ( const Quat ) const

◆ Minus()

Quat Minus ( const Quat ) const

Member Data Documentation

◆ x

float x = 0.f

◆ y

float y = 0.f

◆ z

float z = 0.f

◆ w

float w = 1.f