3ds Max C++ API Reference
RotationValue Class Reference

#include <euler.h>

+ Inheritance diagram for RotationValue:

Public Types

enum  EulerType {
  kXYZ = EULERTYPE_XYZ , kXZY , kYZX , kYXZ ,
  kZXY , kZYX , kXYX , kYZY ,
  kZXZ
}
 
enum  { kReptd = kXYX , kQuat = 100 }
 

Public Member Functions

void Set (const Point3 &a, EulerType et)
 
void Set (const Quat &q)
 
 RotationValue ()
 
 RotationValue (const Point3 &a, EulerType et)
 
 RotationValue (const Quat &q)
 
 RotationValue (const RotationValue &src)
 
Point3 Euler (EulerType et=kXYZ) const
 
 operator Quat () const
 
 operator Matrix3 () const
 
void PreApplyTo (Matrix3 &m) const
 
void PostApplyTo (Matrix3 &m) const
 
void PostRotate (const AngAxis &aa)
 
int NativeRep () const
 
Quat GetNative () const
 

Static Public Member Functions

static bool IsEuler (int rep)
 
static bool IsRepetitive (int rep)
 
static bool IsQuat (int rep)
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Static Public Attributes

static const int kAxisToOrdinal [kReptd][3]
 
static const int kOrdinalToAxis [kZXZ+1][3]
 

Protected Member Functions

Point3 ToEulerAngles (EulerType et) const
 
Quat ToQuat () const
 

Detailed Description

Note
This class is only available in release 5 or later.

This class is to hold different representations of the rotation. In particular, it holds rotation value as represented by Euler angles or quaternion. Different types of rotation controllers may use different representations. To avoid losing information due to converting from one representation to another, we can use RotationValue to hold the result.

For example, the Skin pose feature reads rotation of a node from the rotation controller and stores the result in RotationValue (c.f. maxsdk/include/iSkinPose.h).

// Assuming node is a valid pointer to INode.
// skpose should not be null for Max version 5.0 or later.
RotationValue rv = skpose-\>SkinRot();
Definition: iSkinPose.h:31
static ISkinPose * GetISkinPose(INode &n)
Definition: iSkinPose.h:43
Definition: euler.h:97

It is guaranteed that rv keeps the original representation of the controller.

Being asked of Euler angles, RotationValue will return 3 float numbers in the format of Point3. There must be an association between numbers and axes.

There are two classes of Euler angle types. In one class, the rotation axes are not repeated (non-repetitive). They are enum's from kXYZ to kZYX. In the other class, one of the rotation axes is repeated (repetitive). They are enum's from kXYX to kZXZ. For convenience, enum kReptd is used to denote the starting one: kRept == kXYX.

For non-repetitive Euler angles, there are two well-defined methods to associate three ordered angles, to three axes.

First, we can associate angles with x-, y-, and z-, axes, respectively. The first angle, for example, is always associated with the x-axis, no matter where it appears in the Euler order. Suppose

Point3 a(0.1, 0.2, 0.3)

then a.x (==0.1), a.y(==0.2), a.z (==0.3), are the angles of the x-axis, y-axis, and z-axis, respectively, no matter whether the order (type) of the Euler angles is kXYZ or kZXY.

Let's call this way of association by axis (name).

Second, we can associate them by position: the first angle, from left, is always associated with the first axis in the Euler angle order. For examples, the first angle is applied to the x-axis for kXYZ and kXZY, but to the y-axis for kYXZ and kYZX, etc. Suppose a is a Point3, a0, a1, a2, are the angles of the z-axis, x-axis, and y-axis, respectively, for Euler type kZXY.

Let's call this way of association by order.

For repetitive Euler type, the association by axis is ambiguous because one axis may appear twice in the Euler axes. In this case, "by order" is well defined.

This class uses the association of by axis for non-repetitive types and by order for repetitive type. Suppose,

Point3 a = rv.Euler(RotationValue::kZXZ) // repetitive Euler type

Then, a[0] and a[2] are both applied to the Z axis, but a[0] corresponds to the first z-axis from left, a[2] corresponds to the second z-axis (third axis) from left, and a[1] corresponds to the x-axis.

Member Enumeration Documentation

◆ EulerType

enum EulerType
Enumerator
kXYZ 
kXZY 
kYZX 
kYXZ 
kZXY 
kZYX 
kXYX 
kYZY 
kZXZ 
125  {
127  kXZY,
128  kYZX,
129  kYXZ,
130  kZXY,
131  kZYX,
132  kXYX,
133  kYZY,
134  kZXZ
135  };
@ kZXY
Definition: euler.h:130
@ kXZY
Definition: euler.h:127
@ kZYX
Definition: euler.h:131
@ kYXZ
Definition: euler.h:129
@ kZXZ
Definition: euler.h:134
@ kXYX
Definition: euler.h:132
@ kYZX
Definition: euler.h:128
@ kXYZ
Definition: euler.h:126
@ kYZY
Definition: euler.h:133
#define EULERTYPE_XYZ
Definition: euler.h:22

◆ anonymous enum

anonymous enum
Enumerator
kReptd 
kQuat 
137  {
138  kReptd = kXYX,
139  kQuat = 100
140  };
@ kReptd
Definition: euler.h:138
@ kQuat
Definition: euler.h:139

Constructor & Destructor Documentation

◆ RotationValue() [1/4]

RotationValue ( )
inline
Remarks
Constructor
191  : mQ()
192  , mRep(kXYZ)
193  {
194  }

◆ RotationValue() [2/4]

RotationValue ( const Point3 a,
EulerType  et 
)
inline
Remarks
Constructor
197  {
198  Set(a, et);
199  }
void Set(const Point3 &a, EulerType et)
Definition: euler.h:174

◆ RotationValue() [3/4]

RotationValue ( const Quat q)
inline
Remarks
K Prototype

Constructor.
203  {
204  Set(q);
205  }

◆ RotationValue() [4/4]

RotationValue ( const RotationValue src)
inline
Remarks
Copy constructor.
208  : mQ(src.mQ)
209  , mRep(src.mRep)
210  {
211  }

Member Function Documentation

◆ IsEuler()

static bool IsEuler ( int  rep)
inlinestatic
Remarks
Conveniency (static) method to test whether an integer corresponds to an enum of rotation representations used in RotationValue of type Euler angles

146  {
147  return (kXYZ <= rep && rep <= kZXZ);
148  }

◆ IsRepetitive()

static bool IsRepetitive ( int  rep)
inlinestatic
Remarks
Conveniency (static) method to test whether in cases where a call to IsEuler(int rep) is made, and the return value is of type Euler angles, this method call returns whether it has repetitive axes (such as XYX).

155  {
156  // Pre-cond: IsEuler(rep)
157  return rep >= kReptd;
158  }

◆ IsQuat()

static bool IsQuat ( int  rep)
inlinestatic
Remarks
Conveniency (static) method to test whether an integer corresponds to an enum of rotation representations used in RotationValue of type Quaternion.

164  {
165  return rep == kQuat;
166  }

◆ Set() [1/2]

void Set ( const Point3 a,
EulerType  et 
)
inline
Remarks
Set an object of RotationValue to an Euler angle representation. Angles are assumed in radians. To set to Euler angles of x, y, z, of order XYZ, do, for example:

RotationValue a;

a.Set(Point3(x, y, z), RotationValue::kXYZ);

175  {
176  mQ.x = a.x;
177  mQ.y = a.y;
178  mQ.z = a.z;
179  mRep = (short)et;
180  }
float y
Definition: point3.h:61
float x
Definition: point3.h:60
float z
Definition: point3.h:62
float y
Definition: quat.h:178
float x
Definition: quat.h:177
float z
Definition: quat.h:179

◆ Set() [2/2]

void Set ( const Quat q)
inline
Remarks
Set an object of RotationValue to a quaternion representation.

185  {
186  mQ = q;
187  mRep = kQuat;
188  }

◆ Euler()

Point3 Euler ( EulerType  et = kXYZ) const
inline
Remarks
Used to get the rotation in specific representation. Suppose rv is a RotationValue, to get it in terms of Euler angles of order XYZ:

rv.Euler();

in order ZXY:

rv.Euler(RotationValue::kZXY);

or, to get it in quaternion:

(Quat)rv;

to get it in matrix form:

(Matrix3)rv
223  {
224  if (et == mRep)
225  return Point3(mQ.x, mQ.y, mQ.z);
226  else
227  return ToEulerAngles(et);
228  }
Definition: point3.h:56
Point3 ToEulerAngles(EulerType et) const

◆ operator Quat()

operator Quat ( ) const
inline
Remarks
Please see method Euler() for fuller explanation.
231  {
232  if (mRep == kQuat)
233  return mQ;
234  else
235  return ToQuat();
236  }
Quat ToQuat() const

◆ operator Matrix3()

operator Matrix3 ( ) const
Remarks
Please see method Euler() for fuller explanation.

◆ PreApplyTo()

void PreApplyTo ( Matrix3 m) const
Remarks
Given a matrix, m, we can apply the rotation, rv, of RotationValue from left side (PreApplyTo)

rv.PreApplyTo(m) == ((Matrix3)rv) * m

◆ PostApplyTo()

void PostApplyTo ( Matrix3 m) const
Remarks
Given a matrix, m, we can apply the rotation, rv, of RotationValue from right side (PoseApplyTo)

rv.PoseApplyTo(m) == m * (Matrix3)rv)

◆ PostRotate()

void PostRotate ( const AngAxis aa)
Remarks
To apply a rotation, aa, as represented as AngAxis to a RotationValue, rv, from the right side,

rv.PostRotate(aa)

The internal representation of rv after applying to it will not be change. Mathematically,

(Matrix3)rv.PostRotate(aa) == ((Matrix3)rv) * MatrixOf(aa)

If rv is in Euler angles, this method will try to keep the Euler angles from jumping at the borders of (+/-)180 degrees.

◆ NativeRep()

int NativeRep ( ) const
inline
Remarks
Used to get the internal representation and returns the representation type. If it is a Euler angle type, the first three numbers of the Quat returned from GetNative() are to be interpreted as Euler angles.
264  {
265  return mRep;
266  }

◆ GetNative()

Quat GetNative ( ) const
inline
Remarks
Used to get the internal representation and returns the actual float numbers.
270  {
271  return mQ;
272  }

◆ ToEulerAngles()

Point3 ToEulerAngles ( EulerType  et) const
protected

◆ ToQuat()

Quat ToQuat ( ) const
protected

Member Data Documentation

◆ kAxisToOrdinal

const int kAxisToOrdinal[kReptd][3]
static

◆ kOrdinalToAxis

const int kOrdinalToAxis[kZXZ+1][3]
static