Rosetta
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
numeric::Quaternion< T > Class Template Reference

Unit quaternion 3-D orientation representation. More...

#include <Quaternion.hh>

Public Types

typedef T Value
 
typedef TReference
 
typedef T const & ConstReference
 
typedef TPointer
 
typedef T const * ConstPointer
 
typedef T value_type
 
typedef Treference
 
typedef T const & const_reference
 
typedef Tpointer
 
typedef T const * const_pointer
 
typedef NumericTraits< TTraits
 
typedef xyzVector< TAxis
 

Public Member Functions

 Quaternion ()
 Default constructor. More...
 
 Quaternion (Value const &w_a, Value const &x_a, Value const &y_a, Value const &z_a, bool const precise=true)
 Coordinate constructor. More...
 
 Quaternion (Axis const &u, Value const &angle, bool const precise=true)
 
 Quaternion (Quaternion const &q)
 Copy constructor. More...
 
 ~Quaternion ()
 Destructor. More...
 
Quaternionoperator= (Quaternion const &q)
 
void w (Value newval)
 w More...
 
void x (Value newval)
 x More...
 
void y (Value newval)
 y More...
 
void z (Value newval)
 z More...
 
Value const & w () const
 w More...
 
Value const & x () const
 x More...
 
Value const & y () const
 y More...
 
Value const & z () const
 z More...
 
Value w_squared () const
 w squared More...
 
Value x_squared () const
 x squared More...
 
Value y_squared () const
 y squared More...
 
Value z_squared () const
 z squared More...
 
Value norm () const
 Norm: Should be one. More...
 
Value norm_squared () const
 Norm squared: Should be one. More...
 
Value norm_error () const
 Norm error. More...
 
Value norm_squared_error () const
 Norm squared error. More...
 
Value magnitude () const
 Magnitude: Should be one. More...
 
Value magnitude_squared () const
 Magnitude squared: Should be one. More...
 
Value magnitude_error () const
 Magnitude error. More...
 
Value magnitude_squared_error () const
 Magnitude squared error. More...
 
bool is_normalized (Value const &tol=Traits::quaternion_tolerance()) const
 Magnitude squared error within tolerance? More...
 
bool not_normalized (Value const &tol=Traits::quaternion_tolerance()) const
 Magnitude squared error exceeds tolerance? More...
 
Value angle () const
 Principal angle of rotation (on [0,2*pi]) More...
 
Axis axis () const
 Axis of Rotation unit vector (direction for angle on [0,2*pi]) More...
 
Axisaxis (Axis &u) const
 Axis of rotation unit vector: Passed vector (direction for angle on [0,2*pi]) More...
 
std::string to_string () const
 to_string, useful for utility exits More...
 
Value dot (Quaternion const &q) const
 Dot product. More...
 
Value dot_product (Quaternion const &q) const
 Dot product. More...
 
Quaternionnormalize ()
 Normalize. More...
 
Quaternionnormalize_if_needed (Value const &tol=Traits::quaternion_tolerance())
 Normalize if magnitude squared error exceeds tolerance. More...
 
Quaternionto_identity ()
 Identity. More...
 
Quaternionconjugate ()
 Conjugate. More...
 
Quaternioninvert ()
 Invert. More...
 
Quaternionapply (Quaternion const &q, bool const precise=true)
 Apply a successive Quaternion. More...
 
Quaternionleft_multiply_by (Quaternion const &q, bool const precise=true)
 Left multiply by a Quaternion. More...
 
Quaternionright_multiply_by (Quaternion const &q, bool const precise=true)
 Right multiply by a Quaternion. More...
 
Quaternionleft_multiply_by_inverse_of (Quaternion const &q, bool const precise=true)
 Left multiply by the inverse of a Quaternion. More...
 
Quaternionright_multiply_by_inverse_of (Quaternion const &q, bool const precise=true)
 Right multiply by the inverse of a Quaternion. More...
 
void swap (Quaternion &q)
 Swap. More...
 
Quaternion conjugated () const
 Conjugated. More...
 
Quaternion inverse () const
 Inverse. More...
 

Static Public Member Functions

static Quaternion identity ()
 Identity named constructor. More...
 
static Quaternion const & I ()
 Identity Quaternion for expressions. More...
 

Private Attributes

Value w_
 w coordinate More...
 
Value x_
 x coordinate More...
 
Value y_
 y coordinate More...
 
Value z_
 z coordinate More...
 

Friends

class BodyPosition< T >
 
template<class U >
Quaternion< U > operator* (Quaternion< U > const &q2, Quaternion< U > const &q1)
 Quaternion * Quaternion (always normalizes return value) More...
 
template<class U >
Quaternion< U > product (Quaternion< U > const &q2, Quaternion< U > const &q1, bool const precise=true)
 Product: Quaternion * Quaternion. More...
 
template<class U >
bool operator== (Quaternion< U > const &q1, Quaternion< U > const &q2)
 Quaternion == Quaternion. More...
 
template<class U >
bool operator!= (Quaternion< U > const &q1, Quaternion< U > const &q2)
 Quaternion != Quaternion. More...
 
template<class U >
Value dot (Quaternion< U > const &q1, Quaternion< U > const &q2)
 Dot product. More...
 
template<class U >
Value dot_product (Quaternion< U > const &q1, Quaternion< U > const &q2)
 Dot product. More...
 

Detailed Description

template<typename T>
class numeric::Quaternion< T >

Unit quaternion 3-D orientation representation.

Remarks
  • Quaternion defined as ( w, x, y, z )
  • Quaternions must be in the same coordinate frame to be used together
  • Successive rotation convention: q2 * q1 means q1 followed by q2
  • Performance-critical code can suppress normalization after every modification and use explicit normalization

Member Typedef Documentation

◆ Axis

template<typename T >
typedef xyzVector< T > numeric::Quaternion< T >::Axis

◆ const_pointer

template<typename T >
typedef T const* numeric::Quaternion< T >::const_pointer

◆ const_reference

template<typename T >
typedef T const& numeric::Quaternion< T >::const_reference

◆ ConstPointer

template<typename T >
typedef T const* numeric::Quaternion< T >::ConstPointer

◆ ConstReference

template<typename T >
typedef T const& numeric::Quaternion< T >::ConstReference

◆ Pointer

template<typename T >
typedef T* numeric::Quaternion< T >::Pointer

◆ pointer

template<typename T >
typedef T* numeric::Quaternion< T >::pointer

◆ Reference

template<typename T >
typedef T& numeric::Quaternion< T >::Reference

◆ reference

template<typename T >
typedef T& numeric::Quaternion< T >::reference

◆ Traits

template<typename T >
typedef NumericTraits< T > numeric::Quaternion< T >::Traits

◆ Value

template<typename T >
typedef T numeric::Quaternion< T >::Value

◆ value_type

template<typename T >
typedef T numeric::Quaternion< T >::value_type

Constructor & Destructor Documentation

◆ Quaternion() [1/4]

template<typename T >
numeric::Quaternion< T >::Quaternion ( )
inline

◆ Quaternion() [2/4]

template<typename T >
numeric::Quaternion< T >::Quaternion ( Value const &  w_a,
Value const &  x_a,
Value const &  y_a,
Value const &  z_a,
bool const  precise = true 
)
inline

◆ Quaternion() [3/4]

template<typename T >
numeric::Quaternion< T >::Quaternion ( Axis const &  u,
Value const &  angle,
bool const  precise = true 
)
inline

◆ Quaternion() [4/4]

template<typename T >
numeric::Quaternion< T >::Quaternion ( Quaternion< T > const &  q)
inline

Copy constructor.

◆ ~Quaternion()

template<typename T >
numeric::Quaternion< T >::~Quaternion ( )
inline

Destructor.

Member Function Documentation

◆ angle()

template<typename T >
Value numeric::Quaternion< T >::angle ( ) const
inline

Principal angle of rotation (on [0,2*pi])

References pyrosetta.distributed.cluster.exceptions::T, and numeric::Quaternion< T >::w_.

Referenced by numeric::BodyPosition< T >::angle().

◆ apply()

template<typename T >
Quaternion& numeric::Quaternion< T >::apply ( Quaternion< T > const &  q,
bool const  precise = true 
)
inline

◆ axis() [1/2]

template<typename T >
Axis numeric::Quaternion< T >::axis ( ) const
inline

Axis of Rotation unit vector (direction for angle on [0,2*pi])

References numeric::Quaternion< T >::x_, numeric::Quaternion< T >::y_, and numeric::Quaternion< T >::z_.

Referenced by numeric::BodyPosition< T >::axis().

◆ axis() [2/2]

template<typename T >
Axis& numeric::Quaternion< T >::axis ( Axis u) const
inline

Axis of rotation unit vector: Passed vector (direction for angle on [0,2*pi])

References kmeans_adaptive_kernel_density_bb_dependent_rotlib::u, numeric::Quaternion< T >::x_, numeric::Quaternion< T >::y_, and numeric::Quaternion< T >::z_.

◆ conjugate()

template<typename T >
Quaternion& numeric::Quaternion< T >::conjugate ( )
inline

◆ conjugated()

template<typename T >
Quaternion numeric::Quaternion< T >::conjugated ( ) const
inline

◆ dot()

template<typename T >
Value numeric::Quaternion< T >::dot ( Quaternion< T > const &  q) const
inline

◆ dot_product()

template<typename T >
Value numeric::Quaternion< T >::dot_product ( Quaternion< T > const &  q) const
inline

◆ I()

template<typename T >
static Quaternion const& numeric::Quaternion< T >::I ( )
inlinestatic

Identity Quaternion for expressions.

Note
Default and identity() named constructors can be faster for construction
Can be safely used in construction of global objects

References pyrosetta.distributed.cluster.exceptions::T.

◆ identity()

template<typename T >
static Quaternion numeric::Quaternion< T >::identity ( )
inlinestatic

◆ inverse()

template<typename T >
Quaternion numeric::Quaternion< T >::inverse ( ) const
inline

◆ invert()

template<typename T >
Quaternion& numeric::Quaternion< T >::invert ( )
inline

◆ is_normalized()

template<typename T >
bool numeric::Quaternion< T >::is_normalized ( Value const &  tol = Traits::quaternion_tolerance()) const
inline

Magnitude squared error within tolerance?

References numeric::Quaternion< T >::norm_squared_error(), and loops_kic::tol.

Referenced by numeric::Quaternion< T >::Quaternion().

◆ left_multiply_by()

template<typename T >
Quaternion& numeric::Quaternion< T >::left_multiply_by ( Quaternion< T > const &  q,
bool const  precise = true 
)
inline

◆ left_multiply_by_inverse_of()

template<typename T >
Quaternion& numeric::Quaternion< T >::left_multiply_by_inverse_of ( Quaternion< T > const &  q,
bool const  precise = true 
)
inline

◆ magnitude()

template<typename T >
Value numeric::Quaternion< T >::magnitude ( ) const
inline

◆ magnitude_error()

template<typename T >
Value numeric::Quaternion< T >::magnitude_error ( ) const
inline

◆ magnitude_squared()

template<typename T >
Value numeric::Quaternion< T >::magnitude_squared ( ) const
inline

◆ magnitude_squared_error()

template<typename T >
Value numeric::Quaternion< T >::magnitude_squared_error ( ) const
inline

◆ norm()

template<typename T >
Value numeric::Quaternion< T >::norm ( ) const
inline

◆ norm_error()

template<typename T >
Value numeric::Quaternion< T >::norm_error ( ) const
inline

◆ norm_squared()

template<typename T >
Value numeric::Quaternion< T >::norm_squared ( ) const
inline

◆ norm_squared_error()

template<typename T >
Value numeric::Quaternion< T >::norm_squared_error ( ) const
inline

◆ normalize()

template<typename T >
Quaternion& numeric::Quaternion< T >::normalize ( )
inline

◆ normalize_if_needed()

template<typename T >
Quaternion& numeric::Quaternion< T >::normalize_if_needed ( Value const &  tol = Traits::quaternion_tolerance())
inline

◆ not_normalized()

template<typename T >
bool numeric::Quaternion< T >::not_normalized ( Value const &  tol = Traits::quaternion_tolerance()) const
inline

Magnitude squared error exceeds tolerance?

References numeric::Quaternion< T >::norm_squared_error(), and loops_kic::tol.

◆ operator=()

template<typename T >
Quaternion& numeric::Quaternion< T >::operator= ( Quaternion< T > const &  q)
inline

◆ right_multiply_by()

template<typename T >
Quaternion& numeric::Quaternion< T >::right_multiply_by ( Quaternion< T > const &  q,
bool const  precise = true 
)
inline

◆ right_multiply_by_inverse_of()

template<typename T >
Quaternion& numeric::Quaternion< T >::right_multiply_by_inverse_of ( Quaternion< T > const &  q,
bool const  precise = true 
)
inline

◆ swap()

template<typename T >
void numeric::Quaternion< T >::swap ( Quaternion< T > &  q)
inline

◆ to_identity()

template<typename T >
Quaternion& numeric::Quaternion< T >::to_identity ( )
inline

◆ to_string()

template<typename T >
std::string numeric::Quaternion< T >::to_string ( ) const
inline

◆ w() [1/2]

template<typename T >
Value const& numeric::Quaternion< T >::w ( ) const
inline

◆ w() [2/2]

template<typename T >
void numeric::Quaternion< T >::w ( Value  newval)
inline

◆ w_squared()

template<typename T >
Value numeric::Quaternion< T >::w_squared ( ) const
inline

w squared

References numeric::Quaternion< T >::w_.

◆ x() [1/2]

template<typename T >
Value const& numeric::Quaternion< T >::x ( ) const
inline

◆ x() [2/2]

template<typename T >
void numeric::Quaternion< T >::x ( Value  newval)
inline

◆ x_squared()

template<typename T >
Value numeric::Quaternion< T >::x_squared ( ) const
inline

x squared

References numeric::Quaternion< T >::x_.

◆ y() [1/2]

template<typename T >
Value const& numeric::Quaternion< T >::y ( ) const
inline

◆ y() [2/2]

template<typename T >
void numeric::Quaternion< T >::y ( Value  newval)
inline

◆ y_squared()

template<typename T >
Value numeric::Quaternion< T >::y_squared ( ) const
inline

y squared

References numeric::Quaternion< T >::y_.

◆ z() [1/2]

template<typename T >
Value const& numeric::Quaternion< T >::z ( ) const
inline

◆ z() [2/2]

template<typename T >
void numeric::Quaternion< T >::z ( Value  newval)
inline

◆ z_squared()

template<typename T >
Value numeric::Quaternion< T >::z_squared ( ) const
inline

z squared

References numeric::Quaternion< T >::z_.

Friends And Related Function Documentation

◆ BodyPosition< T >

template<typename T >
friend class BodyPosition< T >
friend

◆ dot

template<typename T >
template<class U >
Value dot ( Quaternion< U > const &  q1,
Quaternion< U > const &  q2 
)
friend

Dot product.

◆ dot_product

template<typename T >
template<class U >
Value dot_product ( Quaternion< U > const &  q1,
Quaternion< U > const &  q2 
)
friend

Dot product.

◆ operator!=

template<typename T >
template<class U >
bool operator!= ( Quaternion< U > const &  q1,
Quaternion< U > const &  q2 
)
friend

◆ operator*

template<typename T >
template<class U >
Quaternion<U> operator* ( Quaternion< U > const &  q2,
Quaternion< U > const &  q1 
)
friend

Quaternion * Quaternion (always normalizes return value)

◆ operator==

template<typename T >
template<class U >
bool operator== ( Quaternion< U > const &  q1,
Quaternion< U > const &  q2 
)
friend

◆ product

template<typename T >
template<class U >
Quaternion<U> product ( Quaternion< U > const &  q2,
Quaternion< U > const &  q1,
bool const  precise = true 
)
friend

Product: Quaternion * Quaternion.

Member Data Documentation

◆ w_

template<typename T >
Value numeric::Quaternion< T >::w_
private

◆ x_

template<typename T >
Value numeric::Quaternion< T >::x_
private

◆ y_

template<typename T >
Value numeric::Quaternion< T >::y_
private

◆ z_

template<typename T >
Value numeric::Quaternion< T >::z_
private

The documentation for this class was generated from the following files: