Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::ROOT_MATH_ARCH::Quaternion Class Reference

Rotation class with the (3D) rotation represented by a unit quaternion (u, i, j, k).

This is the optimal representation for multiplication of multiple rotations, and for computation of group-manifold-invariant distance between two rotations. See also ROOT::Math::AxisAngle, ROOT::Math::EulerAngles, and ROOT::Math::Rotation3D.

See also
Physics Vectors

Definition at line 52 of file Quaternion.h.

Public Types

typedef double Scalar
 
typedef DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTagXYZVector
 Rotation operation on a cartesian vector.
 

Public Member Functions

 Quaternion ()
 Default constructor (identity rotation)
 
template<class OtherRotation >
 Quaternion (const OtherRotation &r)
 Construct from another supported rotation type (see gv_detail::convert )
 
template<class IT >
 Quaternion (IT begin, IT end)
 Construct given a pair of pointers or iterators defining the beginning and end of an array of four Scalars.
 
 Quaternion (Scalar u, Scalar i, Scalar j, Scalar k)
 Construct from four Scalars representing the coefficients of u, i, j, k.
 
Scalar Distance (const Quaternion &q) const
 Distance between two rotations in Quaternion form Note: The rotation group is isomorphic to a 3-sphere with diametrically opposite points identified.
 
template<class IT >
void GetComponents (IT begin) const
 Get the components into data specified by an iterator begin.
 
template<class IT >
void GetComponents (IT begin, IT end) const
 Get the components into data specified by an iterator begin and another to the end of the desired data (4 past start).
 
void GetComponents (Scalar &u, Scalar &i, Scalar &j, Scalar &k) const
 Get the components into four Scalars.
 
Scalar I () const
 
Quaternion Inverse () const
 Return inverse of a rotation.
 
void Invert ()
 Invert a rotation in place.
 
Scalar J () const
 
Scalar K () const
 
bool operator!= (const Quaternion &rhs) const
 
template<class CoordSystem , class Tag >
DisplacementVector3D< CoordSystem, Tagoperator() (const DisplacementVector3D< CoordSystem, Tag > &v) const
 Rotation operation on a displacement vector in any coordinate system.
 
template<class ForeignVector >
ForeignVector operator() (const ForeignVector &v) const
 Rotation operation on an arbitrary vector v.
 
template<class CoordSystem >
LorentzVector< CoordSystem > operator() (const LorentzVector< CoordSystem > &v) const
 Rotation operation on a Lorentz vector in any 4D coordinate system.
 
template<class CoordSystem , class Tag >
PositionVector3D< CoordSystem, Tagoperator() (const PositionVector3D< CoordSystem, Tag > &p) const
 Rotation operation on a position vector in any coordinate system.
 
XYZVector operator() (const XYZVector &v) const
 
template<class AVector >
AVector operator* (const AVector &v) const
 Overload operator * for rotation on a vector.
 
Quaternion operator* (const AxisAngle &a) const
 
Quaternion operator* (const EulerAngles &e) const
 
Quaternion operator* (const Quaternion &q) const
 Multiply (combine) two rotations.
 
Quaternion operator* (const Rotation3D &r) const
 
Quaternion operator* (const RotationX &rx) const
 
Quaternion operator* (const RotationY &ry) const
 
Quaternion operator* (const RotationZ &rz) const
 
Quaternion operator* (const RotationZYX &r) const
 
template<class R >
Quaternionoperator*= (const R &r)
 Post-Multiply (on right) by another rotation : T = T*R.
 
template<class OtherRotation >
Quaternionoperator= (OtherRotation const &r)
 Assign from another supported rotation type (see gv_detail::convert )
 
bool operator== (const Quaternion &rhs) const
 Equality/inequality operators.
 
void Rectify ()
 Re-adjust components to eliminate small deviations from |Q| = 1 orthonormality.
 
template<class IT >
void SetComponents (IT begin, IT end)
 Set the four components given an iterator to the start of the desired data, and another to the end (4 past start).
 
void SetComponents (Scalar u, Scalar i, Scalar j, Scalar k)
 Set the components based on four Scalars.
 
Scalar U () const
 Access to the four quaternion components: U() is the coefficient of the identity Pauli matrix, I(), J() and K() are the coefficients of sigma_x, sigma_y, sigma_z.
 

Private Attributes

Scalar fI
 
Scalar fJ
 
Scalar fK
 
Scalar fU
 

#include <MathX/GenVectorX/Quaternion.h>

Member Typedef Documentation

◆ Scalar

◆ XYZVector

Constructor & Destructor Documentation

◆ Quaternion() [1/4]

ROOT::ROOT_MATH_ARCH::Quaternion::Quaternion ( )
inline

Default constructor (identity rotation)

Definition at line 62 of file Quaternion.h.

◆ Quaternion() [2/4]

template<class IT >
ROOT::ROOT_MATH_ARCH::Quaternion::Quaternion ( IT begin,
IT end )
inline

Construct given a pair of pointers or iterators defining the beginning and end of an array of four Scalars.

Definition at line 69 of file Quaternion.h.

◆ Quaternion() [3/4]

template<class OtherRotation >
ROOT::ROOT_MATH_ARCH::Quaternion::Quaternion ( const OtherRotation & r)
inlineexplicit

Construct from another supported rotation type (see gv_detail::convert )

Definition at line 80 of file Quaternion.h.

◆ Quaternion() [4/4]

ROOT::ROOT_MATH_ARCH::Quaternion::Quaternion ( Scalar u,
Scalar i,
Scalar j,
Scalar k )
inline

Construct from four Scalars representing the coefficients of u, i, j, k.

Definition at line 88 of file Quaternion.h.

Member Function Documentation

◆ Distance()

Quaternion::Scalar ROOT::ROOT_MATH_ARCH::Quaternion::Distance ( const Quaternion & q) const

Distance between two rotations in Quaternion form Note: The rotation group is isomorphic to a 3-sphere with diametrically opposite points identified.

The (rotation group-invariant) is the smaller of the two possible angles between the images of the two totations on that sphere. Thus the distance is never greater than pi/2.

Definition at line 101 of file Quaternion.cxx.

◆ GetComponents() [1/3]

template<class IT >
void ROOT::ROOT_MATH_ARCH::Quaternion::GetComponents ( IT begin) const
inline

Get the components into data specified by an iterator begin.

Definition at line 144 of file Quaternion.h.

◆ GetComponents() [2/3]

template<class IT >
void ROOT::ROOT_MATH_ARCH::Quaternion::GetComponents ( IT begin,
IT end ) const
inline

Get the components into data specified by an iterator begin and another to the end of the desired data (4 past start).

Definition at line 130 of file Quaternion.h.

◆ GetComponents() [3/3]

void ROOT::ROOT_MATH_ARCH::Quaternion::GetComponents ( Scalar & u,
Scalar & i,
Scalar & j,
Scalar & k ) const
inline

Get the components into four Scalars.

Definition at line 167 of file Quaternion.h.

◆ I()

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::I ( ) const
inline

Definition at line 181 of file Quaternion.h.

◆ Inverse()

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::Inverse ( ) const
inline

Return inverse of a rotation.

Definition at line 273 of file Quaternion.h.

◆ Invert()

void ROOT::ROOT_MATH_ARCH::Quaternion::Invert ( )
inline

Invert a rotation in place.

Definition at line 263 of file Quaternion.h.

◆ J()

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::J ( ) const
inline

Definition at line 182 of file Quaternion.h.

◆ K()

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::K ( ) const
inline

Definition at line 183 of file Quaternion.h.

◆ operator!=()

bool ROOT::ROOT_MATH_ARCH::Quaternion::operator!= ( const Quaternion & rhs) const
inline

Definition at line 333 of file Quaternion.h.

◆ operator()() [1/5]

template<class CoordSystem , class Tag >
DisplacementVector3D< CoordSystem, Tag > ROOT::ROOT_MATH_ARCH::Quaternion::operator() ( const DisplacementVector3D< CoordSystem, Tag > & v) const
inline

Rotation operation on a displacement vector in any coordinate system.

Definition at line 206 of file Quaternion.h.

◆ operator()() [2/5]

template<class ForeignVector >
ForeignVector ROOT::ROOT_MATH_ARCH::Quaternion::operator() ( const ForeignVector & v) const
inline

Rotation operation on an arbitrary vector v.

Preconditions: v must implement methods x(), y(), and z() and the arbitrary vector type must have a constructor taking (x,y,z)

Definition at line 244 of file Quaternion.h.

◆ operator()() [3/5]

template<class CoordSystem >
LorentzVector< CoordSystem > ROOT::ROOT_MATH_ARCH::Quaternion::operator() ( const LorentzVector< CoordSystem > & v) const
inline

Rotation operation on a Lorentz vector in any 4D coordinate system.

Definition at line 230 of file Quaternion.h.

◆ operator()() [4/5]

template<class CoordSystem , class Tag >
PositionVector3D< CoordSystem, Tag > ROOT::ROOT_MATH_ARCH::Quaternion::operator() ( const PositionVector3D< CoordSystem, Tag > & p) const
inline

Rotation operation on a position vector in any coordinate system.

Definition at line 219 of file Quaternion.h.

◆ operator()() [5/5]

XYZVector ROOT::ROOT_MATH_ARCH::Quaternion::operator() ( const XYZVector & v) const
inline

Definition at line 191 of file Quaternion.h.

◆ operator*() [1/9]

template<class AVector >
AVector ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const AVector & v) const
inline

Overload operator * for rotation on a vector.

Definition at line 255 of file Quaternion.h.

◆ operator*() [2/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const AxisAngle & a) const

Definition at line 83 of file Quaternion.cxx.

◆ operator*() [3/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const EulerAngles & e) const

Definition at line 89 of file Quaternion.cxx.

◆ operator*() [4/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const Quaternion & q) const
inline

Multiply (combine) two rotations.

Multiply (combine) two rotations

Definition at line 283 of file Quaternion.h.

◆ operator*() [5/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const Rotation3D & r) const

Definition at line 77 of file Quaternion.cxx.

◆ operator*() [6/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const RotationX & rx) const

Definition at line 32 of file QuaternionXaxial.cxx.

◆ operator*() [7/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const RotationY & ry) const

Definition at line 40 of file QuaternionXaxial.cxx.

◆ operator*() [8/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const RotationZ & rz) const

Definition at line 48 of file QuaternionXaxial.cxx.

◆ operator*() [9/9]

Quaternion ROOT::ROOT_MATH_ARCH::Quaternion::operator* ( const RotationZYX & r) const

Definition at line 95 of file Quaternion.cxx.

◆ operator*=()

template<class R >
Quaternion & ROOT::ROOT_MATH_ARCH::Quaternion::operator*= ( const R & r)
inline

Post-Multiply (on right) by another rotation : T = T*R.

Definition at line 301 of file Quaternion.h.

◆ operator=()

template<class OtherRotation >
Quaternion & ROOT::ROOT_MATH_ARCH::Quaternion::operator= ( OtherRotation const & r)
inline

Assign from another supported rotation type (see gv_detail::convert )

Definition at line 102 of file Quaternion.h.

◆ operator==()

bool ROOT::ROOT_MATH_ARCH::Quaternion::operator== ( const Quaternion & rhs) const
inline

Equality/inequality operators.

Definition at line 321 of file Quaternion.h.

◆ Rectify()

void ROOT::ROOT_MATH_ARCH::Quaternion::Rectify ( )

Re-adjust components to eliminate small deviations from |Q| = 1 orthonormality.

Definition at line 38 of file Quaternion.cxx.

◆ SetComponents() [1/2]

template<class IT >
void ROOT::ROOT_MATH_ARCH::Quaternion::SetComponents ( IT begin,
IT end )
inline

Set the four components given an iterator to the start of the desired data, and another to the end (4 past start).

Definition at line 115 of file Quaternion.h.

◆ SetComponents() [2/2]

void ROOT::ROOT_MATH_ARCH::Quaternion::SetComponents ( Scalar u,
Scalar i,
Scalar j,
Scalar k )
inline

Set the components based on four Scalars.

The sum of the squares of these Scalars should be 1; no checking is done.

Definition at line 156 of file Quaternion.h.

◆ U()

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::U ( ) const
inline

Access to the four quaternion components: U() is the coefficient of the identity Pauli matrix, I(), J() and K() are the coefficients of sigma_x, sigma_y, sigma_z.

Definition at line 180 of file Quaternion.h.

Member Data Documentation

◆ fI

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::fI
private

Definition at line 337 of file Quaternion.h.

◆ fJ

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::fJ
private

Definition at line 338 of file Quaternion.h.

◆ fK

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::fK
private

Definition at line 339 of file Quaternion.h.

◆ fU

Scalar ROOT::ROOT_MATH_ARCH::Quaternion::fU
private

Definition at line 336 of file Quaternion.h.

  • math/experimental/genvectorx/inc/MathX/GenVectorX/Quaternion.h
  • math/experimental/genvectorx/src/Quaternion.cxx
  • math/experimental/genvectorx/src/QuaternionXaxial.cxx