Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
fmat::QuaternionT< R > Class Template ReferenceQuaternions can be more efficient and more stable for a series of rotations than a corresponding 3x3 matrix, also more compact storage. More...
Inheritance diagram for fmat::QuaternionT< R >:
Detailed Descriptiontemplate<class R = fmatReal>
|
Public Member Functions | |
QuaternionT () | |
Default constructor, initialize to identity (0 rotation). | |
QuaternionT (R w_, R x_, R y_, R z_) | |
Explicit construction from elements (careful, does not check normalization!). | |
template<typename T > | |
QuaternionT & | importFrom (const T &q) |
copies from another representation, assuming operator[] is supported and w is index 0 | |
template<typename T > | |
T | exportTo () const |
copies into another representation, assuming operator[] is supported and w is index 0 | |
template<typename T > | |
T & | exportTo (T &q) const |
copies into another representation, assuming operator[] is supported and w is index 0 | |
template<typename T > | |
void | exportTo (T &w_, T &x_, T &y_, T &z_) const |
unpacks into specified storage | |
template<typename T > | |
void | exportTo (T &x_, T &y_, T &z_) const |
unpacks into specified storage, skipping w which can be reconstitued from √(1-x^2-y^2-z^2), see fromAxis() | |
R | getW () const |
returns w | |
R | getX () const |
returns x | |
R | getY () const |
returns y | |
R | getZ () const |
returns z | |
bool | operator== (const QuaternionT< R > &other) const |
Matrix< 3, 3, R > | toMatrix () const |
returns a 3x3 rotation matrix representation | |
operator Matrix< 3, 3, R > () const | |
allows conversion/assignment to Matrix<3,3> | |
Column< 3, R > | axis () const |
return axis of rotation represented by quaternion q (i.e. the axis component of axis-angle representation) | |
R | angle () const |
Return angle of rotation (range ±π radians) about the quaternion's native axis (i.e. the angle component for axis-angle representation). | |
template<class T > | |
R | axisComponent (const T &v) const |
Return angle of rotation represented by the quaternion about an arbitrary axis (assumed to already be normalized). | |
fmat::Column< 3, R > | ypr () const |
Returns yaw-pitch-roll aka heading-elevation-bank conversion, where roll-pitch-yaw correspond to compounding rotations about the global x, y, and z axis respectively (in that order). | |
QuaternionT | inverse () const ATTR_must_check |
Negates just the quaternion axis. | |
template<typename Rb > | |
QuaternionT< typename fmat_internal::promotion_trait < R, Rb >::type > | operator* (const QuaternionT< Rb > &q) const |
multiply quaternions | |
QuaternionT | operator*= (const QuaternionT &q) |
multiply quaternions | |
template<template< size_t H, size_t W, typename Rt > class T, size_t W> | |
Matrix< 3, W, R > | operator* (const T< 3, W, R > &m) const |
multiply 3-row matrix by quaternion | |
TransformT< R > | operator* (const TransformT< R > &m) const |
multiply Transform by quaternion | |
Column< 3, R > | operator* (const Column< 3, R > v) const |
multiply 3-element vector by quaternion | |
R | sumSq () const |
returns sum of squares of components; should be "close" to 1, otherwise call normalize() | |
R | norm () const |
returns magnitude of quaternion; should be "close" to 1, otherwise call normalize() | |
R | normalize () |
Re-normalize the quaternion magnitude to 1 (or 0 if norm is already invalid) and positive W, returns the previous magnitude. | |
Static Public Member Functions | |
template<typename T > | |
static QuaternionT | from (const T &q) |
copies from another representation, assuming operator[] is supported and w is index 0 | |
static const QuaternionT & | identity () |
returns a no-op quaternion (0 rotation), the same as the default constructor, but can re-use this instance instead of creating new ones all the time | |
static QuaternionT< R > | aboutX (R rad) |
generate quaternion representing rotation of rad radians about X axis | |
static QuaternionT< R > | aboutY (R rad) |
generate quaternion representing rotation of rad radians about Y axis | |
static QuaternionT< R > | aboutZ (R rad) |
generate quaternion representing rotation of rad radians about Z axis | |
template<class T > | |
static QuaternionT | fromAxisAngle (const T &axis, R angle) |
Generate quaternion from axis-angle representation (angle in radians, axis will be re-normalized if non-zero angle). | |
template<class T > | |
static QuaternionT | fromAxis (const T &axis) |
Generate quaternion from just the axis component of another quaternion (i.e. axis magnitude should be less than 1; 0 magnitude means no rotation). | |
template<class T > | |
static QuaternionT | fromMatrix (const T &rot) |
Generate quaternion from rotation matrix, this assumes the rotation matrix is well-formed. | |
Static Public Attributes | |
static const QuaternionT | IDENTITY |
identity instance | |
Protected Member Functions | |
QuaternionT (const fmat_internal::NoInit &) | |
no-op constructor for functions which fill in results with additional computation | |
Protected Attributes | |
R | w |
R | x |
R | y |
R | z |
Friends | |
std::ostream & | operator<< (std::ostream &os, const QuaternionT< R > &q) |
fmat::QuaternionT< R >::QuaternionT | ( | ) |
Default constructor, initialize to identity (0 rotation).
Definition at line 74 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::from(), fmat::QuaternionT< R >::fromAxis(), fmat::QuaternionT< R >::fromAxisAngle(), and fmat::QuaternionT< R >::inverse().
fmat::QuaternionT< R >::QuaternionT | ( | R | w_, | |
R | x_, | |||
R | y_, | |||
R | z_ | |||
) |
Explicit construction from elements (careful, does not check normalization!).
Definition at line 77 of file fmatSpatial.h.
fmat::QuaternionT< R >::QuaternionT | ( | const fmat_internal::NoInit & | ) | [protected] |
no-op constructor for functions which fill in results with additional computation
Definition at line 397 of file fmatSpatial.h.
static QuaternionT<R> fmat::QuaternionT< R >::aboutX | ( | R | rad | ) | [static] |
generate quaternion representing rotation of rad radians about X axis
Definition at line 104 of file fmatSpatial.h.
Referenced by Grasper::checkGoalCandidate(), Grasper::PlanArmApproach::doStart(), IKCalliope::isSideGrasp(), and IKCalliope::solve().
static QuaternionT<R> fmat::QuaternionT< R >::aboutY | ( | R | rad | ) | [static] |
generate quaternion representing rotation of rad radians about Y axis
Definition at line 106 of file fmatSpatial.h.
Referenced by ArmController::ArmController(), and IKCalliope::solve().
static QuaternionT<R> fmat::QuaternionT< R >::aboutZ | ( | R | rad | ) | [static] |
generate quaternion representing rotation of rad radians about Z axis
Definition at line 108 of file fmatSpatial.h.
Referenced by CBracketGrasperPredicate< N >::admissible(), and IKCalliope::IKCalliope().
R fmat::QuaternionT< R >::angle | ( | ) | const |
Return angle of rotation (range ±π radians) about the quaternion's native axis (i.e. the angle component for axis-angle representation).
Handles some slight denormalization gracefully.
Definition at line 227 of file fmatSpatial.h.
Referenced by IKGradientSolver::step().
Column<3,R> fmat::QuaternionT< R >::axis | ( | ) | const |
return axis of rotation represented by quaternion q (i.e. the axis component of axis-angle representation)
Definition at line 217 of file fmatSpatial.h.
Referenced by IKGradientSolver::step().
R fmat::QuaternionT< R >::axisComponent | ( | const T & | v | ) | const |
Return angle of rotation represented by the quaternion about an arbitrary axis (assumed to already be normalized).
Definition at line 241 of file fmatSpatial.h.
void fmat::QuaternionT< R >::exportTo | ( | T & | x_, | |
T & | y_, | |||
T & | z_ | |||
) | const |
unpacks into specified storage, skipping w which can be reconstitued from √(1-x^2-y^2-z^2), see fromAxis()
Definition at line 90 of file fmatSpatial.h.
void fmat::QuaternionT< R >::exportTo | ( | T & | w_, | |
T & | x_, | |||
T & | y_, | |||
T & | z_ | |||
) | const |
unpacks into specified storage
Definition at line 88 of file fmatSpatial.h.
T& fmat::QuaternionT< R >::exportTo | ( | T & | q | ) | const |
copies into another representation, assuming operator[] is supported and w is index 0
Definition at line 86 of file fmatSpatial.h.
copies into another representation, assuming operator[] is supported and w is index 0
Definition at line 84 of file fmatSpatial.h.
static QuaternionT fmat::QuaternionT< R >::from | ( | const T & | q | ) | [static] |
copies from another representation, assuming operator[] is supported and w is index 0
Definition at line 80 of file fmatSpatial.h.
static QuaternionT fmat::QuaternionT< R >::fromAxis | ( | const T & | axis | ) | [static] |
Generate quaternion from just the axis component of another quaternion (i.e. axis magnitude should be less than 1; 0 magnitude means no rotation).
This method requires only basic operations on the input type, so you can pass a raw array or plist::Point...
Definition at line 126 of file fmatSpatial.h.
Referenced by LinkComponent::computeOwnAABB(), LinkComponent::getCollisionModelTransform(), LinkComponent::getModelTransform(), LinkComponent::getObstacle(), and IKCalliope::solve().
static QuaternionT fmat::QuaternionT< R >::fromAxisAngle | ( | const T & | axis, | |
R | angle | |||
) | [static] |
Generate quaternion from axis-angle representation (angle in radians, axis will be re-normalized if non-zero angle).
If axis is 0 length, initializes to identity (0 rotation)
Definition at line 113 of file fmatSpatial.h.
Referenced by IKSolver::Parallel::computeErrorGradient(), and GaitedFootsteps::expand().
static QuaternionT fmat::QuaternionT< R >::fromMatrix | ( | const T & | rot | ) | [static] |
Generate quaternion from rotation matrix, this assumes the rotation matrix is well-formed.
This implementation is based on cross pollination between "Angel"'s code on this page: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm and the Ogre3D Quaternion implementation, which itself references: Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes article "Quaternion Calculus and Fast Animation".
Definition at line 151 of file fmatSpatial.h.
Referenced by Grasper::computeGoalStates(), KinematicJoint::getQuaternion(), IKCalliope::IKCalliope(), and ShapeSpacePlanner3DR< N >::plotPath().
R fmat::QuaternionT< R >::getW | ( | ) | const |
returns w
Definition at line 92 of file fmatSpatial.h.
R fmat::QuaternionT< R >::getX | ( | ) | const |
R fmat::QuaternionT< R >::getY | ( | ) | const |
R fmat::QuaternionT< R >::getZ | ( | ) | const |
static const QuaternionT& fmat::QuaternionT< R >::identity | ( | ) | [static] |
returns a no-op quaternion (0 rotation), the same as the default constructor, but can re-use this instance instead of creating new ones all the time
Definition at line 100 of file fmatSpatial.h.
Referenced by KinematicJoint::getQuaternion().
QuaternionT& fmat::QuaternionT< R >::importFrom | ( | const T & | q | ) |
copies from another representation, assuming operator[] is supported and w is index 0
Definition at line 82 of file fmatSpatial.h.
QuaternionT fmat::QuaternionT< R >::inverse | ( | ) | const |
Negates just the quaternion axis.
Definition at line 279 of file fmatSpatial.h.
Referenced by fmat::crossProduct(), KinematicJoint::getQuaternion(), and fmat::invert().
R fmat::QuaternionT< R >::norm | ( | ) | const |
returns magnitude of quaternion; should be "close" to 1, otherwise call normalize()
Definition at line 364 of file fmatSpatial.h.
R fmat::QuaternionT< R >::normalize | ( | ) |
Re-normalize the quaternion magnitude to 1 (or 0 if norm is already invalid) and positive W, returns the previous magnitude.
Definition at line 367 of file fmatSpatial.h.
Referenced by IKGradientSolver::step().
fmat::QuaternionT< R >::operator Matrix< 3, 3, R > | ( | ) | const |
allows conversion/assignment to Matrix<3,3>
Definition at line 214 of file fmatSpatial.h.
Column<3,R> fmat::QuaternionT< R >::operator* | ( | const Column< 3, R > | v | ) | const |
multiply 3-element vector by quaternion
Definition at line 343 of file fmatSpatial.h.
TransformT<R> fmat::QuaternionT< R >::operator* | ( | const TransformT< R > & | m | ) | const |
multiply Transform by quaternion
Definition at line 323 of file fmatSpatial.h.
Matrix<3,W,R> fmat::QuaternionT< R >::operator* | ( | const T< 3, W, R > & | m | ) | const |
multiply 3-row matrix by quaternion
Definition at line 303 of file fmatSpatial.h.
QuaternionT<typename fmat_internal::promotion_trait<R,Rb>::type> fmat::QuaternionT< R >::operator* | ( | const QuaternionT< Rb > & | q | ) | const |
multiply quaternions
Definition at line 289 of file fmatSpatial.h.
QuaternionT fmat::QuaternionT< R >::operator*= | ( | const QuaternionT< R > & | q | ) |
multiply quaternions
Definition at line 299 of file fmatSpatial.h.
bool fmat::QuaternionT< R >::operator== | ( | const QuaternionT< R > & | other | ) | const |
Definition at line 97 of file fmatSpatial.h.
R fmat::QuaternionT< R >::sumSq | ( | ) | const |
returns sum of squares of components; should be "close" to 1, otherwise call normalize()
Definition at line 361 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::normalize().
Matrix<3,3,R> fmat::QuaternionT< R >::toMatrix | ( | ) | const |
returns a 3x3 rotation matrix representation
implemented by simplified version of operator*(*this, Matrix<3,3>::identity())
Definition at line 190 of file fmatSpatial.h.
Referenced by LinkComponent::getObstacle(), fmat::QuaternionT< R >::operator Matrix< 3, 3, R >(), and IKCalliope::solve().
fmat::Column<3,R> fmat::QuaternionT< R >::ypr | ( | ) | const |
Returns yaw-pitch-roll aka heading-elevation-bank conversion, where roll-pitch-yaw correspond to compounding rotations about the global x, y, and z axis respectively (in that order).
From the "driver's seat" positive heading is turning to the left (z is up, using right hand rule, not compass heading), positive pitch is looking down, and positive roll is spinning clockwise. Within this frame-oriented view, we apply rotation axes in the 'reverse' order: first z, then y, then x.
You can reconstruct a Quaternion from these values by: q · v = aboutZ(yaw) * aboutY(pitch) * aboutX(roll) · v Note we right-multiply v to apply the rotation, so x is applied to an incoming vector first, then y, then z.
With thanks to http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/ (note that page uses different axis mapping however!)
Definition at line 261 of file fmatSpatial.h.
Referenced by MoCapLogger::gotMoCapGUI(), IKCalliope::solve(), and fmat::ypr().
std::ostream& operator<< | ( | std::ostream & | os, | |
const QuaternionT< R > & | q | |||
) | [friend] |
Definition at line 391 of file fmatSpatial.h.
const QuaternionT< T > fmat::QuaternionT< T >::IDENTITY [static] |
identity instance
Definition at line 101 of file fmatSpatial.h.
Referenced by ArmController::ArmController(), fmat::TransformT< R >::identity(), and fmat::QuaternionT< R >::identity().
R fmat::QuaternionT< R >::w [protected] |
Definition at line 394 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::angle(), fmat::QuaternionT< R >::axisComponent(), fmat::QuaternionT< R >::exportTo(), fmat::QuaternionT< R >::fromMatrix(), fmat::QuaternionT< R >::getW(), fmat::QuaternionT< R >::importFrom(), fmat::QuaternionT< R >::inverse(), fmat::QuaternionT< R >::norm(), fmat::QuaternionT< R >::normalize(), fmat::QuaternionT< R >::operator*(), fmat::QuaternionT< R >::operator==(), fmat::QuaternionT< R >::sumSq(), fmat::QuaternionT< R >::toMatrix(), and fmat::QuaternionT< R >::ypr().
R fmat::QuaternionT< R >::x [protected] |
Definition at line 394 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::exportTo(), fmat::QuaternionT< R >::fromMatrix(), fmat::QuaternionT< R >::getX(), fmat::QuaternionT< R >::importFrom(), fmat::QuaternionT< R >::operator*(), fmat::QuaternionT< R >::operator==(), and fmat::QuaternionT< R >::toMatrix().
R fmat::QuaternionT< R >::y [protected] |
Definition at line 394 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::exportTo(), fmat::QuaternionT< R >::fromMatrix(), fmat::QuaternionT< R >::getY(), fmat::QuaternionT< R >::importFrom(), fmat::QuaternionT< R >::operator*(), fmat::QuaternionT< R >::operator==(), and fmat::QuaternionT< R >::toMatrix().
R fmat::QuaternionT< R >::z [protected] |
Definition at line 394 of file fmatSpatial.h.
Referenced by fmat::QuaternionT< R >::exportTo(), fmat::QuaternionT< R >::fromMatrix(), fmat::QuaternionT< R >::getZ(), fmat::QuaternionT< R >::importFrom(), fmat::QuaternionT< R >::operator*(), fmat::QuaternionT< R >::operator==(), and fmat::QuaternionT< R >::toMatrix().
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:23 2016 by Doxygen 1.6.3 |