3#include <Core/Math/LinearAlgebra.hpp>
4#include <Core/RaCore.hpp>
26 inline DualQuaternion(
const Quaternion& q0,
const Quaternion& qe ) : m_q0( q0 ), m_qe( qe ) {}
38 inline const Quaternion&
getQ0()
const;
39 inline void setQ0(
const Quaternion& q0 );
40 inline const Quaternion& getQe()
const;
41 inline void setQe(
const Quaternion& qe );
66 inline Vector3
transform(
const Vector3& p )
const;
69 inline Vector3
rotate(
const Vector3& p )
const;
72 inline Vector3
translate(
const Vector3& p )
const;
88inline void DualQuaternion::setQ0(
const Quaternion& q0 ) {
92inline const Quaternion& DualQuaternion::getQe()
const {
96inline void DualQuaternion::setQe(
const Quaternion& qe ) {
104inline DualQuaternion DualQuaternion::operator*( Scalar scalar )
const {
109 *
this = *
this + other;
113inline DualQuaternion& DualQuaternion::operator*=( Scalar scalar ) {
114 *
this = *
this * scalar;
119 const Scalar norm = m_q0.norm();
120 CORE_ASSERT( norm != 0,
"Normalizing a null quaternion." );
127 "Dual quaternion not normalized" );
133 "Dual quaternion not normalized" );
134 return m_q0.toRotationMatrix() * p;
138 Vector3 v0 = m_q0.vec();
139 Vector3 ve = m_qe.vec();
140 return p + ( ( ve * m_q0.w() - v0 * m_qe.w() + v0.cross( ve ) ) * 2_ra );
150 "Dual quaternion not normalized" );
153 result.linear() = m_q0.toRotationMatrix();
154 result.translation() = ( 2_ra * m_q0 * m_qe.conjugate() ).vec();
159 m_q0 = Quaternion( t.rotation() );
160 Core::Vector4 trans = Core::Vector4::Zero();
161 trans.head<3>() = t.translation();
162 m_qe = 0.5f * Quaternion( trans ) * m_q0;
void setFromTransform(const Transform &t)
Other methods.
Vector3 transform(const Vector3 &p) const
DualQuaternion(const DualQuaternion &other)=default
Default copy constructor and assignment operator.
Transform getTransform() const
Return the corresponding rigid transform. Assume a unit dual quaternion.
DualQuaternion operator+(const DualQuaternion &other) const
Operators.
DualQuaternion()
Construct an uninitialized dual quaternion.
Vector3 translate(const Vector3 &p) const
Apply only the translational part of the dual quaternion to the given vector.
const Quaternion & getQ0() const
Getters and setters.
Vector3 rotate(const Vector3 &p) const
Apply only the rotational part of the dual quaternion to the given vector.
DualQuaternion(const Quaternion &q0, const Quaternion &qe)
Construct a dual-quaternion from two quaternions.
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type areApproxEqual(T x, T y, T espilonBoostFactor=T(10))
Compare two numbers such that |x-y| < espilon*epsilonBoostFactor.
DualQuaternion operator*(Scalar scalar, const DualQuaternion &dq)
Pre-multiplication of dual quaternion.
hepler function to manage enum as underlying types in VariableSet