37 #ifndef INCLUDED_IMATHEULER_H
38 #define INCLUDED_IMATHEULER_H
139 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
141 #pragma warning(disable:4244)
281 void angleOrder(
int &i,
int &j,
int &k)
const;
333 #if defined _WIN32 || defined _WIN64
358 j = _parityEven ? (i+1)%3 : (i > 0 ? i-1 : 2);
359 k = _parityEven ? (i > 0 ? i-1 : 2) : (i+1)%3;
369 m[(_initialAxis+1) % 3] = _parityEven ? 1 : 2;
370 m[(_initialAxis+2) % 3] = _parityEven ? 2 : 1;
393 return Vec3<T>((*this)[i],(*this)[j],(*this)[k]);
401 _initialRepeated(false),
410 _initialRepeated(false),
423 if ( l == XYZLayout ) setXYZVector(v);
424 else {
x = v.
x;
y = v.
y;
z = v.
z; }
447 if ( l == XYZLayout ) setXYZVector(
Vec3<T>(xi,yi,zi));
448 else {
x = xi;
y = yi;
z = zi; }
477 if (_initialRepeated)
492 r[i] = (_parityEven? -
x:
x);
498 M[1][0], M[1][1], M[1][2], 0,
499 M[2][0], M[2][1], M[2][2], 0,
524 r[i] = (_parityEven? -
x:
x);
530 M[1][0], M[1][1], M[1][2], 0,
531 M[2][0], M[2][1], M[2][2], 0,
559 if (_initialRepeated)
574 r[i] = (_parityEven? -
x:
x);
603 r[i] = (_parityEven? -
x:
x);
637 if ( _frameStatic ) angles = (*this);
640 if ( !_parityEven ) angles *= -1.0;
656 if ( _initialRepeated )
658 M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
659 M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
660 M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
664 M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
665 M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
666 M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
680 if ( _frameStatic ) angles = (*this);
683 if ( !_parityEven ) angles *= -1.0;
699 if ( _initialRepeated )
701 M[i][i] = cj; M[j][i] = sj*si; M[k][i] = sj*ci;
702 M[i][j] = sj*sh; M[j][j] = -cj*ss+cc; M[k][j] = -cj*cs-sc;
703 M[i][k] = -sj*ch; M[j][k] = cj*sc+cs; M[k][k] = cj*cc-ss;
707 M[i][i] = cj*ch; M[j][i] = sj*sc-cs; M[k][i] = sj*cc+ss;
708 M[i][j] = cj*sh; M[j][j] = sj*ss+cc; M[k][j] = sj*cs-sc;
709 M[i][k] = -sj; M[j][k] = cj*si; M[k][k] = cj*ci;
722 if ( _frameStatic ) angles = (*this);
725 if ( !_parityEven ) angles.
y = -angles.
y;
741 T parity = _parityEven ? 1.0 : -1.0;
746 if ( _initialRepeated )
749 a[j] = sj*(cc + ss) * parity,
755 a[i] = cj*sc - sj*cs,
756 a[j] = (cj*ss + sj*cc) * parity,
757 a[k] = cj*cs - sj*sc;
770 return (order & ~Legal) ?
false :
true;
777 int foo = (_initialAxis ==
Z ? 0x2000 : (_initialAxis ==
Y ? 0x1000 : 0));
779 if (_parityEven) foo |= 0x0100;
780 if (_initialRepeated) foo |= 0x0010;
781 if (_frameStatic) foo++;
789 set( p & 0x2000 ?
Z : (p & 0x1000 ?
Y :
X),
802 _frameStatic = !relative;
803 _parityEven = parityEven;
804 _initialRepeated = firstRepeats;
830 std::ostream& operator << (std::ostream &o, const Euler<T> &euler)
832 char a[3] = {
'X',
'Y',
'Z' };
834 const char*
r = euler.frameStatic() ?
"" :
"r";
836 euler.angleOrder(i,j,k);
838 if ( euler.initialRepeated() ) k = i;
844 << a[i] << a[j] << a[k] << r <<
")";
852 angle =
fmod(
T (angle),
T (2 * pi));
854 if (angle < -pi) angle += 2 *
pi;
855 if (angle > +pi) angle -= 2 *
pi;
864 Vec3<T> d = xyzRot - targetXyzRot;
865 xyzRot[0] = targetXyzRot[0] + angleMod(d[0]);
866 xyzRot[1] = targetXyzRot[1] + angleMod(d[1]);
867 xyzRot[2] = targetXyzRot[2] + angleMod(d[2]);
879 simpleXYZRotation(xyzRot, targetXyzRot);
882 otherXyzRot[i] =
M_PI+xyzRot[i];
883 otherXyzRot[j] =
M_PI-xyzRot[j];
884 otherXyzRot[k] =
M_PI+xyzRot[k];
886 simpleXYZRotation(otherXyzRot, targetXyzRot);
888 Vec3<T> d = xyzRot - targetXyzRot;
889 Vec3<T> od = otherXyzRot - targetXyzRot;
891 T odMag = od.
dot(od);
895 xyzRot = otherXyzRot;
903 Vec3<T> xyzRot = toXYZVector();
915 nearestRotation(xyzRot, targetXyz,
order());
917 setXYZVector(xyzRot);
920 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
921 #pragma warning(default:4244)
927 #endif // INCLUDED_IMATHEULER_H
#define IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
const Euler< T > & operator=(const Euler< T > &)
SYS_API double fmod(double x, double y)
GLuint GLdouble GLdouble GLint GLint order
bool initialRepeated() const
#define IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
static float angleMod(T angle)
void setXYZVector(const Vec3< T > &)
Matrix44< T > toMatrix44() const
static void simpleXYZRotation(Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot)
GLdouble GLdouble GLdouble GLdouble q
Matrix33< T > toMatrix33() const
GLuint GLfloat GLfloat GLfloat x1
bool extract(const vbool4 &a)
void extract(const Matrix33< T > &)
T dot(const Vec3 &v) const
GLboolean GLboolean GLboolean GLboolean a
Vec3< T > toXYZVector() const
void makeNear(const Euler< T > &target)
GLdouble GLdouble GLdouble z
void set(Axis initial, bool relative, bool parityEven, bool firstRepeats)
void angleMapping(int &i, int &j, int &k) const
GA_API const UT_StringHolder N
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
const Matrix44 & rotate(const Vec3< S > &r)
void angleOrder(int &i, int &j, int &k) const
static void nearestRotation(Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot, Order order=XYZ)
Matrix33< T > toMatrix33() const