36 #ifndef vtkQuaternion_h
37 #define vtkQuaternion_h
71 vtkQuaternion(
const T& w,
const T& x,
const T& y,
const T& z);
171 void Set(
const T& w,
const T& x,
const T& y,
const T& z);
173 void Get(T quat[4])
const;
180 void SetW(
const T& w);
181 const T&
GetW()
const;
188 void SetX(
const T& x);
189 const T&
GetX()
const;
196 void SetY(
const T& y);
197 const T&
GetY()
const;
204 void SetZ(
const T& z);
205 const T&
GetZ()
const;
221 template <
typename CastTo>
301 #define vtkQuaternionIdentity(quaternionType, type) \
302 quaternionType Identity() const \
304 return quaternionType(vtkQuaternion<type>::Identity().GetData()); \
306 #define vtkQuaternionNormalized(quaternionType, type) \
307 quaternionType Normalized() const \
309 return quaternionType(vtkQuaternion<type>::Normalized().GetData()); \
311 #define vtkQuaternionConjugated(quaternionType, type) \
312 quaternionType Conjugated() const \
314 return quaternionType(vtkQuaternion<type>::Conjugated().GetData()); \
316 #define vtkQuaternionInverse(quaternionType, type) \
317 quaternionType Inverse() const \
319 return quaternionType(vtkQuaternion<type>::Inverse().GetData()); \
321 #define vtkQuaternionUnitLog(quaternionType, type) \
322 quaternionType UnitLog() const \
324 return quaternionType(vtkQuaternion<type>::UnitLog().GetData()); \
326 #define vtkQuaternionUnitExp(quaternionType, type) \
327 quaternionType UnitExp() const \
329 return quaternionType(vtkQuaternion<type>::UnitExp().GetData()); \
331 #define vtkQuaternionNormalizedWithAngleInDegrees(quaternionType, type) \
332 quaternionType NormalizedWithAngleInDegrees() const \
334 return quaternionType(vtkQuaternion<type>::NormalizedWithAngleInDegrees().GetData()); \
336 #define vtkQuaternionSlerp(quaternionType, type) \
337 quaternionType Slerp(type t, const quaternionType& q) const \
339 return quaternionType(vtkQuaternion<type>::Slerp(t, q).GetData()); \
341 #define vtkQuaternionInnerPoint(quaternionType, type) \
342 quaternionType InnerPoint(const quaternionType& q1, const quaternionType& q2) const \
344 return quaternionType(vtkQuaternion<type>::InnerPoint(q1, q2).GetData()); \
346 #define vtkQuaternionOperatorPlus(quaternionType, type) \
347 inline quaternionType operator+(const quaternionType& q) const \
349 return quaternionType( \
350 (static_cast<vtkQuaternion<type>>(*this) + static_cast<vtkQuaternion<type>>(q)).GetData()); \
352 #define vtkQuaternionOperatorMinus(quaternionType, type) \
353 inline quaternionType operator-(const quaternionType& q) const \
355 return quaternionType( \
356 (static_cast<vtkQuaternion<type>>(*this) - static_cast<vtkQuaternion<type>>(q)).GetData()); \
358 #define vtkQuaternionOperatorMultiply(quaternionType, type) \
359 inline quaternionType operator*(const quaternionType& q) const \
361 return quaternionType( \
362 (static_cast<vtkQuaternion<type>>(*this) * static_cast<vtkQuaternion<type>>(q)).GetData()); \
364 #define vtkQuaternionOperatorMultiplyScalar(quaternionType, type) \
365 inline quaternionType operator*(const type& scalar) const \
367 return quaternionType((static_cast<vtkQuaternion<type>>(*this) * scalar).GetData()); \
369 #define vtkQuaternionOperatorDivide(quaternionType, type) \
370 inline quaternionType operator/(const quaternionType& q) const \
372 return quaternionType( \
373 (static_cast<vtkQuaternion<type>>(*this) / static_cast<vtkQuaternion<type>>(q)).GetData()); \
375 #define vtkQuaternionOperatorDivideScalar(quaternionType, type) \
376 inline quaternionType operator/(const type& scalar) const \
378 return quaternionType((static_cast<vtkQuaternion<type>>(*this) / scalar).GetData()); \
381 #define vtkQuaternionOperatorMacro(quaternionType, type) \
382 vtkQuaternionIdentity(quaternionType, type); \
383 vtkQuaternionNormalized(quaternionType, type); \
384 vtkQuaternionConjugated(quaternionType, type); \
385 vtkQuaternionInverse(quaternionType, type); \
386 vtkQuaternionUnitLog(quaternionType, type); \
387 vtkQuaternionUnitExp(quaternionType, type); \
388 vtkQuaternionNormalizedWithAngleInDegrees(quaternionType, type); \
389 vtkQuaternionSlerp(quaternionType, type); \
390 vtkQuaternionInnerPoint(quaternionType, type); \
391 vtkQuaternionOperatorPlus(quaternionType, type); \
392 vtkQuaternionOperatorMinus(quaternionType, type); \
393 vtkQuaternionOperatorMultiply(quaternionType, type); \
394 vtkQuaternionOperatorMultiplyScalar(quaternionType, type); \
395 vtkQuaternionOperatorDivide(quaternionType, type); \
396 vtkQuaternionOperatorDivideScalar(quaternionType, type)
448 #include "vtkQuaternion.txx"
450 #endif // vtkQuaternion_h
vtkQuaternion< T > UnitLog() const
Return the unit log version of this quaternion.
vtkQuaternionf(float scalar)
void SetZ(const T &z)
Set/Get the y component of the quaternion, i.e.
void ToMatrix3x3(T A[3][3]) const
Convert a quaternion to a 3x3 rotation matrix.
vtkQuaternion< T > operator/(const vtkQuaternion< T > &q) const
Performs division of quaternions of the same type.
const T & GetZ() const
Set/Get the y component of the quaternion, i.e.
vtkQuaterniond(double w, double x, double y, double z)
T SquaredNorm() const
Get the squared norm of the quaternion.
void NormalizeWithAngleInDegrees()
Normalize a quaternion in place and transform it to so its angle is in degrees and its axis normalize...
void Invert()
Invert the quaternion in place.
void operator/=(const T &scalar)
Performs in place division of the quaternions by a scalar value.
vtkQuaternion< T > operator-(const vtkQuaternion< T > &q) const
Performs subtraction of quaternions of the same basic type.
vtkQuaternion< T > Normalized() const
Return the normalized form of this quaternion.
vtkQuaternion< T > NormalizedWithAngleInDegrees() const
Returns a quaternion normalized and transformed so its angle is in degrees and its axis normalized...
templated base type for storage of quaternions.
vtkQuaternion< T > UnitExp() const
Return the unit exponential version of this quaternion.
void SetRotationAngleAndAxis(T angle, T axis[3])
Set/Get the angle (in radians) and the axis corresponding to the axis-angle rotation of this quaterni...
T GetRotationAngleAndAxis(T axis[3]) const
Set/Get the angle (in radians) and the axis corresponding to the axis-angle rotation of this quaterni...
vtkQuaterniond(double scalar)
void Get(T quat[4]) const
Set/Get the w, x, y and z components of the quaternion.
vtkQuaternionOperatorMacro(vtkQuaterniond, double)
const T & GetY() const
Set/Get the y component of the quaternion, i.e.
void SetY(const T &y)
Set/Get the y component of the quaternion, i.e.
vtkQuaternion< T > Slerp(T t, const vtkQuaternion< T > &q) const
Interpolate quaternions using spherical linear interpolation between this quaternion and q1 to produc...
void Conjugate()
Conjugate the quaternion in place.
vtkQuaternion(const T *init)
Initialize the quaternion's elements with the elements of the supplied array.
vtkQuaternionf(const float *init)
templated base type for containers of constant size.
void FromMatrix3x3(const T A[3][3])
Convert a 3x3 matrix into a quaternion.
vtkQuaternion< CastTo > Cast() const
Cast the quaternion to the specified type and return the result.
const T & GetW() const
Set/Get the w component of the quaternion, i.e.
const T & GetX() const
Set/Get the x component of the quaternion, i.e.
vtkQuaternion< T > InnerPoint(const vtkQuaternion< T > &q1, const vtkQuaternion< T > &q2) const
Interpolates between quaternions, using spherical quadrangle interpolation.
vtkQuaternionf(float w, float x, float y, float z)
void ToUnitExp()
Convert this quaternion to a unit exponential quaternion.
void SetW(const T &w)
Set/Get the w component of the quaternion, i.e.
vtkQuaternion< T > operator+(const vtkQuaternion< T > &q) const
Performs addition of quaternion of the same basic type.
vtkQuaternion< T > Inverse() const
Return the inverted form of this quaternion.
vtkQuaternionOperatorMacro(vtkQuaternionf, float)
vtkQuaterniond(const double *init)
T Normalize()
Normalize the quaternion in place.
vtkQuaternion(const T &scalar)
Initialize all of the quaternion's elements with the supplied scalar.
void ToIdentity()
Set the quaternion to identity in place.
void Set(const T &w, const T &x, const T &y, const T &z)
Set/Get the w, x, y and z components of the quaternion.
void ToUnitLog()
Convert this quaternion to a unit log quaternion.
T Norm() const
Get the norm of the quaternion, i.e.
void operator*=(const T &scalar) const
Performs in place multiplication of the quaternions by a scalar value.
void SetX(const T &x)
Set/Get the x component of the quaternion, i.e.
vtkQuaternion< T > operator*(const vtkQuaternion< T > &q) const
Performs multiplication of quaternion of the same basic type.
static vtkQuaternion< T > Identity()
Return the identity quaternion.
vtkQuaternion()
Default constructor.
vtkQuaternion< T > Conjugated() const
Return the conjugate form of this quaternion.