[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

Quaternion< ValueType > Class Template Reference

#include <vigra/quaternion.hxx>

Public Types

typedef ValueType const & const_reference
 
typedef NormTraits< ValueType >::NormType NormType
 
typedef ValueType & reference
 
typedef NormTraits< ValueType >::SquaredNormType SquaredNormType
 
typedef ValueType value_type
 

Public Member Functions

template<class MatrixType>
void fillRotationMatrix (MatrixType &matrix) const
 
NormType magnitude () const
 
bool operator!= (Quaternion const &other) const
 
Quaternionoperator*= (double scale)
 
Quaternionoperator*= (Quaternion const &other)
 
Quaternion operator+ () const
 
Quaternionoperator+= (Quaternion const &other)
 
Quaternionoperator+= (value_type const &w)
 
Quaternion operator- () const
 
Quaternionoperator-= (Quaternion const &other)
 
Quaternionoperator-= (value_type const &w)
 
Quaternionoperator/= (double scale)
 
Quaternionoperator/= (Quaternion const &other)
 
Quaternionoperator= (Quaternion const &other)
 
Quaternionoperator= (ValueType w)
 
bool operator== (Quaternion const &other) const
 
value_typeoperator[] (int index)
 
value_type operator[] (int index) const
 
 Quaternion (const Quaternion &q)
 
 Quaternion (ValueType w, const Vector &v)
 
 Quaternion (ValueType w=0, ValueType x=0, ValueType y=0, ValueType z=0)
 
void setV (const Vector &v)
 
void setV (ValueType x, ValueType y, ValueType z)
 
void setW (ValueType w)
 
SquaredNormType squaredMagnitude () const
 
Vectorv ()
 
const Vectorv () const
 
ValueType & w ()
 
ValueType w () const
 

Static Public Member Functions

static Quaternion createRotation (double angle, const Vector &rotationAxis)
 

Detailed Description

template<class ValueType>
class vigra::Quaternion< ValueType >

Quaternion class.

Quaternions are mainly used as a compact representation for 3D rotations because they are much less prone to round-off errors than rotation matrices, especially when many rotations are concatenated. In addition, the angle/axis interpretation of normalized quaternions is very intuitive. Read the Wikipedia entry on quaternions for more information on the mathematics.

See also: Quaternion Operations

Member Typedef Documentation

◆ value_type

template<class ValueType>
typedef ValueType value_type

the quaternion's valuetype

◆ reference

template<class ValueType>
typedef ValueType& reference

reference (return of operator[]).

◆ const_reference

template<class ValueType>
typedef ValueType const& const_reference

const reference (return of operator[] const).

◆ SquaredNormType

template<class ValueType>
typedef NormTraits<ValueType>::SquaredNormType SquaredNormType

the quaternion's squared norm type

◆ NormType

template<class ValueType>
typedef NormTraits<ValueType>::NormType NormType

the quaternion's norm type

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

template<class ValueType>
Quaternion ( ValueType w = 0,
ValueType x = 0,
ValueType y = 0,
ValueType z = 0 )

Construct a quaternion with explicit values for the real and imaginary parts.

◆ Quaternion() [2/3]

template<class ValueType>
Quaternion ( ValueType w,
const Vector & v )

Construct a quaternion with real value and imaginary vector.

Equivalent to Quaternion(w, v[0], v[1], v[2]).

◆ Quaternion() [3/3]

template<class ValueType>
Quaternion ( const Quaternion< ValueType > & q)

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

template<class ValueType>
Quaternion & operator= ( Quaternion< ValueType > const & other)

Copy assignment.

◆ operator=() [2/2]

template<class ValueType>
Quaternion & operator= ( ValueType w)

Assign w to the real part and set the imaginary part to zero.

◆ createRotation()

template<class ValueType>
static Quaternion createRotation ( double angle,
const Vector & rotationAxis )
static

Creates a Quaternion which represents the operation of rotating around the given axis by the given angle.

The angle should be in the range -pi..3*pi for sensible results.

◆ w() [1/2]

template<class ValueType>
ValueType w ( ) const

Read real part.

◆ w() [2/2]

template<class ValueType>
ValueType & w ( )

Access real part.

◆ setW()

template<class ValueType>
void setW ( ValueType w)

Set real part.

◆ v() [1/2]

template<class ValueType>
const Vector & v ( ) const

Read imaginary part.

◆ v() [2/2]

template<class ValueType>
Vector & v ( )

Access imaginary part.

◆ setV() [1/2]

template<class ValueType>
void setV ( const Vector & v)

Set imaginary part.

◆ setV() [2/2]

template<class ValueType>
void setV ( ValueType x,
ValueType y,
ValueType z )

Set imaginary part.

◆ operator[]() [1/2]

template<class ValueType>
value_type & operator[] ( int index)

Access entry at index (0 <=> w(), 1 <=> v[0] etc.).

◆ operator[]() [2/2]

template<class ValueType>
value_type operator[] ( int index) const

Read entry at index (0 <=> w(), 1 <=> v[0] etc.).

◆ magnitude()

template<class ValueType>
NormType magnitude ( ) const

Magnitude.

◆ squaredMagnitude()

template<class ValueType>
SquaredNormType squaredMagnitude ( ) const

Squared magnitude.

◆ operator+=() [1/2]

template<class ValueType>
Quaternion & operator+= ( value_type const & w)

Add w to the real part.

If the quaternion represents a rotation, the rotation angle is increased by w.

◆ operator+=() [2/2]

template<class ValueType>
Quaternion & operator+= ( Quaternion< ValueType > const & other)

Add assigment.

◆ operator-=() [1/2]

template<class ValueType>
Quaternion & operator-= ( value_type const & w)

Subtract w from the real part.

If the quaternion represents a rotation, the rotation angle is decreased by w.

◆ operator-=() [2/2]

template<class ValueType>
Quaternion & operator-= ( Quaternion< ValueType > const & other)

Subtract assigment.

◆ operator+()

template<class ValueType>
Quaternion operator+ ( ) const

Addition.

◆ operator-()

template<class ValueType>
Quaternion operator- ( ) const

Subtraction.

◆ operator*=() [1/2]

template<class ValueType>
Quaternion & operator*= ( Quaternion< ValueType > const & other)

Multiply assignment.

If the quaternions represent rotations, the rotations of this and other are concatenated.

◆ operator*=() [2/2]

template<class ValueType>
Quaternion & operator*= ( double scale)

Multiply all entries with the scalar scale.

◆ operator/=() [1/2]

template<class ValueType>
Quaternion & operator/= ( Quaternion< ValueType > const & other)

Divide assignment.

◆ operator/=() [2/2]

template<class ValueType>
Quaternion & operator/= ( double scale)

Devide all entries by the scalar scale.

◆ operator==()

template<class ValueType>
bool operator== ( Quaternion< ValueType > const & other) const

Equal.

◆ operator!=()

template<class ValueType>
bool operator!= ( Quaternion< ValueType > const & other) const

Not equal.

◆ fillRotationMatrix()

template<class ValueType>
template<class MatrixType>
void fillRotationMatrix ( MatrixType & matrix) const

Fill the first 3x3 elements of the given matrix with a rotation matrix performing the same 3D rotation as this quaternion. If matrix is in column-major format, it should be pre-multiplied with the vectors to be rotated, i.e. matrix[0][0-3] will be the rotated X axis.


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

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.12.2 (Mon Apr 14 2025)