14 #ifndef __UT_DualQuaternion_h__
15 #define __UT_DualQuaternion_h__
54 T dual_qx,
T dual_qy,
T dual_qz,
T dual_qw);
138 friend std::ostream &
139 operator<<(std::ostream &os, const UT_DualQuaternionT<T> &dq)
193 template <
typename T>
202 template <
typename T>
205 T real_qx, T real_qy, T real_qz, T real_qw,
206 T dual_qx, T dual_qy, T dual_qz, T dual_qw)
207 : myReal(real_qx, real_qy, real_qz, real_qw)
208 , myDual(dual_qx, dual_qy, dual_qz, dual_qw)
212 template <
typename T>
218 updateFromRotTransPair(r, t);
221 template <
typename T>
225 updateFromXform(xform);
228 template <
typename T>
234 myReal.updateFromRotationMatrix(rotXform);
239 updateFromRotTransPair(myReal, translate);
242 template <
typename T>
246 myReal.updateFromRotationMatrix(xform);
247 updateFromRotTransPair(myReal, 0.0
f, 0.0
f, 0.0
f);
250 template <
typename T>
255 T w = -0.5f * ( tx*r.
x() + ty*r.
y() + tz*r.
z() );
256 T x = 0.5f * ( r.
w()*tx + ty*r.
z() - r.
y()*tz );
257 T y = 0.5f * ( r.
w()*ty + tz*r.
x() - r.
z()*tx );
258 T z = 0.5f * ( r.
w()*tz + tx*r.
y() - r.
x()*ty );
261 myDual.assign(x, y, z, w);
271 template <
typename T>
286 t = (dual_vec*myReal.w() - real_vec*myDual.w() + cross_vec) *
T(2.0);
288 dst = myReal.rotate(vec) +
t;
291 template <
typename T>
298 dst = rot_quat.
rotate(vec);
301 template <
typename T>
306 myReal.getRotationMatrix(rotMat);
321 template <
typename T>
326 updateFromRotTransPair(r, t.
x(), t.
y(), t.
z());
329 template <
typename T>
334 return myReal.normal();
337 template <
typename T>
341 return SYSsqrt(length2());
344 template <
typename T>
356 T norm = myReal.normal();
360 norm = SYSsqrt(norm);
366 template <
typename T>
374 template <
typename T>
381 myDual = (myReal * myDual * myReal) *
T(-1.0);
384 template <
typename T>
391 myDual = (myReal * myDual * myReal) *
T(-1.0);
394 template <
typename T>
399 myDual.assign(0, 0, 0, 0);
407 template <
typename T>
416 template <
typename T>
425 template <
typename T>
434 template <
typename T>
438 myDual = myDual - dq.
getDual();
439 myReal = myReal - dq.
getReal();
443 template <
typename T>
447 return ( myDual == dq.
getDual() ) &&
451 template <
typename T>
465 template <
typename T>
469 return !(*
this == dq);
476 template <
typename T>
484 template <
typename T>
492 template <
typename T>
500 template <
typename T>
514 #endif // __UT_DualQuaternion_h__
UT_DualQuaternionT< fpreal32 > UT_DualQuaternion
Typedefs.
void extractRotate(UT_Matrix3T< S > &dst) const
const UT_QuaternionT< T > & getDual() const
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
T length2() const
Methods.
UT_DualQuaternionT< T > & operator+=(const UT_DualQuaternionT< T > &dq)
Operator implementations.
SYS_FORCE_INLINE UT_DualQuaternionT< T > & operator=(const UT_DualQuaternionT &v)=default
Default assignment.
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Add corresponding elements of m0 and m1 and return the result.
void updateFromRotTransPair(const UT_QuaternionT< T > &r, const UT_Vector3T< T > &t)
GLdouble GLdouble GLdouble z
const UT_QuaternionT< T > & getTranslation() const
constexpr SYS_FORCE_INLINE T & z() noexcept
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
void rotate(const UT_Vector3T< T > &vec, UT_Vector3T< T > &dst) const
const T * realData() const
Getters.
UT_DualQuaternionT< T > & operator*=(T scalar)
Operators.
UT_DualQuaternionT< fpreal64 > UT_DualQuaternionD
UT_DualQuaternionT< fpreal > UT_DualQuaternionR
SYS_FORCE_INLINE UT_DualQuaternionT()=default
Trivial constructor. If called, it initializes to all zeroes.
bool operator==(const UT_DualQuaternionT< T > &dq) const
bool isEqual(const UT_DualQuaternionT< T > &quat, T tol=T(SYS_FTOLERANCE)) const
Like operator==() but using a tolerance.
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Subtract corresponding elements of m0 and m1 and return the result.
void identity()
Change dual quaternion into an 0 rotation and 0 translation components.
UT_API void outTo(std::ostream &os) const
const UT_QuaternionT< T > & getRotation() const
void invert()
Invert this dual quaternion. Does not exist if getReal() is zero.
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
void updateFromXform(const UT_Matrix4T< T > &xform)
Assign from UT_Matrix4.
void normalize()
Normalizes the dual quaternion to have length of 1.
void conjugate()
Changes dual quaternion into its conjugate.
UT_DualQuaternionT< fpreal32 > UT_DualQuaternionF
void setTranslates(const UT_Vector3T< S > &translates)
void transform(const UT_Vector3T< T > &vec, UT_Vector3T< T > &dst) const
Method implementations.
bool SYSequalZero(const UT_Vector3T< T > &v)
bool operator!=(const UT_DualQuaternionT< T > &dq) const
const UT_QuaternionT< T > & getReal() const
SYS_DECLARE_IS_POD(UT_DualQuaternionF)
UT_Matrix4T< T > convertToXform() const
GLubyte GLubyte GLubyte GLubyte w
UT_DualQuaternionT< T > & operator-=(const UT_DualQuaternionT< T > &dq)
const T * dualData() const
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
UT_Vector3T< T > rotate(const UT_Vector3T< T > &) const
constexpr SYS_FORCE_INLINE T & y() noexcept
bool SYSisEqual(const UT_Vector2T< T > &a, const UT_Vector2T< T > &b, S tol=SYS_FTOLERANCE)
Componentwise equality.
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
void getTranslates(UT_Vector3T< S > &translates) const
constexpr SYS_FORCE_INLINE T & x() noexcept