Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::Quaternion< T > Class Template Reference

General 4-component quaternion \( q = c_1 + c_2 i + c_3 j + c_4 k \). More...

#include <Quaternion.hpp>

+ Inheritance diagram for CDPL::Math::Quaternion< T >:

Public Types

typedef T ValueType
 The scalar component value type. More...
 
typedef T & Reference
 Mutable reference type to a component. More...
 
typedef const T & ConstReference
 Constant reference type to a component. More...
 
typedef ValueType ArrayType[4]
 The plain C-array type used for in-memory storage of the four components. More...
 
typedef T * Pointer
 Pointer type for raw access to the component array. More...
 
typedef const T * ConstPointer
 Constant pointer type for raw access to the component array. More...
 
typedef QuaternionReference< SelfTypeClosureType
 Closure type used when this quaternion appears inside another expression. More...
 
typedef const QuaternionReference< const SelfTypeConstClosureType
 Constant closure type used when this quaternion appears inside another expression. More...
 
typedef SelfType QuaternionTemporaryType
 Concrete temporary quaternion type used by expression-template machinery. More...
 
- Public Types inherited from CDPL::Math::QuaternionContainer< Quaternion< T > >
typedef Quaternion< T > ContainerType
 The derived quaternion container type. More...
 
- Public Types inherited from CDPL::Math::QuaternionExpression< E >
typedef E ExpressionType
 The derived quaternion expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 Quaternion ()
 Constructs an uninitialized quaternion. More...
 
 Quaternion (const ValueType &c1, const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
 Constructs the quaternion with the supplied component values (omitted components default to the value-initialized ValueType). More...
 
 Quaternion (const Quaternion &q)
 Constructs a copy of the quaternion q. More...
 
template<typename E >
 Quaternion (const QuaternionExpression< E > &e)
 Constructs the quaternion from the quaternion expression e. More...
 
Pointer getData ()
 Returns a pointer to the contiguous 4-element component array. More...
 
ConstPointer getData () const
 Returns a const pointer to the contiguous 4-element component array. More...
 
Reference getC1 ()
 Returns a mutable reference to the real component C1. More...
 
Reference getC2 ()
 Returns a mutable reference to the imaginary component C2. More...
 
Reference getC3 ()
 Returns a mutable reference to the imaginary component C3. More...
 
Reference getC4 ()
 Returns a mutable reference to the imaginary component C4. More...
 
ConstReference getC1 () const
 Returns a const reference to the real component C1. More...
 
ConstReference getC2 () const
 Returns a const reference to the imaginary component C2. More...
 
ConstReference getC3 () const
 Returns a const reference to the imaginary component C3. More...
 
ConstReference getC4 () const
 Returns a const reference to the imaginary component C4. More...
 
void set (const ValueType &c1=ValueType(), const ValueType &c2=ValueType(), const ValueType &c3=ValueType(), const ValueType &c4=ValueType())
 Sets the four quaternion components to the supplied values (omitted arguments default to the value-initialized ValueType). More...
 
Quaternionoperator= (const Quaternion &q)
 Copy-assigns the components of q to this quaternion. More...
 
template<typename C >
Quaternionoperator= (const QuaternionContainer< C > &c)
 Assigns the components of the quaternion container c to this quaternion (no alias check needed). More...
 
template<typename E >
Quaternionoperator= (const QuaternionExpression< E > &e)
 Assigns the quaternion expression e to this quaternion (via a temporary to handle aliasing). More...
 
template<typename T1 >
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator= (const T1 &t)
 Assigns the scalar t to the real component (zeroing the three imaginary components). More...
 
template<typename T1 >
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator+= (const T1 &t)
 Adds the scalar t to the real component. More...
 
template<typename C >
Quaternionoperator+= (const QuaternionContainer< C > &c)
 Adds the components of the quaternion container c to this quaternion (no alias check needed). More...
 
template<typename E >
Quaternionoperator+= (const QuaternionExpression< E > &e)
 Adds the quaternion expression e to this quaternion (via a temporary to handle aliasing). More...
 
template<typename T1 >
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator-= (const T1 &t)
 Subtracts the scalar t from the real component. More...
 
template<typename C >
Quaternionoperator-= (const QuaternionContainer< C > &c)
 Subtracts the components of the quaternion container c from this quaternion (no alias check needed). More...
 
template<typename E >
Quaternionoperator-= (const QuaternionExpression< E > &e)
 Subtracts the quaternion expression e from this quaternion (via a temporary to handle aliasing). More...
 
template<typename T1 >
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator*= (const T1 &t)
 Multiplies every component by the scalar t. More...
 
template<typename E >
Quaternionoperator*= (const QuaternionExpression< E > &e)
 Right-multiplies this quaternion by the quaternion expression e (Hamilton product, via a temporary). More...
 
template<typename T1 >
std::enable_if< IsScalar< T1 >::value, Quaternion >::type & operator/= (const T1 &t)
 Divides every component by the scalar t. More...
 
template<typename E >
Quaternionoperator/= (const QuaternionExpression< E > &e)
 Right-divides this quaternion by the quaternion expression e (Hamilton-product inverse, via a temporary). More...
 
template<typename E >
Quaternionassign (const QuaternionExpression< E > &e)
 Assigns the quaternion expression e to this quaternion without intermediate temporary. More...
 
template<typename E >
QuaternionplusAssign (const QuaternionExpression< E > &e)
 Adds the quaternion expression e to this quaternion without intermediate temporary. More...
 
template<typename E >
QuaternionminusAssign (const QuaternionExpression< E > &e)
 Subtracts the quaternion expression e from this quaternion without intermediate temporary. More...
 
void swap (Quaternion &q)
 Swaps the four components of this quaternion with those of q. More...
 
- Public Member Functions inherited from CDPL::Math::QuaternionContainer< Quaternion< T > >
const ContainerTypeoperator() () const
 Returns a const reference to the derived quaternion container. More...
 
ContainerTypeoperator() ()
 Returns a reference to the derived quaternion container. More...
 
- Public Member Functions inherited from CDPL::Math::QuaternionExpression< E >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived quaternion expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived quaternion expression. More...
 

Friends

void swap (Quaternion &q1, Quaternion &q2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::QuaternionContainer< Quaternion< T > >
 QuaternionContainer ()
 
 ~QuaternionContainer ()
 
- Protected Member Functions inherited from CDPL::Math::QuaternionExpression< E >
 QuaternionExpression ()
 
 ~QuaternionExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename T>
class CDPL::Math::Quaternion< T >

General 4-component quaternion \( q = c_1 + c_2 i + c_3 j + c_4 k \).

Template Parameters
TThe scalar component value type.

Member Typedef Documentation

◆ ValueType

template<typename T >
typedef T CDPL::Math::Quaternion< T >::ValueType

The scalar component value type.

◆ Reference

template<typename T >
typedef T& CDPL::Math::Quaternion< T >::Reference

Mutable reference type to a component.

◆ ConstReference

template<typename T >
typedef const T& CDPL::Math::Quaternion< T >::ConstReference

Constant reference type to a component.

◆ ArrayType

template<typename T >
typedef ValueType CDPL::Math::Quaternion< T >::ArrayType[4]

The plain C-array type used for in-memory storage of the four components.

◆ Pointer

template<typename T >
typedef T* CDPL::Math::Quaternion< T >::Pointer

Pointer type for raw access to the component array.

◆ ConstPointer

template<typename T >
typedef const T* CDPL::Math::Quaternion< T >::ConstPointer

Constant pointer type for raw access to the component array.

◆ ClosureType

template<typename T >
typedef QuaternionReference<SelfType> CDPL::Math::Quaternion< T >::ClosureType

Closure type used when this quaternion appears inside another expression.

◆ ConstClosureType

template<typename T >
typedef const QuaternionReference<const SelfType> CDPL::Math::Quaternion< T >::ConstClosureType

Constant closure type used when this quaternion appears inside another expression.

◆ QuaternionTemporaryType

template<typename T >
typedef SelfType CDPL::Math::Quaternion< T >::QuaternionTemporaryType

Concrete temporary quaternion type used by expression-template machinery.

Constructor & Destructor Documentation

◆ Quaternion() [1/4]

template<typename T >
CDPL::Math::Quaternion< T >::Quaternion ( )
inline

Constructs an uninitialized quaternion.

◆ Quaternion() [2/4]

template<typename T >
CDPL::Math::Quaternion< T >::Quaternion ( const ValueType c1,
const ValueType c2 = ValueType(),
const ValueType c3 = ValueType(),
const ValueType c4 = ValueType() 
)
inlineexplicit

Constructs the quaternion with the supplied component values (omitted components default to the value-initialized ValueType).

Parameters
c1The real component.
c2The first imaginary component.
c3The second imaginary component.
c4The third imaginary component.

◆ Quaternion() [3/4]

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

Constructs a copy of the quaternion q.

Parameters
qThe quaternion to copy.

◆ Quaternion() [4/4]

template<typename T >
template<typename E >
CDPL::Math::Quaternion< T >::Quaternion ( const QuaternionExpression< E > &  e)
inline

Constructs the quaternion from the quaternion expression e.

Template Parameters
EThe quaternion expression type.
Parameters
eThe quaternion expression to materialize.

Member Function Documentation

◆ getData() [1/2]

template<typename T >
Pointer CDPL::Math::Quaternion< T >::getData ( )
inline

Returns a pointer to the contiguous 4-element component array.

Returns
A mutable pointer to the component array.

◆ getData() [2/2]

template<typename T >
ConstPointer CDPL::Math::Quaternion< T >::getData ( ) const
inline

Returns a const pointer to the contiguous 4-element component array.

Returns
A const pointer to the component array.

◆ getC1() [1/2]

template<typename T >
Reference CDPL::Math::Quaternion< T >::getC1 ( )
inline

Returns a mutable reference to the real component C1.

Returns
A mutable reference to C1.

◆ getC2() [1/2]

template<typename T >
Reference CDPL::Math::Quaternion< T >::getC2 ( )
inline

Returns a mutable reference to the imaginary component C2.

Returns
A mutable reference to C2.

◆ getC3() [1/2]

template<typename T >
Reference CDPL::Math::Quaternion< T >::getC3 ( )
inline

Returns a mutable reference to the imaginary component C3.

Returns
A mutable reference to C3.

◆ getC4() [1/2]

template<typename T >
Reference CDPL::Math::Quaternion< T >::getC4 ( )
inline

Returns a mutable reference to the imaginary component C4.

Returns
A mutable reference to C4.

◆ getC1() [2/2]

template<typename T >
ConstReference CDPL::Math::Quaternion< T >::getC1 ( ) const
inline

Returns a const reference to the real component C1.

Returns
A const reference to C1.

◆ getC2() [2/2]

template<typename T >
ConstReference CDPL::Math::Quaternion< T >::getC2 ( ) const
inline

Returns a const reference to the imaginary component C2.

Returns
A const reference to C2.

◆ getC3() [2/2]

template<typename T >
ConstReference CDPL::Math::Quaternion< T >::getC3 ( ) const
inline

Returns a const reference to the imaginary component C3.

Returns
A const reference to C3.

◆ getC4() [2/2]

template<typename T >
ConstReference CDPL::Math::Quaternion< T >::getC4 ( ) const
inline

Returns a const reference to the imaginary component C4.

Returns
A const reference to C4.

◆ set()

template<typename T >
void CDPL::Math::Quaternion< T >::set ( const ValueType c1 = ValueType(),
const ValueType c2 = ValueType(),
const ValueType c3 = ValueType(),
const ValueType c4 = ValueType() 
)
inline

Sets the four quaternion components to the supplied values (omitted arguments default to the value-initialized ValueType).

Parameters
c1The new real component.
c2The new first imaginary component.
c3The new second imaginary component.
c4The new third imaginary component.

◆ operator=() [1/4]

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

Copy-assigns the components of q to this quaternion.

Parameters
qThe source quaternion.
Returns
A reference to itself.

◆ operator=() [2/4]

template<typename T >
template<typename C >
Quaternion& CDPL::Math::Quaternion< T >::operator= ( const QuaternionContainer< C > &  c)
inline

Assigns the components of the quaternion container c to this quaternion (no alias check needed).

Template Parameters
CThe source quaternion container type.
Parameters
cThe source quaternion container.
Returns
A reference to itself.

◆ operator=() [3/4]

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::operator= ( const QuaternionExpression< E > &  e)
inline

Assigns the quaternion expression e to this quaternion (via a temporary to handle aliasing).

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ operator=() [4/4]

template<typename T >
template<typename T1 >
std::enable_if<IsScalar<T1>::value, Quaternion>::type& CDPL::Math::Quaternion< T >::operator= ( const T1 &  t)
inline

Assigns the scalar t to the real component (zeroing the three imaginary components).

Template Parameters
T1The scalar type.
Parameters
tThe scalar value.
Returns
A reference to itself.

◆ operator+=() [1/3]

template<typename T >
template<typename T1 >
std::enable_if<IsScalar<T1>::value, Quaternion>::type& CDPL::Math::Quaternion< T >::operator+= ( const T1 &  t)
inline

Adds the scalar t to the real component.

Template Parameters
T1The scalar type.
Parameters
tThe scalar addend.
Returns
A reference to itself.

◆ operator+=() [2/3]

template<typename T >
template<typename C >
Quaternion& CDPL::Math::Quaternion< T >::operator+= ( const QuaternionContainer< C > &  c)
inline

Adds the components of the quaternion container c to this quaternion (no alias check needed).

Template Parameters
CThe source quaternion container type.
Parameters
cThe source quaternion container.
Returns
A reference to itself.

◆ operator+=() [3/3]

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::operator+= ( const QuaternionExpression< E > &  e)
inline

Adds the quaternion expression e to this quaternion (via a temporary to handle aliasing).

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ operator-=() [1/3]

template<typename T >
template<typename T1 >
std::enable_if<IsScalar<T1>::value, Quaternion>::type& CDPL::Math::Quaternion< T >::operator-= ( const T1 &  t)
inline

Subtracts the scalar t from the real component.

Template Parameters
T1The scalar type.
Parameters
tThe scalar subtrahend.
Returns
A reference to itself.

◆ operator-=() [2/3]

template<typename T >
template<typename C >
Quaternion& CDPL::Math::Quaternion< T >::operator-= ( const QuaternionContainer< C > &  c)
inline

Subtracts the components of the quaternion container c from this quaternion (no alias check needed).

Template Parameters
CThe source quaternion container type.
Parameters
cThe source quaternion container.
Returns
A reference to itself.

◆ operator-=() [3/3]

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::operator-= ( const QuaternionExpression< E > &  e)
inline

Subtracts the quaternion expression e from this quaternion (via a temporary to handle aliasing).

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ operator*=() [1/2]

template<typename T >
template<typename T1 >
std::enable_if<IsScalar<T1>::value, Quaternion>::type& CDPL::Math::Quaternion< T >::operator*= ( const T1 &  t)
inline

Multiplies every component by the scalar t.

Template Parameters
T1The scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator*=() [2/2]

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::operator*= ( const QuaternionExpression< E > &  e)
inline

Right-multiplies this quaternion by the quaternion expression e (Hamilton product, via a temporary).

Template Parameters
EThe right-hand quaternion expression type.
Parameters
eThe right-hand quaternion expression.
Returns
A reference to itself.

◆ operator/=() [1/2]

template<typename T >
template<typename T1 >
std::enable_if<IsScalar<T1>::value, Quaternion>::type& CDPL::Math::Quaternion< T >::operator/= ( const T1 &  t)
inline

Divides every component by the scalar t.

Template Parameters
T1The scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ operator/=() [2/2]

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::operator/= ( const QuaternionExpression< E > &  e)
inline

Right-divides this quaternion by the quaternion expression e (Hamilton-product inverse, via a temporary).

Template Parameters
EThe right-hand quaternion expression type.
Parameters
eThe right-hand quaternion expression.
Returns
A reference to itself.

◆ assign()

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::assign ( const QuaternionExpression< E > &  e)
inline

Assigns the quaternion expression e to this quaternion without intermediate temporary.

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ plusAssign()

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::plusAssign ( const QuaternionExpression< E > &  e)
inline

Adds the quaternion expression e to this quaternion without intermediate temporary.

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ minusAssign()

template<typename T >
template<typename E >
Quaternion& CDPL::Math::Quaternion< T >::minusAssign ( const QuaternionExpression< E > &  e)
inline

Subtracts the quaternion expression e from this quaternion without intermediate temporary.

Template Parameters
EThe source quaternion expression type.
Parameters
eThe source quaternion expression.
Returns
A reference to itself.

◆ swap()

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

Swaps the four components of this quaternion with those of q.

Parameters
qThe quaternion to swap with.

Friends And Related Function Documentation

◆ swap

template<typename T >
void swap ( Quaternion< T > &  q1,
Quaternion< T > &  q2 
)
friend

ADL-enabled free-function form of swap().

Parameters
q1The first quaternion.
q2The second quaternion.

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