10 #ifndef INCLUDED_IMATHEULER_H
11 #define INCLUDED_IMATHEULER_H
23 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
25 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
27 # pragma warning(push)
28 # pragma warning(disable : 4244)
222 InputLayout l = IJKLayout) IMATH_NOEXCEPT;
225 Euler (
T i,
T j,
T k, Order o = Default, InputLayout l = IJKLayout) IMATH_NOEXCEPT;
282 IMATH_HOSTDEVICE void set (
Axis initial,
bool relative,
bool parityEven,
bool firstRepeats) IMATH_NOEXCEPT;
337 nearestRotation (
Vec3<
T>& xyzRot, const
Vec3<
T>& targetXyzRot, Order
order =
XYZ) IMATH_NOEXCEPT;
350 bool _frameStatic : 1;
353 bool _initialRepeated : 1;
356 bool _parityEven : 1;
358 #if defined _WIN32 || defined _WIN64
387 j = _parityEven ? (i + 1) % 3 : (i > 0 ? i - 1 : 2);
388 k = _parityEven ? (i > 0 ? i - 1 : 2) : (i + 1) % 3;
398 m[(_initialAxis + 1) % 3] = _parityEven ? 1 : 2;
399 m[(_initialAxis + 2) % 3] = _parityEven ? 2 : 1;
410 angleMapping (i, j, k);
421 angleMapping (i, j, k);
422 return Vec3<T> ((*this)[i], (*this)[
j], (*this)[k]);
429 _initialRepeated (false),
438 _initialRepeated (
false),
482 setXYZVector (
Vec3<T> (xi, yi, zi));
517 angleOrder (i, j, k);
519 if (_initialRepeated)
534 r[i] = (_parityEven ? -
x :
x);
559 T sy =
std::sqrt (N[j][i] * N[j][i] + N[k][i] * N[k][i]);
578 r[i] = (_parityEven ? -
x :
x);
603 T cy =
std::sqrt (N[i][i] * N[i][i] + N[i][j] * N[i][j]);
624 angleOrder (i, j, k);
626 if (_initialRepeated)
641 r[i] = (_parityEven ? -
x :
x);
651 T sy =
std::sqrt (N[j][i] * N[j][i] + N[k][i] * N[k][i]);
670 r[i] = (_parityEven ? -
x :
x);
680 T cy =
std::sqrt (N[i][i] * N[i][i] + N[i][j] * N[i][j]);
701 angleOrder (i, j, k);
727 if (_initialRepeated)
733 M[
j][
j] = -cj * ss + cc;
734 M[k][
j] = -cj * cs - sc;
736 M[
j][k] = cj * sc + cs;
737 M[k][k] = cj * cc - ss;
742 M[
j][i] = sj * sc - cs;
743 M[k][i] = sj * cc + ss;
745 M[
j][
j] = sj * ss + cc;
746 M[k][
j] = sj * cs - sc;
760 angleOrder (i, j, k);
786 if (_initialRepeated)
792 M[
j][
j] = -cj * ss + cc;
793 M[k][
j] = -cj * cs - sc;
795 M[
j][k] = cj * sc + cs;
796 M[k][k] = cj * cc - ss;
801 M[
j][i] = sj * sc - cs;
802 M[k][i] = sj * cc + ss;
804 M[
j][
j] = sj * ss + cc;
805 M[k][
j] = sj * cs - sc;
820 angleOrder (i, j, k);
828 angles.
y = -angles.
y;
830 T ti = angles.
x * 0.5;
831 T tj = angles.
y * 0.5;
832 T th = angles.
z * 0.5;
844 T parity = _parityEven ? 1.0 : -1.0;
849 if (_initialRepeated)
851 a[i] = cj * (cs + sc);
852 a[
j] = sj * (cc + ss) * parity,
853 a[k] = sj * (cs - sc);
854 q.
r = cj * (cc - ss);
858 a[i] = cj * sc - sj * cs,
859 a[
j] = (cj * ss + sj * cc) * parity,
860 a[k] = cj * cs - sj * sc;
861 q.
r = cj * cc + sj * ss;
880 int foo = (_initialAxis ==
Z ? 0x2000 : (_initialAxis ==
Y ? 0x1000 : 0));
884 if (_initialRepeated)
896 set (p & 0x2000 ?
Z : (p & 0x1000 ?
Y :
X),
907 _frameStatic = !relative;
908 _parityEven = parityEven;
909 _initialRepeated = firstRepeats;
919 _initialAxis = euler._initialAxis;
920 _frameStatic = euler._frameStatic;
921 _parityEven = euler._parityEven;
922 _initialRepeated = euler._initialRepeated;
955 Vec3<T> d = xyzRot - targetXyzRot;
956 xyzRot[0] = targetXyzRot[0] + angleMod (d[0]);
957 xyzRot[1] = targetXyzRot[1] + angleMod (d[1]);
958 xyzRot[2] = targetXyzRot[2] + angleMod (d[2]);
967 e.angleOrder (i, j, k);
969 simpleXYZRotation (xyzRot, targetXyzRot);
972 otherXyzRot[i] =
M_PI + xyzRot[i];
973 otherXyzRot[
j] =
M_PI - xyzRot[
j];
974 otherXyzRot[k] =
M_PI + xyzRot[k];
976 simpleXYZRotation (otherXyzRot, targetXyzRot);
978 Vec3<T> d = xyzRot - targetXyzRot;
979 Vec3<T> od = otherXyzRot - targetXyzRot;
981 T odMag = od.
dot (od);
985 xyzRot = otherXyzRot;
993 Vec3<T> xyzRot = toXYZVector();
1005 nearestRotation (xyzRot, targetXyz,
order());
1007 setXYZVector (xyzRot);
1015 operator<< (std::ostream& o, const Euler<T>& euler)
1017 char a[3] = {
'X',
'Y',
'Z' };
1019 const char*
r = euler.frameStatic() ?
"" :
"r";
1021 euler.angleOrder (i, j, k);
1023 if (euler.initialRepeated())
1026 return o <<
"(" << euler.x <<
" " << euler.y <<
" " << euler.z <<
" " << a[i] << a[
j] << a[k]
1030 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
1031 # pragma warning(pop)
1035 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
1037 #endif // INCLUDED_IMATHEULER_H
IMATH_HOSTDEVICE constexpr bool parityEven() const
Return partityEven.
SYS_API double cos(double x)
SYS_API double fmod(double x, double y)
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.
SYS_API double atan2(double y, double x)
SIM_API const UT_StringHolder angle
IMATH_HOSTDEVICE Matrix44< T > toMatrix44() const IMATH_NOEXCEPT
Convert to Matrix44.
vfloat4 sqrt(const vfloat4 &a)
GLdouble GLdouble GLdouble z
IMATH_HOSTDEVICE void set(Axis initial, bool relative, bool parityEven, bool firstRepeats) IMATH_NOEXCEPT
Set the value.
IMATH_HOSTDEVICE void setXYZVector(const Vec3< T > &) IMATH_NOEXCEPT
GLboolean GLboolean GLboolean GLboolean a
IMATH_HOSTDEVICE constexpr T dot(const Vec3 &v) const IMATH_NOEXCEPT
Dot product.
Vec3< T > v
The imaginary vector.
GLdouble GLdouble GLdouble q
OIIO_FORCEINLINE bool extract(const vbool4 &a)
IMATH_HOSTDEVICE static constexpr bool legal(Order) IMATH_NOEXCEPT
Return whether the given value is a legal Order.
IMATH_HOSTDEVICE Vec3< T > toXYZVector() const IMATH_NOEXCEPT
IMATH_HOSTDEVICE void extract(const Matrix33< T > &) IMATH_NOEXCEPT
Assign from Matrix33, assumed to be affine.
IMATH_HOSTDEVICE constexpr Axis initialAxis() const
Return initialAxis.
IMATH_HOSTDEVICE static IMATH_CONSTEXPR14 float angleMod(T angle) IMATH_NOEXCEPT
Convert an angle to its equivalent in [-PI, PI].
#define IMATH_EXPORT_ENUM
GLdouble GLdouble GLint GLint order
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)
IMATH_HOSTDEVICE constexpr Euler() IMATH_NOEXCEPT
No initialization by default.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Order order() const IMATH_NOEXCEPT
Return the order.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Euler< T > & operator=(const Euler< T > &) IMATH_NOEXCEPT
Assignment.
IMATH_HOSTDEVICE constexpr bool initialRepeated() const
Return intialRepeated.
Euler< float > Eulerf
Euler of type float.
IMATH_HOSTDEVICE void angleOrder(int &i, int &j, int &k) const IMATH_NOEXCEPT
Unpack angles from ijk form.
Euler< double > Eulerd
Euler of type double.
__hostdev__ constexpr T pi()
Pi constant taken from Boost to match old behaviour.
LeafData & operator=(const LeafData &)=delete
#define IMATH_EXPORT_TEMPLATE_TYPE
IMATH_HOSTDEVICE const Matrix44 & rotate(const Vec3< S > &r) IMATH_NOEXCEPT
IMATH_HOSTDEVICE Matrix33< T > toMatrix33() const IMATH_NOEXCEPT
Convert to Matrix33.
IMATH_HOSTDEVICE void setOrder(Order) IMATH_NOEXCEPT
GA_API const UT_StringHolder N
static IMATH_HOSTDEVICE void nearestRotation(Vec3< T > &xyzRot, const Vec3< T > &targetXyzRot, Order order=XYZ) IMATH_NOEXCEPT
IMATH_HOSTDEVICE void makeNear(const Euler< T > &target) IMATH_NOEXCEPT
IMATH_HOSTDEVICE Quat< T > toQuat() const IMATH_NOEXCEPT
Convert to Quat.
SYS_API double sin(double x)