HDK
|
#include <ImathEuler.h>
Public Member Functions | |
Constructors | |
All default to 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< T > | toMatrix33 () const IMATH_NOEXCEPT |
Convert to Matrix33. More... | |
IMATH_HOSTDEVICE Matrix44< T > | toMatrix44 () const IMATH_NOEXCEPT |
Convert to Matrix44. More... | |
IMATH_HOSTDEVICE Quat< T > | toQuat () const IMATH_NOEXCEPT |
Convert to Quat. More... | |
IMATH_HOSTDEVICE Vec3< T > | toXYZVector () 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 Vec3 & | operator= (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 T * | getValue () IMATH_NOEXCEPT |
Return a raw pointer to the array of values. More... | |
IMATH_HOSTDEVICE const T * | getValue () 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 Vec3 & | normalize () IMATH_NOEXCEPT |
Normalize in place. If length()==0, return a null vector. More... | |
const Vec3 & | normalizeExc () |
Normalize in place. If length()==0, throw an exception. More... | |
IMATH_HOSTDEVICE const Vec3 & | normalizeNonNull () IMATH_NOEXCEPT |
IMATH_HOSTDEVICE Vec3< T > | normalized () const IMATH_NOEXCEPT |
Return a normalized vector. Does not modify *this. More... | |
Vec3< T > | normalizedExc () const |
IMATH_HOSTDEVICE Vec3< T > | normalizedNonNull () 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 |
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.
IMATH_HOSTDEVICE constexpr Euler< T >::Euler | ( | ) |
No initialization by default.
Copy constructor.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler | ( | Order | p | ) |
Construct from given Order.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler | ( | const Vec3< T > & | v, |
Order | o = Default , |
||
InputLayout | l = IJKLayout |
||
) |
Construct from vector, order, layout.
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.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler | ( | const Euler< T > & | euler, |
Order | newp | ||
) |
Copy constructor with new Order.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler | ( | const Matrix33< T > & | , |
Order | o = Default |
||
) |
Construct from Matrix33.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Euler< T >::Euler | ( | const Matrix44< T > & | , |
Order | o = Default |
||
) |
Construct from Matrix44.
|
default |
Destructor.
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)
|
static |
Convert an angle to its equivalent in [-PI, PI].
Unpack angles from ijk form.
Assign from Matrix33, assumed to be affine.
Assign from Matrix44, assumed to be affine.
Assign from Quaternion.
|
inline |
Return frameStatic.
Definition at line 251 of file ImathEuler.h.
|
inline |
Return initialAxis.
Definition at line 260 of file ImathEuler.h.
|
inline |
Return intialRepeated.
Definition at line 254 of file ImathEuler.h.
|
static |
Return whether the given value is a legal Order.
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).
|
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.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Euler<T>& Euler< T >::operator= | ( | const Euler< T > & | ) |
Assignment.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Euler<T>& Euler< T >::operator= | ( | const Vec3< T > & | ) |
Assignment.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Order Euler< T >::order | ( | ) | const |
Return the order.
|
inline |
Return partityEven.
Definition at line 257 of file ImathEuler.h.
IMATH_HOSTDEVICE void Euler< T >::set | ( | Axis | initial, |
bool | relative, | ||
bool | parityEven, | ||
bool | firstRepeats | ||
) |
Set the value.
IMATH_HOSTDEVICE void Euler< T >::setOrder | ( | Order | ) |
Set the order. This does NOT convert the angles, but it does reorder the input vector.
Set the euler value: set the first angle to v[0]
, the second to v[1]
, the third to v[2]
.
|
static |
Adjust xyzRot so that its components differ from targetXyzRot by no more than +/-PI.
IMATH_HOSTDEVICE Matrix33<T> Euler< T >::toMatrix33 | ( | ) | const |
Convert to Matrix33.
IMATH_HOSTDEVICE Matrix44<T> Euler< T >::toMatrix44 | ( | ) | const |
Convert to Matrix44.
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
relative or static rotations
Definition at line 350 of file ImathEuler.h.
First axis of rotation.
Definition at line 363 of file ImathEuler.h.
init axis repeated as last
Definition at line 353 of file ImathEuler.h.
"parity of axis permutation"
Definition at line 356 of file ImathEuler.h.