33 #ifndef vtkQuaternion_h
34 #define vtkQuaternion_h
61 vtkQuaternion(
const T& w,
const T& x,
const T& y,
const T& z);
161 void Set(
const T& w,
const T& x,
const T& y,
const T& z);
163 void Get(T quat[4])
const;
170 void SetW(
const T& w);
171 const T&
GetW()
const;
178 void SetX(
const T& x);
179 const T&
GetX()
const;
186 void SetY(
const T& y);
187 const T&
GetY()
const;
194 void SetZ(
const T& z);
195 const T&
GetZ()
const;
206 const T& angle,
const T& x,
const T& y,
const T& z);
292 #define vtkQuaternionIdentity(quaternionType, type) \
293 quaternionType Identity() const \
295 return quaternionType(vtkQuaternion<type>::Identity().GetData()); \
297 #define vtkQuaternionNormalized(quaternionType, type) \
298 quaternionType Normalized() const \
300 return quaternionType(vtkQuaternion<type>::Normalized().GetData()); \
302 #define vtkQuaternionConjugated(quaternionType, type) \
303 quaternionType Conjugated() const \
305 return quaternionType(vtkQuaternion<type>::Conjugated().GetData()); \
307 #define vtkQuaternionInverse(quaternionType, type) \
308 quaternionType Inverse() const \
310 return quaternionType(vtkQuaternion<type>::Inverse().GetData()); \
312 #define vtkQuaternionUnitLog(quaternionType, type) \
313 quaternionType UnitLog() const \
315 return quaternionType( \
316 vtkQuaternion<type>::UnitLog().GetData()); \
318 #define vtkQuaternionUnitExp(quaternionType, type) \
319 quaternionType UnitExp() const \
321 return quaternionType( \
322 vtkQuaternion<type>::UnitExp().GetData()); \
324 #define vtkQuaternionNormalizedWithAngleInDegrees(quaternionType, type) \
325 quaternionType NormalizedWithAngleInDegrees() const \
327 return quaternionType( \
328 vtkQuaternion<type>::NormalizedWithAngleInDegrees().GetData()); \
330 #define vtkQuaternionSlerp(quaternionType, type) \
331 quaternionType Slerp(type t, const quaternionType& q) const \
333 return quaternionType( \
334 vtkQuaternion<type>::Slerp(t, q).GetData()); \
336 #define vtkQuaternionInnerPoint(quaternionType, type) \
337 quaternionType InnerPoint(const quaternionType& q1, \
338 const quaternionType& q2) const \
340 return quaternionType( \
341 vtkQuaternion<type>::InnerPoint(q1, q2).GetData()); \
343 #define vtkQuaternionOperatorPlus(quaternionType, type) \
344 inline quaternionType operator+(const quaternionType& q) const \
346 return quaternionType( ( \
347 static_cast< vtkQuaternion<type> > (*this) + \
348 static_cast< vtkQuaternion<type> > (q)).GetData()); \
350 #define vtkQuaternionOperatorMinus(quaternionType, type) \
351 inline quaternionType operator-(const quaternionType& q) const \
353 return quaternionType( ( \
354 static_cast< vtkQuaternion<type> > (*this) - \
355 static_cast< vtkQuaternion<type> > (q)).GetData()); \
357 #define vtkQuaternionOperatorMultiply(quaternionType, type) \
358 inline quaternionType operator*(const quaternionType& q) const \
360 return quaternionType( ( \
361 static_cast< vtkQuaternion<type> > (*this) * \
362 static_cast< vtkQuaternion<type> > (q)).GetData()); \
364 #define vtkQuaternionOperatorMultiplyScalar(quaternionType, type) \
365 inline quaternionType operator*(const type& scalar) const \
367 return quaternionType( ( \
368 static_cast< vtkQuaternion<type> > (*this) * \
369 scalar).GetData()); \
371 #define vtkQuaternionOperatorDivide(quaternionType, type) \
372 inline quaternionType operator/(const quaternionType& q) const \
374 return quaternionType( ( \
375 static_cast< vtkQuaternion<type> > (*this) / \
376 static_cast< vtkQuaternion<type> > (q)).GetData()); \
378 #define vtkQuaternionOperatorDivideScalar(quaternionType, type) \
379 inline quaternionType operator/(const type& scalar) const \
381 return quaternionType( ( \
382 static_cast< vtkQuaternion<type> > (*this) / \
383 scalar).GetData()); \
386 #define vtkQuaternionOperatorMacro(quaternionType, type) \
387 vtkQuaternionIdentity(quaternionType, type) \
388 vtkQuaternionNormalized(quaternionType, type) \
389 vtkQuaternionConjugated(quaternionType, type) \
390 vtkQuaternionInverse(quaternionType, type) \
391 vtkQuaternionUnitLog(quaternionType, type) \
392 vtkQuaternionUnitExp(quaternionType, type) \
393 vtkQuaternionNormalizedWithAngleInDegrees(quaternionType, type) \
394 vtkQuaternionSlerp(quaternionType, type) \
395 vtkQuaternionInnerPoint(quaternionType, type) \
396 vtkQuaternionOperatorPlus(quaternionType, type) \
397 vtkQuaternionOperatorMinus(quaternionType, type) \
398 vtkQuaternionOperatorMultiply(quaternionType, type) \
399 vtkQuaternionOperatorMultiplyScalar(quaternionType, type) \
400 vtkQuaternionOperatorDivide(quaternionType, type) \
401 vtkQuaternionOperatorDivideScalar(quaternionType, type)
437 #include "vtkQuaternion.txx"
439 #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)
Initalize 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.
#define vtkQuaternionOperatorMacro(quaternionType, type)
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.