adamantine
Public Member Functions | Private Member Functions | Private Attributes | List of all members
adamantine::Quaternion Class Reference

#include <Quaternion.hh>

Public Member Functions

 Quaternion ()
 
 Quaternion (double const r, double const i, double const j, double const k)
 
void reinit (double const r, double const i, double const j, double const k)
 
bool is_valid () const
 
dealii::Point< 3, double > rotate (dealii::Point< 3, double > const &point) const
 
dealii::Point< 3, dealii::VectorizedArray< double > > rotate (dealii::Point< 3, dealii::VectorizedArray< double >> const &points) const
 
dealii::Point< 3, double > inv_rotate (dealii::Point< 3, double > const &point) const
 
dealii::Point< 3, dealii::VectorizedArray< double > > inv_rotate (dealii::Point< 3, dealii::VectorizedArray< double >> const &points) const
 
bool operator== (Quaternion const &other) const
 
Quaternionoperator*= (Quaternion const &other)
 
Quaternionoperator/= (Quaternion const &other)
 
void pow (double const exp)
 

Private Member Functions

void build_rotation_matrices ()
 

Private Attributes

bool _is_valid = false
 
std::array< double, 4 > _quaternion
 
dealii::Tensor< 2, 3, double > _rotation_matrix
 
dealii::Tensor< 2, 3, double > _inv_rotation_matrix
 
dealii::Tensor< 2, 3, dealii::VectorizedArray< double > > _vec_rotation_matrix
 
dealii::Tensor< 2, 3, dealii::VectorizedArray< double > > _vec_inv_rotation_matrix
 

Detailed Description

This class defines rotation using quaternion. Unit quaternions, known as versors, provide a convenient mathematical notation for representing spatial orientations and rotations of elements in three dimensional space. Specifically, they encode information about an axis-angle rotation about an arbitrary axis.

Definition at line 21 of file Quaternion.hh.

Constructor & Destructor Documentation

◆ Quaternion() [1/2]

adamantine::Quaternion::Quaternion ( )

Default constructor. The object is initialized in an invalid state. It can only be used after calling reinit().

Definition at line 14 of file Quaternion.cc.

◆ Quaternion() [2/2]

adamantine::Quaternion::Quaternion ( double const  r,
double const  i,
double const  j,
double const  k 
)

Constructor. The quaternion should be normed.

Definition at line 30 of file Quaternion.cc.

Member Function Documentation

◆ build_rotation_matrices()

void adamantine::Quaternion::build_rotation_matrices ( )
private

Build the different rotation matrices.

Definition at line 116 of file Quaternion.cc.

◆ inv_rotate() [1/2]

dealii::Point< 3, dealii::VectorizedArray< double > > adamantine::Quaternion::inv_rotate ( dealii::Point< 3, dealii::VectorizedArray< double >> const &  points) const
inline

Rotate the given points by the inverse of the quaternion.

Definition at line 144 of file Quaternion.hh.

◆ inv_rotate() [2/2]

dealii::Point< 3, double > adamantine::Quaternion::inv_rotate ( dealii::Point< 3, double > const &  point) const
inline

Rotate the given point by the inverse of the quaternion.

Definition at line 139 of file Quaternion.hh.

◆ is_valid()

bool adamantine::Quaternion::is_valid ( ) const

Return true if the quaternion has been initialized.

Definition at line 50 of file Quaternion.cc.

◆ operator*=()

Quaternion & adamantine::Quaternion::operator*= ( Quaternion const &  other)

Multiply two quaternions together using the Hamilton product. The resulting quaternion describes the single combined rotation that results from applying the two rotations.

Definition at line 60 of file Quaternion.cc.

◆ operator/=()

Quaternion & adamantine::Quaternion::operator/= ( Quaternion const &  other)

Multiply the quaternions using the inverse of other.

Definition at line 84 of file Quaternion.cc.

◆ operator==()

bool adamantine::Quaternion::operator== ( Quaternion const &  other) const

Test for equality of two quaternions.

Definition at line 52 of file Quaternion.cc.

◆ pow()

void adamantine::Quaternion::pow ( double const  exp)

Compute the power to the exp of the quaternion. If exp is less than one, this corresponds to a partial rotation.

Definition at line 96 of file Quaternion.cc.

◆ reinit()

void adamantine::Quaternion::reinit ( double const  r,
double const  i,
double const  j,
double const  k 
)

Reinitialize the quaternion. The norm should be equal to one.

Definition at line 36 of file Quaternion.cc.

◆ rotate() [1/2]

dealii::Point< 3, dealii::VectorizedArray< double > > adamantine::Quaternion::rotate ( dealii::Point< 3, dealii::VectorizedArray< double >> const &  points) const
inline

Rotate the given points.

Definition at line 131 of file Quaternion.hh.

◆ rotate() [2/2]

dealii::Point< 3, double > adamantine::Quaternion::rotate ( dealii::Point< 3, double > const &  point) const
inline

Rotate the given point.

Definition at line 126 of file Quaternion.hh.

Member Data Documentation

◆ _inv_rotation_matrix

dealii::Tensor<2, 3, double> adamantine::Quaternion::_inv_rotation_matrix
private

Rotation matrix defined by the inverse quaternion.

Definition at line 113 of file Quaternion.hh.

◆ _is_valid

bool adamantine::Quaternion::_is_valid = false
private

Flag is false if the default constructor was called and reinit() has not been called yet.

Definition at line 101 of file Quaternion.hh.

◆ _quaternion

std::array<double, 4> adamantine::Quaternion::_quaternion
private

Store the value of the quaternion.

Definition at line 105 of file Quaternion.hh.

◆ _rotation_matrix

dealii::Tensor<2, 3, double> adamantine::Quaternion::_rotation_matrix
private

Rotation matrix defined by the quaternion.

Definition at line 109 of file Quaternion.hh.

◆ _vec_inv_rotation_matrix

dealii::Tensor<2, 3, dealii::VectorizedArray<double> > adamantine::Quaternion::_vec_inv_rotation_matrix
private

Vectorized rotation matrix defined by the inverse quaternion.

Definition at line 122 of file Quaternion.hh.

◆ _vec_rotation_matrix

dealii::Tensor<2, 3, dealii::VectorizedArray<double> > adamantine::Quaternion::_vec_rotation_matrix
private

Vectorized rotation matrix defined by the quaternion.

Definition at line 117 of file Quaternion.hh.