Developer Documentation
ACG::QuaternionT< Scalar > Class Template Reference

#include <OpenFlipper/libs_required/ACG/Math/QuaternionT.hh>

Inheritance diagram for ACG::QuaternionT< Scalar >:
OpenMesh::VectorT< Scalar, DIM >

Public Types

typedef VectorT< Scalar, 4 > Base
 
typedef QuaternionT< Scalar > Quaternion
 
typedef VectorT< Scalar, 3 > Vec3
 
typedef VectorT< Scalar, 4 > Vec4
 
typedef Matrix4x4T< Scalar > Matrix
 
- Public Types inherited from OpenMesh::VectorT< Scalar, DIM >
typedef Scalar value_type
 the type of the scalar used in this template More...
 
typedef VectorT< Scalar, DIM > vector_type
 type of this vector More...
 
using iterator = typename container::iterator
 
using const_iterator = typename container::const_iterator
 
using reverse_iterator = typename container::reverse_iterator
 
using const_reverse_iterator = typename container::const_reverse_iterator
 

Public Member Functions

 QuaternionT (Scalar _w=1.0, Scalar _x=0.0, Scalar _y=0.0, Scalar _z=0.0)
 construct from 4 Scalars (default) More...
 
 QuaternionT (const Vec3 &_p)
 construct from 3D point (pure imaginary quaternion) More...
 
 QuaternionT (const Vec4 &_p)
 construct from 4D vector More...
 
 QuaternionT (Vec3 _axis, Scalar _angle)
 construct from rotation axis and angle (in radians) More...
 
template<class MatrixT >
 QuaternionT (const MatrixT &_rot)
 construct from rotation matrix (only valid for rotation matrices!) More...
 
void identity ()
 identity rotation More...
 
Quaternion conjugate () const
 conjugate quaternion More...
 
Quaternion invert () const
 invert quaternion More...
 
Quaternion operator* (const Quaternion &_q) const
 quaternion * quaternion More...
 
Quaternionoperator*= (const Quaternion &_q)
 quaternion *= quaternion More...
 
template<class Vec3T >
Vec3T rotate (const Vec3T &_v) const
 rotate vector More...
 
void axis_angle (Vec3 &_axis, Scalar &_angle) const
 get rotation axis and angle (only valid for unit quaternions!) More...
 
Matrix rotation_matrix () const
 cast to rotation matrix More...
 
Matrix right_mult_matrix () const
 get matrix for mult from right (p*q = Qp) More...
 
Matrix left_mult_matrix () const
 get matrix for mult from left (q*p = Qp) More...
 
template<class MatrixT >
void init_from_matrix (const MatrixT &_rot)
 get quaternion from rotation matrix More...
 
Quaternion exponential () const
 quaternion exponential (for unit quaternions) More...
 
Quaternion logarithm () const
 quaternion logarithm (for unit quaternions) More...
 
void print_info ()
 
- Public Member Functions inherited from OpenMesh::VectorT< Scalar, DIM >
template<typename T , typename ... Ts, typename = typename std::enable_if<sizeof...(Ts)+1 == DIM>::type, typename = typename std::enable_if< are_convertible_to<Scalar, T, Ts...>::value>::type>
constexpr VectorT (T v, Ts... vs)
 
constexpr VectorT ()
 default constructor creates uninitialized values. More...
 
 VectorT (const Scalar &v)
 
 VectorT (const VectorT &rhs)=default
 
 VectorT (VectorT &&rhs)=default
 
VectorToperator= (const VectorT &rhs)=default
 
VectorToperator= (VectorT &&rhs)=default
 
template<typename S = Scalar, int D = DIM>
auto homogenized () const -> typename std::enable_if< D==4, VectorT< decltype(std::declval< S >()/std::declval< S >()), DIM > >::type
 
template<typename Iterator , typename = decltype( *std::declval<Iterator&>(), void(), ++std::declval<Iterator&>(), void())>
 VectorT (Iterator it)
 construct from a value array or any other iterator More...
 
 VectorT (container &&_array)
 construct from an array More...
 
template<typename otherScalarType , typename = typename std::enable_if< std::is_convertible<otherScalarType, Scalar>::value>>
 VectorT (const VectorT< otherScalarType, DIM > &_rhs)
 copy & cast constructor (explicit) More...
 
template<typename OtherScalar , typename = typename std::enable_if< std::is_convertible<OtherScalar, Scalar>::value>>
vector_typeoperator= (const VectorT< OtherScalar, DIM > &_rhs)
 cast from vector with a different scalar type More...
 
Scalar * data ()
 access to Scalar array More...
 
const Scalar * data () const
 access to const Scalar array More...
 
Scalar & operator[] (size_t _i)
 get i'th element read-write More...
 
const Scalar & operator[] (size_t _i) const
 get i'th element read-only More...
 
bool operator== (const vector_type &_rhs) const
 component-wise comparison More...
 
bool operator!= (const vector_type &_rhs) const
 component-wise comparison More...
 
template<typename OtherScalar >
auto operator*= (const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0] *_s), Scalar >::value, VectorT< Scalar, DIM > & >::type
 component-wise self-multiplication with scalar More...
 
template<typename OtherScalar >
auto operator/= (const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0]/_s), Scalar >::value, VectorT< Scalar, DIM > & >::type
 component-wise self-division by scalar More...
 
VectorT< Scalar, DIM > ::type operator* (const OtherScalar &_s) const
 
VectorT< Scalar, DIM > ::type operator/ (const OtherScalar &_s) const
 
template<typename OtherScalar >
auto operator*= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0] **_rhs.data())) >=0
 component-wise self-multiplication
 
template<typename OtherScalar >
auto operator/= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0]/*_rhs.data())) >=0
 component-wise self-division
 
template<typename OtherScalar >
auto operator-= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0] - *_rhs.data())) >=0
 vector difference from this
 
template<typename OtherScalar >
auto operator+= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0]+ *_rhs.data())) >=0
 vector self-addition
 
template<typename OtherScalar >
auto operator* (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0] **_rhs.data())) >=0
 component-wise vector multiplication
 
template<typename OtherScalar >
auto operator/ (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0]/*_rhs.data())) >=0
 component-wise vector division
 
template<typename OtherScalar >
auto operator+ (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0]+ *_rhs.data())) >=0
 component-wise vector addition
 
template<typename OtherScalar >
auto operator- (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0] - *_rhs.data())) >=0
 component-wise vector difference
 
vector_type operator- (void) const
 unary minus More...
 
template<typename OtherScalar >
auto operator% (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< DIM==3, VectorT< decltype((*this)[0] *_rhs[0] -(*this)[0] *_rhs[0]), DIM > >::type
 
template<typename OtherScalar >
auto cross (const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this % _rhs)
 
template<typename OtherScalar >
auto operator| (const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this->data() **_rhs.data())
 
template<typename OtherScalar >
auto dot (const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this|_rhs)
 
VectorT< float, 3 > operator% (const VectorT< float, 3 > &_rhs) const
 cross product for Vec3f More...
 
VectorT< double, 3 > operator% (const VectorT< double, 3 > &_rhs) const
 cross product for Vec3d More...
 
template<typename S = Scalar>
decltype(std::declval< S >() *std::declval< S >()) sqrnorm () const
 compute squared euclidean norm More...
 
template<typename S = Scalar>
auto norm () const -> decltype(std::sqrt(std::declval< VectorT< S, DIM > >().sqrnorm()))
 compute euclidean norm More...
 
template<typename S = Scalar>
auto length () const -> decltype(std::declval< VectorT< S, DIM > >().norm())
 compute squared euclidean norm More...
 
template<typename S = Scalar>
auto normalize () -> decltype(*this/=std::declval< VectorT< S, DIM > >().norm())
 
template<typename S = Scalar>
auto normalized () const -> decltype(*this/std::declval< VectorT< S, DIM > >().norm())
 
vector_type &::type normalize_cond ()
 compute squared euclidean norm More...
 
Scalar l1_norm () const
 compute L1 (Manhattan) norm More...
 
Scalar l8_norm () const
 compute l8_norm More...
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rend () const noexcept
 
const_reverse_iterator crend () const noexcept
 
Scalar max () const
 return the maximal component More...
 
Scalar max_abs () const
 return the maximal absolute component More...
 
Scalar min () const
 return the minimal component More...
 
Scalar min_abs () const
 return the minimal absolute component More...
 
Scalar mean () const
 return arithmetic mean More...
 
Scalar mean_abs () const
 return absolute arithmetic mean More...
 
vector_typeminimize (const vector_type &_rhs)
 minimize values: same as *this = min(*this, _rhs), but faster More...
 
bool minimized (const vector_type &_rhs)
 minimize values and signalize coordinate minimization More...
 
vector_typemaximize (const vector_type &_rhs)
 maximize values: same as *this = max(*this, _rhs), but faster More...
 
bool maximized (const vector_type &_rhs)
 maximize values and signalize coordinate maximization More...
 
vector_type min (const vector_type &_rhs) const
 component-wise min More...
 
vector_type max (const vector_type &_rhs) const
 component-wise max More...
 
template<typename Functor >
vector_type apply (const Functor &_func) const
 component-wise apply function object with Scalar operator()(Scalar). More...
 
vector_typevectorize (const Scalar &_s)
 store the same value in each component (e.g. to clear all entries) More...
 
bool operator< (const vector_type &_rhs) const
 lexicographical comparison More...
 
void swap (VectorT &_other) noexcept(noexcept(std::swap(values_, _other.values_)))
 swap with another vector More...
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenMesh::VectorT< Scalar, DIM >
static constexpr int dim ()
 returns dimension of the vector (deprecated) More...
 
static constexpr size_t size ()
 returns dimension of the vector More...
 
static vector_type vectorized (const Scalar &_s)
 store the same value in each component More...
 
- Static Public Attributes inherited from OpenMesh::VectorT< Scalar, DIM >
static constexpr const size_t size_ = DIM
 

Detailed Description

template<class Scalar>
class ACG::QuaternionT< Scalar >

Quaternion class for representing rotations.

Definition at line 75 of file QuaternionT.hh.

Member Typedef Documentation

◆ Base

template<class Scalar >
typedef VectorT<Scalar,4> ACG::QuaternionT< Scalar >::Base

Definition at line 85 of file QuaternionT.hh.

◆ Matrix

template<class Scalar >
typedef Matrix4x4T<Scalar> ACG::QuaternionT< Scalar >::Matrix

Definition at line 89 of file QuaternionT.hh.

◆ Quaternion

template<class Scalar >
typedef QuaternionT<Scalar> ACG::QuaternionT< Scalar >::Quaternion

Definition at line 86 of file QuaternionT.hh.

◆ Vec3

template<class Scalar >
typedef VectorT<Scalar,3> ACG::QuaternionT< Scalar >::Vec3

Definition at line 87 of file QuaternionT.hh.

◆ Vec4

template<class Scalar >
typedef VectorT<Scalar,4> ACG::QuaternionT< Scalar >::Vec4

Definition at line 88 of file QuaternionT.hh.

Constructor & Destructor Documentation

◆ QuaternionT() [1/5]

template<class Scalar >
ACG::QuaternionT< Scalar >::QuaternionT ( Scalar  _w = 1.0,
Scalar  _x = 0.0,
Scalar  _y = 0.0,
Scalar  _z = 0.0 
)
inline

construct from 4 Scalars (default)

Definition at line 93 of file QuaternionT.hh.

◆ QuaternionT() [2/5]

template<class Scalar >
ACG::QuaternionT< Scalar >::QuaternionT ( const Vec3 _p)
inline

construct from 3D point (pure imaginary quaternion)

Definition at line 97 of file QuaternionT.hh.

◆ QuaternionT() [3/5]

template<class Scalar >
ACG::QuaternionT< Scalar >::QuaternionT ( const Vec4 _p)
inline

construct from 4D vector

Definition at line 101 of file QuaternionT.hh.

◆ QuaternionT() [4/5]

template<class Scalar >
ACG::QuaternionT< Scalar >::QuaternionT ( Vec3  _axis,
Scalar  _angle 
)
inline

construct from rotation axis and angle (in radians)

Definition at line 105 of file QuaternionT.hh.

◆ QuaternionT() [5/5]

template<class Scalar >
template<class MatrixT >
ACG::QuaternionT< Scalar >::QuaternionT ( const MatrixT &  _rot)
inline

construct from rotation matrix (only valid for rotation matrices!)

Definition at line 118 of file QuaternionT.hh.

Member Function Documentation

◆ axis_angle()

template<class Scalar >
void ACG::QuaternionT< Scalar >::axis_angle ( Vec3 _axis,
Scalar &  _angle 
) const
inline

get rotation axis and angle (only valid for unit quaternions!)

Definition at line 159 of file QuaternionT.hh.

◆ conjugate()

template<class Scalar >
Quaternion ACG::QuaternionT< Scalar >::conjugate ( ) const
inline

conjugate quaternion

Definition at line 127 of file QuaternionT.hh.

◆ exponential()

template<class Scalar >
Quaternion ACG::QuaternionT< Scalar >::exponential ( ) const
inline

quaternion exponential (for unit quaternions)

Definition at line 297 of file QuaternionT.hh.

◆ identity()

template<class Scalar >
void ACG::QuaternionT< Scalar >::identity ( )
inline

identity rotation

Definition at line 123 of file QuaternionT.hh.

◆ init_from_matrix()

template<class Scalar >
template<class MatrixT >
void ACG::QuaternionT< Scalar >::init_from_matrix ( const MatrixT &  _rot)
inline

get quaternion from rotation matrix

Definition at line 254 of file QuaternionT.hh.

◆ invert()

template<class Scalar >
Quaternion ACG::QuaternionT< Scalar >::invert ( ) const
inline

invert quaternion

Definition at line 132 of file QuaternionT.hh.

◆ left_mult_matrix()

template<class Scalar >
Matrix ACG::QuaternionT< Scalar >::left_mult_matrix ( ) const
inline

get matrix for mult from left (q*p = Qp)

Definition at line 241 of file QuaternionT.hh.

◆ logarithm()

template<class Scalar >
Quaternion ACG::QuaternionT< Scalar >::logarithm ( ) const
inline

quaternion logarithm (for unit quaternions)

Definition at line 314 of file QuaternionT.hh.

◆ operator*()

template<class Scalar >
Quaternion ACG::QuaternionT< Scalar >::operator* ( const Quaternion _q) const
inline

quaternion * quaternion

Definition at line 137 of file QuaternionT.hh.

◆ operator*=()

template<class Scalar >
Quaternion & ACG::QuaternionT< Scalar >::operator*= ( const Quaternion _q)
inline

quaternion *= quaternion

Definition at line 145 of file QuaternionT.hh.

◆ print_info()

template<class Scalar >
void ACG::QuaternionT< Scalar >::print_info ( )
inline

Definition at line 334 of file QuaternionT.hh.

◆ right_mult_matrix()

template<class Scalar >
Matrix ACG::QuaternionT< Scalar >::right_mult_matrix ( ) const
inline

get matrix for mult from right (p*q = Qp)

Definition at line 229 of file QuaternionT.hh.

◆ rotate()

template<class Scalar >
template<class Vec3T >
Vec3T ACG::QuaternionT< Scalar >::rotate ( const Vec3T &  _v) const
inline

rotate vector

Definition at line 151 of file QuaternionT.hh.

◆ rotation_matrix()

template<class Scalar >
Matrix ACG::QuaternionT< Scalar >::rotation_matrix ( ) const
inline

cast to rotation matrix

Definition at line 176 of file QuaternionT.hh.


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