HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Euler< T > Class Template Reference

#include <ImathEuler.h>

+ Inheritance diagram for Euler< T >:

Public Member Functions

Constructors

All default to ZYX non-relative (ala Softimage 3D/Maya), where there is no argument to specify it.

The Euler-from-matrix constructors assume that the matrix does not include shear or non-uniform scaling, but the constructors do not examine the matrix to verify this assumption. If necessary, you can adjust the matrix by calling the removeScalingAndShear() function, defined in ImathMatrixAlgo.h.

IMATH_HOSTDEVICE constexpr Euler () IMATH_NOEXCEPT
 No initialization by default. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (const Euler &) IMATH_NOEXCEPT
 Copy constructor. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (Order p) IMATH_NOEXCEPT
 Construct from given Order. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (const Vec3< T > &v, Order o=Default, InputLayout l=IJKLayout) IMATH_NOEXCEPT
 Construct from vector, order, layout. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (T i, T j, T k, Order o=Default, InputLayout l=IJKLayout) IMATH_NOEXCEPT
 Construct from explicit axes, order, layout. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (const Euler< T > &euler, Order newp) IMATH_NOEXCEPT
 Copy constructor with new Order. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (const Matrix33< T > &, Order o=Default) IMATH_NOEXCEPT
 Construct from Matrix33. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler (const Matrix44< T > &, Order o=Default) IMATH_NOEXCEPT
 Construct from Matrix44. More...
 
IMATH_HOSTDEVICE ~Euler ()=default
 Destructor. More...
 
Set Value
IMATH_HOSTDEVICE void setOrder (Order) IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE void setXYZVector (const Vec3< T > &) IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE void set (Axis initial, bool relative, bool parityEven, bool firstRepeats) IMATH_NOEXCEPT
 Set the value. More...
 
Assignments and Conversions
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Euler
< T > & 
operator= (const Euler< T > &) IMATH_NOEXCEPT
 Assignment. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Euler
< T > & 
operator= (const Vec3< T > &) IMATH_NOEXCEPT
 Assignment. More...
 
IMATH_HOSTDEVICE void extract (const Matrix33< T > &) IMATH_NOEXCEPT
 Assign from Matrix33, assumed to be affine. More...
 
IMATH_HOSTDEVICE void extract (const Matrix44< T > &) IMATH_NOEXCEPT
 Assign from Matrix44, assumed to be affine. More...
 
IMATH_HOSTDEVICE void extract (const Quat< T > &) IMATH_NOEXCEPT
 Assign from Quaternion. More...
 
IMATH_HOSTDEVICE Matrix33< TtoMatrix33 () const IMATH_NOEXCEPT
 Convert to Matrix33. More...
 
IMATH_HOSTDEVICE Matrix44< TtoMatrix44 () const IMATH_NOEXCEPT
 Convert to Matrix44. More...
 
IMATH_HOSTDEVICE Quat< TtoQuat () const IMATH_NOEXCEPT
 Convert to Quat. More...
 
IMATH_HOSTDEVICE Vec3< TtoXYZVector () const IMATH_NOEXCEPT
 
- Public Member Functions inherited from Vec3< T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T
operator[] (int i) IMATH_NOEXCEPT
 Element access by index. More...
 
IMATH_HOSTDEVICE constexpr
const T
operator[] (int i) const IMATH_NOEXCEPT
 Element access by index. More...
 
IMATH_HOSTDEVICE Vec3 () IMATH_NOEXCEPT
 Uninitialized by default. More...
 
IMATH_HOSTDEVICE constexpr Vec3 (T a) IMATH_NOEXCEPT
 Initialize to a scalar (a,a,a) More...
 
IMATH_HOSTDEVICE constexpr Vec3 (T a, T b, T c) IMATH_NOEXCEPT
 Initialize to given elements (a,b,c) More...
 
IMATH_HOSTDEVICE constexpr Vec3 (const Vec3 &v) IMATH_NOEXCEPT
 Copy constructor. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec3 (const Vec3< S > &v) IMATH_NOEXCEPT
 Construct from Vec3 of another base type. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr Vec3 (const Vec4< S > &v) IMATH_NOEXCEPT
 
template<class S >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Vec3 (const Vec4< S > &v, InfException)
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator= (const Vec3 &v) IMATH_NOEXCEPT
 Assignment. More...
 
 ~Vec3 () IMATH_NOEXCEPT=default
 Destructor. More...
 
template<typename V , IMATH_ENABLE_IF(has_xyz< V, T >::value) >
IMATH_HOSTDEVICE constexpr Vec3 (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE Vec3 (const V &v)
 
template<typename V , IMATH_ENABLE_IF(has_xyz< V, T >::value) >
IMATH_HOSTDEVICE const Vec3operator= (const V &v) IMATH_NOEXCEPT
 
template<typename V , IMATH_ENABLE_IF(has_subscript< V, T, 3 >::value &&!has_xyz< V, T >::value) >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator= (const V &v)
 
template<class S >
IMATH_HOSTDEVICE void setValue (S a, S b, S c) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void setValue (const Vec3< S > &v) IMATH_NOEXCEPT
 Set the value. More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (S &a, S &b, S &c) const IMATH_NOEXCEPT
 Return the value in a, b, and c More...
 
template<class S >
IMATH_HOSTDEVICE void getValue (Vec3< S > &v) const IMATH_NOEXCEPT
 Return the value in v More...
 
IMATH_HOSTDEVICE TgetValue () IMATH_NOEXCEPT
 Return a raw pointer to the array of values. More...
 
IMATH_HOSTDEVICE const TgetValue () const IMATH_NOEXCEPT
 Return a raw pointer to the array of values. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr bool operator== (const Vec3< S > &v) const IMATH_NOEXCEPT
 Equality. More...
 
template<class S >
IMATH_HOSTDEVICE constexpr bool operator!= (const Vec3< S > &v) const IMATH_NOEXCEPT
 Inequality. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithAbsError (const Vec3< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 bool 
equalWithRelError (const Vec3< T > &v, T e) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE constexpr T dot (const Vec3 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr T operator^ (const Vec3 &v) const IMATH_NOEXCEPT
 Dot product. More...
 
IMATH_HOSTDEVICE constexpr Vec3 cross (const Vec3 &v) const IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator%= (const Vec3 &v) IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator% (const Vec3 &v) const IMATH_NOEXCEPT
 Right-handed cross product. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator+= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator+ (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise addition. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator-= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator- (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise subtraction. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator- () const IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
negate () IMATH_NOEXCEPT
 Component-wise multiplication by -1. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator*= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator*= (T a) IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator* (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator* (T a) const IMATH_NOEXCEPT
 Component-wise multiplication. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator/= (const Vec3 &v) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const Vec3
operator/= (T a) IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator/ (const Vec3 &v) const IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE constexpr Vec3 operator/ (T a) const IMATH_NOEXCEPT
 Component-wise division. More...
 
IMATH_HOSTDEVICE T length () const IMATH_NOEXCEPT
 Return the Euclidean norm. More...
 
IMATH_HOSTDEVICE constexpr T length2 () const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE const Vec3normalize () IMATH_NOEXCEPT
 Normalize in place. If length()==0, return a null vector. More...
 
const Vec3normalizeExc ()
 Normalize in place. If length()==0, throw an exception. More...
 
IMATH_HOSTDEVICE const Vec3normalizeNonNull () IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE Vec3< Tnormalized () const IMATH_NOEXCEPT
 Return a normalized vector. Does not modify *this. More...
 
Vec3< TnormalizedExc () const
 
IMATH_HOSTDEVICE Vec3< TnormalizedNonNull () const IMATH_NOEXCEPT
 

Protected Attributes

bool _frameStatic: 1
 relative or static rotations More...
 
bool _initialRepeated: 1
 init axis repeated as last More...
 
bool _parityEven: 1
 "parity of axis permutation" More...
 
Axis _initialAxis: 2
 First axis of rotation. More...
 

Query

IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Order 
order () const IMATH_NOEXCEPT
 Return the order. More...
 
IMATH_HOSTDEVICE constexpr bool frameStatic () const
 Return frameStatic. More...
 
IMATH_HOSTDEVICE constexpr bool initialRepeated () const
 Return intialRepeated. More...
 
IMATH_HOSTDEVICE constexpr bool parityEven () const
 Return partityEven. More...
 
IMATH_HOSTDEVICE constexpr Axis initialAxis () const
 Return initialAxis. More...
 
IMATH_HOSTDEVICE void angleOrder (int &i, int &j, int &k) const IMATH_NOEXCEPT
 Unpack angles from ijk form. More...
 
IMATH_HOSTDEVICE void angleMapping (int &i, int &j, int &k) const IMATH_NOEXCEPT
 Determine mapping from xyz to ijk (reshuffle the xyz to match the order) More...
 
IMATH_HOSTDEVICE static
constexpr bool 
legal (Order) IMATH_NOEXCEPT
 Return whether the given value is a legal Order. More...
 

Utility Methods

Utility methods for getting continuous rotations. None of these methods change the orientation given by its inputs (or at least that is the intent).

IMATH_HOSTDEVICE void makeNear (const Euler< T > &target) IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE static
IMATH_CONSTEXPR14 float 
angleMod (T angle) IMATH_NOEXCEPT
 Convert an angle to its equivalent in [-PI, PI]. More...
 
static IMATH_HOSTDEVICE void simpleXYZRotation (Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot) IMATH_NOEXCEPT
 Adjust xyzRot so that its components differ from targetXyzRot by no more than +/-PI. More...
 
static IMATH_HOSTDEVICE void nearestRotation (Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot, Order order=XYZ) IMATH_NOEXCEPT
 

Additional Inherited Members

- Public Types inherited from Vec3< T >
typedef T BaseType
 
- Static Public Member Functions inherited from Vec3< T >
IMATH_HOSTDEVICE static
constexpr unsigned int 
dimensions () IMATH_NOEXCEPT
 Return the number of dimensions, i.e. 3. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeLowest () IMATH_NOEXCEPT
 Largest possible negative value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeMax () IMATH_NOEXCEPT
 Largest possible positive value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeSmallest () IMATH_NOEXCEPT
 Smallest possible positive value. More...
 
IMATH_HOSTDEVICE static constexpr T baseTypeEpsilon () IMATH_NOEXCEPT
 Smallest possible e for which 1+e != 1. More...
 
- Public Attributes inherited from Vec3< T >
T x
 
T y
 
T z
 

Detailed Description

template<class T>
class Euler< T >

Template class Euler<T>

The Euler class represents euler angle orientations. The class inherits from Vec3 to it can be freely cast. The additional information is the euler priorities rep. This class is essentially a rip off of Ken Shoemake's GemsIV code. It has been modified minimally to make it more understandable, but hardly enough to make it easy to grok completely.

There are 24 possible combonations of Euler angle representations of which 12 are common in CG and you will probably only use 6 of these which in this scheme are the non-relative-non-repeating types.

The representations can be partitioned according to two criteria:

1) Are the angles measured relative to a set of fixed axis or relative to each other (the latter being what happens when rotation matrices are multiplied together and is almost ubiquitous in the cg community)

2) Is one of the rotations repeated (ala XYX rotation)

When you construct a given representation from scratch you must order the angles according to their priorities. So, the easiest is a softimage or aerospace (yaw/pitch/roll) ordering of ZYX.

float x_rot = 1;
float y_rot = 2;
float z_rot = 3;

Eulerf angles(z_rot, y_rot, x_rot, Eulerf::ZYX);

or:

Eulerf angles( V3f(z_rot,y_rot,z_rot), Eulerf::ZYX );

If instead, the order was YXZ for instance you would have to do this:

float x_rot = 1;
float y_rot = 2;
float z_rot = 3;

Eulerf angles(y_rot, x_rot, z_rot, Eulerf::YXZ);

or:

Eulerf angles( V3f(y_rot,x_rot,z_rot), Eulerf::YXZ );

Notice how the order you put the angles into the three slots should correspond to the enum (YXZ) ordering. The input angle vector is called the "ijk" vector – not an "xyz" vector. The ijk vector order is the same as the enum. If you treat the Euler as a Vec3 (which it inherts from) you will find the angles are ordered in the same way, i.e.:

V3f v = angles;
v.x == y_rot, v.y == x_rot, v.z == z_rot

If you just want the x, y, and z angles stored in a vector in that order, you can do this:

V3f v = angles.toXYZVector()
v.x == x_rot, v.y == y_rot, v.z == z_rot

If you want to set the Euler with an XYZVector use the optional layout argument:

Eulerf angles(x_rot, y_rot, z_rot, Eulerf::YXZ, Eulerf::XYZLayout);

This is the same as:

Eulerf angles(y_rot, x_rot, z_rot, Eulerf::YXZ);

Note that this won't do anything intelligent if you have a repeated axis in the euler angles (e.g. XYX)

If you need to use the "relative" versions of these, you will need to use the "r" enums.

The units of the rotation angles are assumed to be radians.

Definition at line 120 of file ImathEuler.h.

Constructor & Destructor Documentation

template<class T>
IMATH_HOSTDEVICE constexpr Euler< T >::Euler ( )

No initialization by default.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( const Euler< T > &  )

Copy constructor.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( Order  p)

Construct from given Order.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( const Vec3< T > &  v,
Order  o = Default,
InputLayout  l = IJKLayout 
)

Construct from vector, order, layout.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( T  i,
T  j,
T  k,
Order  o = Default,
InputLayout  l = IJKLayout 
)

Construct from explicit axes, order, layout.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( const Euler< T > &  euler,
Order  newp 
)

Copy constructor with new Order.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( const Matrix33< T > &  ,
Order  o = Default 
)

Construct from Matrix33.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler ( const Matrix44< T > &  ,
Order  o = Default 
)

Construct from Matrix44.

template<class T>
IMATH_HOSTDEVICE Euler< T >::~Euler ( )
default

Destructor.

Member Function Documentation

template<class T>
IMATH_HOSTDEVICE void Euler< T >::angleMapping ( int i,
int j,
int k 
) const

Determine mapping from xyz to ijk (reshuffle the xyz to match the order)

template<class T>
IMATH_HOSTDEVICE static IMATH_CONSTEXPR14 float Euler< T >::angleMod ( T  angle)
static

Convert an angle to its equivalent in [-PI, PI].

template<class T>
IMATH_HOSTDEVICE void Euler< T >::angleOrder ( int i,
int j,
int k 
) const

Unpack angles from ijk form.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::extract ( const Matrix33< T > &  )

Assign from Matrix33, assumed to be affine.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::extract ( const Matrix44< T > &  )

Assign from Matrix44, assumed to be affine.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::extract ( const Quat< T > &  )

Assign from Quaternion.

template<class T>
IMATH_HOSTDEVICE constexpr bool Euler< T >::frameStatic ( ) const
inline

Return frameStatic.

Definition at line 251 of file ImathEuler.h.

template<class T>
IMATH_HOSTDEVICE constexpr Axis Euler< T >::initialAxis ( ) const
inline

Return initialAxis.

Definition at line 260 of file ImathEuler.h.

template<class T>
IMATH_HOSTDEVICE constexpr bool Euler< T >::initialRepeated ( ) const
inline

Return intialRepeated.

Definition at line 254 of file ImathEuler.h.

template<class T>
IMATH_HOSTDEVICE static constexpr bool Euler< T >::legal ( Order  )
static

Return whether the given value is a legal Order.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::makeNear ( const Euler< T > &  target)

Adjusts "this" Euler so that its components differ from target by as little as possible. This method might not make sense for Eulers with different order and it probably doesn't work for repeated axis and relative orderings (TODO).

template<class T>
static IMATH_HOSTDEVICE void Euler< T >::nearestRotation ( Vec3< T > &  xyzRot,
const Vec3< T > &  targetXyzRot,
Order  order = XYZ 
)
static

Adjust xyzRot so that its components differ from targetXyzRot by as little as possible. Note that xyz here really means ijk, because the order must be provided.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Euler<T>& Euler< T >::operator= ( const Euler< T > &  )

Assignment.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Euler<T>& Euler< T >::operator= ( const Vec3< T > &  )

Assignment.

template<class T>
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Order Euler< T >::order ( ) const

Return the order.

template<class T>
IMATH_HOSTDEVICE constexpr bool Euler< T >::parityEven ( ) const
inline

Return partityEven.

Definition at line 257 of file ImathEuler.h.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::set ( Axis  initial,
bool  relative,
bool  parityEven,
bool  firstRepeats 
)

Set the value.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::setOrder ( Order  )

Set the order. This does NOT convert the angles, but it does reorder the input vector.

template<class T>
IMATH_HOSTDEVICE void Euler< T >::setXYZVector ( const Vec3< T > &  )

Set the euler value: set the first angle to v[0], the second to v[1], the third to v[2].

template<class T>
static IMATH_HOSTDEVICE void Euler< T >::simpleXYZRotation ( Vec3< T > &  xyzRot,
const Vec3< T > &  targetXyzRot 
)
static

Adjust xyzRot so that its components differ from targetXyzRot by no more than +/-PI.

template<class T>
IMATH_HOSTDEVICE Matrix33<T> Euler< T >::toMatrix33 ( ) const

Convert to Matrix33.

template<class T>
IMATH_HOSTDEVICE Matrix44<T> Euler< T >::toMatrix44 ( ) const

Convert to Matrix44.

template<class T>
IMATH_HOSTDEVICE Quat<T> Euler< T >::toQuat ( ) const

Convert to Quat.

template<class T>
IMATH_HOSTDEVICE Vec3<T> Euler< T >::toXYZVector ( ) const

Reorder the angles so that the X rotation comes first, followed by the Y and Z in cases like XYX ordering, the repeated angle will be in the "z" component

Member Data Documentation

template<class T>
bool Euler< T >::_frameStatic
protected

relative or static rotations

Definition at line 350 of file ImathEuler.h.

template<class T>
Axis Euler< T >::_initialAxis
protected

First axis of rotation.

Definition at line 363 of file ImathEuler.h.

template<class T>
bool Euler< T >::_initialRepeated
protected

init axis repeated as last

Definition at line 353 of file ImathEuler.h.

template<class T>
bool Euler< T >::_parityEven
protected

"parity of axis permutation"

Definition at line 356 of file ImathEuler.h.


The documentation for this class was generated from the following file: