17 #ifndef INCLUDED_IMATHQUAT_H
18 #define INCLUDED_IMATHQUAT_H
27 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
29 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
31 # pragma warning(push)
32 # pragma warning(disable : 4244)
187 setRotation (const
Vec3<
T>& fromDirection, const
Vec3<
T>& toDirection) IMATH_NOEXCEPT;
221 Quat<
T>& qb) IMATH_NOEXCEPT;
229 template <
class T> std::ostream& operator<< (std::ostream& o, const
Quat<
T>& q);
322 T rtmp =
r *
q.r - (
v ^
q.v);
323 v =
r *
q.v +
v *
q.r +
v %
q.v;
341 *
this = *
this *
q.inverse();
391 return r ==
q.r &&
v ==
q.v;
399 return r !=
q.r ||
v !=
q.v;
407 return q1.r * q2.r + (q1.v ^ q2.v);
440 return Quat (
r / l,
v / l);
455 T qdot = *
this ^ *
this;
456 return Quat (
r / qdot, -
v / qdot);
463 T qdot = (*this) ^ (*this);
493 return r *
q.r +
v.x *
q.v.x +
v.y *
q.v.y +
v.z *
q.v.z;
553 return slerp (q1, -q2,
t);
638 k = theta / sintheta;
653 T theta =
v.length();
660 k = sintheta / theta;
664 return Quat<T> (costheta,
v.x * k,
v.y * k,
v.z * k);
678 return v.normalized();
719 setRotationInternal (f0, t0, *
this);
733 setRotationInternal (f0, h0, *
this);
736 setRotationInternal (h0, t0, q);
752 if (f02.
x <= f02.
y && f02.
x <= f02.
z)
754 else if (f02.
y <= f02.
z)
755 v = (f0 %
Vec3<T> (0, 1, 0)).normalized();
757 v = (f0 %
Vec3<T> (0, 0, 1)).normalized();
800 2 * (
v.x *
v.y +
v.z *
r),
801 2 * (
v.z *
v.x -
v.y *
r),
803 2 * (
v.x *
v.y -
v.z *
r),
804 1 - 2 * (
v.z *
v.z +
v.x *
v.x),
805 2 * (
v.y *
v.z +
v.x *
r),
807 2 * (
v.z *
v.x +
v.y *
r),
808 2 * (
v.y *
v.z -
v.x *
r),
809 1 - 2 * (
v.y *
v.y +
v.x *
v.x));
817 2 * (
v.x *
v.y +
v.z *
r),
818 2 * (
v.z *
v.x -
v.y *
r),
820 2 * (
v.x *
v.y -
v.z *
r),
821 1 - 2 * (
v.z *
v.z +
v.x *
v.x),
822 2 * (
v.y *
v.z +
v.x *
r),
824 2 * (
v.z *
v.x +
v.y *
r),
825 2 * (
v.y *
v.z -
v.x *
r),
826 1 - 2 * (
v.y *
v.y +
v.x *
v.x),
840 return M *
q.toMatrix33();
849 return q.toMatrix33() * M;
855 operator<< (std::ostream& o, const Quat<T>&
q)
857 return o <<
"(" <<
q.r <<
" " <<
q.v.x <<
" " <<
q.v.y <<
" " <<
q.v.z <<
")";
865 return Quat<T> (q1.r * q2.r - (q1.v ^ q2.v), q1.r * q2.v + q1.v * q2.r + q1.v % q2.v);
873 return q1 * q2.inverse();
907 return Quat<T> (q1.r + q2.r, q1.v + q2.v);
915 return Quat<T> (q1.r - q2.r, q1.v - q2.v);
942 return v +
T (2) * (
q.r * a +
b);
945 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
946 # pragma warning(pop)
949 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
951 #endif // INCLUDED_IMATHQUAT_H
IMATH_HOSTDEVICE constexpr T euclideanInnerProduct(const Quat< T > &q) const IMATH_NOEXCEPT
Return the Euclidean inner product.
SYS_API double cos(double x)
SYS_API double atan2(double y, double x)
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Quat< T > & operator=(const Quat< T > &q) IMATH_NOEXCEPT
Assignment.
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > & normalize() IMATH_NOEXCEPT
SIM_API const UT_StringHolder angle
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Quat< T > & operator+=(const Quat< T > &q) IMATH_NOEXCEPT
Quaternion addition.
IMATH_HOSTDEVICE constexpr Quat< T > operator-(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion subtraction.
vfloat4 sqrt(const vfloat4 &a)
GLboolean GLboolean GLboolean GLboolean a
IMATH_HOSTDEVICE Vec3< T > normalized() const IMATH_NOEXCEPT
Return a normalized vector. Does not modify *this.
GLuint GLsizei GLsizei * length
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > squad(const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &qa, const Quat< T > &qb, T t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE static constexpr Quat< T > identity() IMATH_NOEXCEPT
The identity quaternion.
Vec3< T > v
The imaginary vector.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > spline(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE Quat< T > exp() const IMATH_NOEXCEPT
Return the exponent of the quaterion.
**But if you need a result
IMATH_HOSTDEVICE constexpr T operator^(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
4D dot product
IMATH_HOSTDEVICE constexpr T angle() const IMATH_NOEXCEPT
Return the angle of the axis/angle representation.
IMATH_HOSTDEVICE constexpr bool operator==(const Quat< S > &q) const IMATH_NOEXCEPT
Equality.
GLdouble GLdouble GLdouble q
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T angle4D(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
IMATH_HOSTDEVICE Quat< T > log() const IMATH_NOEXCEPT
Return the logarithm of the quaterion.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Quat< T > & operator/=(const Quat< T > &q) IMATH_NOEXCEPT
Quaterion division, using the inverse()
IMATH_HOSTDEVICE constexpr bool operator!=(const Quat< S > &q) const IMATH_NOEXCEPT
Inequality.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Quat< T > & operator-=(const Quat< T > &q) IMATH_NOEXCEPT
Quaternion subtraction.
IMATH_HOSTDEVICE constexpr T length() const IMATH_NOEXCEPT
Return the R4 length.
IMATH_HOSTDEVICE constexpr Quat() IMATH_NOEXCEPT
Default constructor is the identity quat.
IMATH_HOSTDEVICE constexpr Matrix44< T > toMatrix44() const IMATH_NOEXCEPT
Return a 4x4 rotation matrix.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > & setRotation(const Vec3< T > &fromDirection, const Vec3< T > &toDirection) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > & invert() IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T & operator[](int index) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > & setAxisAngle(const Vec3< T > &axis, T radians) IMATH_NOEXCEPT
SYS_API double acos(double x)
GLint GLenum GLboolean normalized
GLboolean GLboolean GLboolean b
IMATH_HOSTDEVICE constexpr Quat< T > operator+(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion addition.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > slerp(const Quat< T > &q1, const Quat< T > &q2, T t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr Quat< T > operator~(const Quat< T > &q) IMATH_NOEXCEPT
Compute the conjugate.
IMATH_HOSTDEVICE constexpr Matrix33< T > operator*(const Matrix33< T > &M, const Quat< T > &q) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > inverse() const IMATH_NOEXCEPT
Return 1/this, leaving this unchanged.
#define IMATH_EXPORT_TEMPLATE_TYPE
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Vec3< T > rotateVector(const Vec3< T > &original) const IMATH_NOEXCEPT
Rotate the given point by the quaterion.
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE T sinx_over_x(T x)
IMATH_HOSTDEVICE constexpr Vec3< T > axis() const IMATH_NOEXCEPT
Return the axis of the axis/angle representation.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Quat< T > & operator*=(const Quat< T > &q) IMATH_NOEXCEPT
Quaternion multiplication.
IMATH_HOSTDEVICE void intermediate(const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, Quat< T > &qa, Quat< T > &qb) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr Matrix33< T > toMatrix33() const IMATH_NOEXCEPT
Return a 3x3 rotation matrix.
OIIO_FORCEINLINE T log(const T &v)
IMATH_HOSTDEVICE constexpr Quat< T > operator/(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion division.
OIIO_FORCEINLINE OIIO_HOSTDEVICE T radians(T deg)
Convert degrees to radians.
SYS_API double sin(double x)
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > normalized() const IMATH_NOEXCEPT
Return a normalized quaternion, leaving this unmodified.
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > slerpShortestArc(const Quat< T > &q1, const Quat< T > &q2, T t) IMATH_NOEXCEPT