37 #ifndef INCLUDED_IMATHEULER_H 38 #define INCLUDED_IMATHEULER_H 137 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER 139 #pragma warning(disable:4244) 247 void set(
Axis initial,
279 void angleOrder(
int &i,
int &j,
int &k)
const;
331 #if defined _WIN32 || defined _WIN64 356 j = _parityEven ? (i+1)%3 : (i > 0 ? i-1 : 2);
357 k = _parityEven ? (i > 0 ? i-1 : 2) : (i+1)%3;
367 m[(_initialAxis+1) % 3] = _parityEven ? 1 : 2;
368 m[(_initialAxis+2) % 3] = _parityEven ? 2 : 1;
391 return Vec3<T>((*this)[i],(*this)[j],(*this)[k]);
399 _initialRepeated(false),
408 _initialRepeated(false),
421 if ( l == XYZLayout ) setXYZVector(v);
422 else { x = v.x; y = v.y; z = v.z; }
445 if ( l == XYZLayout ) setXYZVector(
Vec3<T>(xi,yi,zi));
446 else { x = xi; y = yi; z = zi; }
475 if (_initialRepeated)
490 r[i] = (_parityEven? -x: x);
496 M[1][0], M[1][1], M[1][2], 0,
497 M[2][0], M[2][1], M[2][2], 0,
522 r[i] = (_parityEven? -x: x);
528 M[1][0], M[1][1], M[1][2], 0,
529 M[2][0], M[2][1], M[2][2], 0,
557 if (_initialRepeated)
572 r[i] = (_parityEven? -x: x);
601 r[i] = (_parityEven? -x: x);
635 if ( _frameStatic ) angles = (*this);
638 if ( !_parityEven ) angles *= -1.0;
654 if ( _initialRepeated )
656 M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
657 M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
658 M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
662 M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
663 M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
664 M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
678 if ( _frameStatic ) angles = (*this);
681 if ( !_parityEven ) angles *= -1.0;
697 if ( _initialRepeated )
699 M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
700 M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
701 M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
705 M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
706 M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
707 M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
720 if ( _frameStatic ) angles = (*this);
723 if ( !_parityEven ) angles.
y = -angles.
y;
739 T parity = _parityEven ? 1.0 : -1.0;
744 if ( _initialRepeated )
747 a[j] = sj*(cc + ss) * parity,
753 a[i] = cj*sc - sj*cs,
754 a[j] = (cj*ss + sj*cc) * parity,
755 a[k] = cj*cs - sj*sc;
768 return (order & ~Legal) ? false :
true;
775 int foo = (_initialAxis == Z ? 0x2000 : (_initialAxis == Y ? 0x1000 : 0));
777 if (_parityEven) foo |= 0x0100;
778 if (_initialRepeated) foo |= 0x0010;
779 if (_frameStatic) foo++;
787 set( p & 0x2000 ? Z : (p & 0x1000 ? Y : X),
800 _frameStatic = !relative;
801 _parityEven = parityEven;
802 _initialRepeated = firstRepeats;
828 std::ostream& operator << (std::ostream &o, const Euler<T> &euler)
830 char a[3] = {
'X',
'Y',
'Z' };
832 const char* r = euler.frameStatic() ?
"" :
"r";
834 euler.angleOrder(i,j,k);
836 if ( euler.initialRepeated() ) k = i;
842 << a[i] << a[j] << a[k] << r <<
")";
849 angle = fmod(T (angle), T (2 *
M_PI));
851 if (angle < -
M_PI) angle += 2 *
M_PI;
852 if (angle > +
M_PI) angle -= 2 *
M_PI;
861 Vec3<T> d = xyzRot - targetXyzRot;
862 xyzRot[0] = targetXyzRot[0] + angleMod(d[0]);
863 xyzRot[1] = targetXyzRot[1] + angleMod(d[1]);
864 xyzRot[2] = targetXyzRot[2] + angleMod(d[2]);
876 simpleXYZRotation(xyzRot, targetXyzRot);
879 otherXyzRot[i] =
M_PI+xyzRot[i];
880 otherXyzRot[j] =
M_PI-xyzRot[j];
881 otherXyzRot[k] =
M_PI+xyzRot[k];
883 simpleXYZRotation(otherXyzRot, targetXyzRot);
885 Vec3<T> d = xyzRot - targetXyzRot;
886 Vec3<T> od = otherXyzRot - targetXyzRot;
888 T odMag = od.
dot(od);
892 xyzRot = otherXyzRot;
900 Vec3<T> xyzRot = toXYZVector();
904 nearestRotation(xyzRot, targetXyz, order());
906 setXYZVector(xyzRot);
909 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER 910 #pragma warning(default:4244) void extract(const Matrix33< T > &)
Definition: ImathEuler.h:470
Vec3< T > v
Definition: ImathQuat.h:76
Definition: ImathEuler.h:173
Order order() const
Definition: ImathEuler.h:773
Definition: ImathEuler.h:182
Definition: ImathEuler.h:168
Definition: ImathEuler.h:183
T dot(const Vec3 &v) const
Definition: ImathVec.h:1466
Definition: ImathEuler.h:178
Definition: ImathEuler.h:162
Order
Definition: ImathEuler.h:151
bool frameStatic() const
Definition: ImathEuler.h:321
Euler< double > Eulerd
Definition: ImathEuler.h:344
Axis _initialAxis
Definition: ImathEuler.h:334
static void nearestRotation(Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot, Order order=XYZ)
Definition: ImathEuler.h:869
Definition: ImathFrame.h:42
Definition: ImathEuler.h:175
void angleOrder(int &i, int &j, int &k) const
Definition: ImathEuler.h:353
Definition: ImathEuler.h:171
void setOrder(Order)
Definition: ImathEuler.h:785
Definition: ImathFrame.h:43
Definition: ImathEuler.h:172
Definition: ImathEuler.h:166
bool _frameStatic
Definition: ImathEuler.h:328
const Euler< T > & operator=(const Euler< T > &)
Definition: ImathEuler.h:806
const Matrix44 & rotate(const Vec3< S > &r)
Definition: ImathEuler.h:198
Definition: ImathEuler.h:199
Definition: ImathEuler.h:193
static T atan2(T x, T y)
Definition: ImathMath.h:96
Definition: ImathEuler.h:200
Definition: ImathEuler.h:174
Definition: ImathMatrix.h:66
Definition: ImathEuler.h:169
Vec3< T > toXYZVector() const
Definition: ImathEuler.h:387
Definition: ImathEuler.h:205
void setXYZVector(const Vec3< T > &)
Definition: ImathEuler.h:376
Definition: ImathEuler.h:165
Definition: ImathEuler.h:205
Definition: ImathEuler.h:203
T x
Definition: ImathVec.h:274
T y
Definition: ImathVec.h:274
Definition: ImathEuler.h:143
Definition: ImathEuler.h:157
static T cos(T x)
Definition: ImathMath.h:97
InputLayout
Definition: ImathEuler.h:205
Axis
Definition: ImathEuler.h:203
bool initialRepeated() const
Definition: ImathEuler.h:322
Definition: ImathQuat.h:71
void angleMapping(int &i, int &j, int &k) const
Definition: ImathEuler.h:362
Definition: ImathEuler.h:203
Definition: ImathEuler.h:160
T z
Definition: ImathVec.h:274
T r
Definition: ImathQuat.h:75
static void simpleXYZRotation(Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot)
Definition: ImathEuler.h:859
bool parityEven() const
Definition: ImathEuler.h:323
Definition: ImathEuler.h:179
Euler< float > Eulerf
Definition: ImathEuler.h:343
Axis initialAxis() const
Definition: ImathEuler.h:324
Matrix44< T > toMatrix44() const
Definition: ImathEuler.h:671
Definition: ImathEuler.h:159
void makeNear(const Euler< T > &target)
Definition: ImathEuler.h:898
Definition: ImathEuler.h:161
Definition: ImathEuler.h:167
Euler()
Definition: ImathEuler.h:396
Matrix33< T > toMatrix33() const
Definition: ImathEuler.h:628
Definition: ImathEuler.h:158
Definition: ImathBox.h:67
Definition: ImathEuler.h:181
static T sin(T x)
Definition: ImathMath.h:98
void set(Axis initial, bool relative, bool parityEven, bool firstRepeats)
Definition: ImathEuler.h:794
static T sqrt(T x)
Definition: ImathMath.h:114
Matrix33< T > toMatrix33() const
Definition: ImathQuat.h:809
static float angleMod(T angle)
Definition: ImathEuler.h:847
Definition: ImathEuler.h:180
Definition: ImathEuler.h:203
Definition: ImathEuler.h:164
Definition: ImathEuler.h:176
Quat< T > toQuat() const
Definition: ImathEuler.h:714
static bool legal(Order)
Definition: ImathEuler.h:766
bool _parityEven
Definition: ImathEuler.h:330
bool _initialRepeated
Definition: ImathEuler.h:329