MorphoGraphX  2.0-1-227
Public Member Functions | List of all members
mgx::Quaternion Class Reference

#include <Quaternion.hpp>

+ Inheritance diagram for mgx::Quaternion:

Public Member Functions

 Quaternion ()
 Default constructor. More...
 
 Quaternion (const Point4d &other)
 Creates a quaternion from a Point4d. More...
 
 Quaternion (double x, double y, double z, double w)
 Creates a quaternion specified by its components. More...
 
 Quaternion (const Quaternion &other)
 Copy constructor. More...
 
 Quaternion (const Point3d &axis, double angle)
 Creates a Quaternion corresponding to an axis rotation. More...
 
 Quaternion (const Point3d &from, const Point3d &to)
 Creates the quaternion corresponding to the rotation transforming from into to. More...
 
 Quaternion (const Matrix3d &m)
 Creates the quaternion corresponding to the rotation matrix m. More...
 
Quaternionoperator= (const Quaternion &other)
 Assignment operator for quaternions. More...
 
void setAxisAngle (const Point3d &axis, double angle)
 Set the quaternion to the described rotation. More...
 
double & w ()
 Accessing the real part of the quaternion. More...
 
const double & w () const
 Accessing the real part of the quaternion. More...
 
Quaternionoperator+= (const Quaternion &other)
 Quaternion in-place addition. More...
 
Quaternion operator+ (const Quaternion &other) const
 Quaternion addition. More...
 
Quaternion operator* (const Quaternion &other) const
 Quaternion multiplication. More...
 
Quaternionoperator*= (const Quaternion &other)
 Quaternion in-place multiplication. More...
 
Quaternionoperator*= (double s)
 In-place multiplication of a quaternion by a scalar. More...
 
Quaternion inverse () const
 Return the quaternion corresponding to the inverse transform. More...
 
Quaternion conjugate () const
 Return the conjugate of the current quaternion. More...
 
Quaternionoperator/= (double v)
 Division of a quaternion by a real number. More...
 
Quaternion operator/ (double v) const
 Division of a quaternion by a real number. More...
 
void setMatrix (Matrix3d &m) const
 Fill the matrix as argument from the quaternion. More...
 
void setMatrix (Matrix4d &m) const
 Fill the matrix as argument from the quaternion. More...
 
Point3d axis () const
 Returns the axis of the rotation corresponding to this quaternion. More...
 
double angle () const
 Returns the angle of the rotation corresponding to this quaternion. More...
 
Point3d rotate (const Point3d &v) const
 Apply the rotation contained in this quaternion on the vector. More...
 
Point3d inverseRotate (const Point3d &v) const
 Apply the inverse of the rotation contained in this quaternion on the vector. More...
 
- Public Member Functions inherited from mgx::Vector< dim, T >
template<size_t d1, class T1 >
CU_HOST_DEVICE Vector (const Vector< d1, T1 > &vec)
 Copy another vector with different number of elements. More...
 
template<class Vec >
CU_HOST_DEVICE Vector (const Vec &el)
 Initialize a vector from any object behaving like an array. More...
 
CU_HOST_DEVICE Vector (const T &x=T())
 Initialize a vector with all values to x. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y)
 Initialize a 2D vector. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y, const T &z)
 Initialize a 3D vector. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y, const T &z, const T &t)
 Initialize a 4D vector. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y, const T &z, const T &a, const T &b)
 Initialize a 5D vector. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y, const T &z, const T &a, const T &b, const T &c)
 Initialize a 6D vector. More...
 
CU_HOST_DEVICE Vector (const T &x, const T &y, const T &z, const T &a, const T &b, const T &c, const T &d)
 Initialize a 7D vector. More...
 
CU_HOST_DEVICE Vector (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h)
 Initialize a 8D vector. More...
 
CU_HOST_DEVICE Vector (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i)
 Initialize a 9D vector. More...
 
CU_HOST_DEVICE Vector (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l)
 Initialize a 12D vector. More...
 
CU_HOST_DEVICE Vector (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const T &i, const T &j, const T &k, const T &l, const T &m, const T &n, const T &o, const T &p, const T &q, const T &r)
 Initialize a 18D vector. More...
 
CU_HOST_DEVICE T * data ()
 Returns a raw pointer on the data. More...
 
CU_HOST_DEVICE iterator begin ()
 STL-iteration begin. More...
 
CU_HOST_DEVICE const_iterator begin () const
 Stl-iteration constant begin. More...
 
CU_HOST_DEVICE iterator end ()
 STL-iteration end. More...
 
CU_HOST_DEVICE const_iterator end () const
 Stl-iteration constant end. More...
 
const CU_HOST_DEVICE T * c_data () const
 Returns a constant raw pointer on the data. More...
 
CU_HOST_DEVICE Vector operator- (void) const
 Vector negation. More...
 
CU_HOST_DEVICE Vector operator+ (const Vector &vec) const
 Vector addition. More...
 
CU_HOST_DEVICE Vector operator- (const Vector &vec) const
 Vector subtraction. More...
 
CU_HOST_DEVICE Vector mult (const Vector &vec) const
 Element-wise multiplcation. More...
 
CU_HOST_DEVICE Vector operator* (const T &scalar) const
 Multiplication by a scalar. More...
 
CU_HOST_DEVICE Vector operator/ (const T &scalar) const
 Division by a scalar. More...
 
CU_HOST_DEVICE Vector operator/ (const Vector &vec) const
 Element-wise division. More...
 
CU_HOST_DEVICE Vectoroperator/= (const Vector &vec)
 In-place element-wise division by a scalar. More...
 
CU_HOST_DEVICEoperator* (const Vector &vec) const
 Dot product. More...
 
CU_HOST_DEVICE Vectoroperator+= (const Vector &vec)
 Vector copy. More...
 
CU_HOST_DEVICE Vectoroperator+= (const T &val)
 In-place constant addition. More...
 
CU_HOST_DEVICE Vectoroperator-= (const Vector &vec)
 In-place vector subtraction. More...
 
CU_HOST_DEVICE Vectoroperator-= (const T &val)
 In-place value subtraction. More...
 
CU_HOST_DEVICE Vectoroperator*= (const T &scalar)
 In-place multiplication by a scalar. More...
 
template<typename T1 >
CU_HOST_DEVICE Vectoroperator*= (const T1 &scalar)
 In-place multiplication by a scalar. More...
 
CU_HOST_DEVICE Vectoroperator/= (const T &scalar)
 In-place division by a scalar. More...
 
template<typename T1 >
CU_HOST_DEVICE Vectoroperator/= (const T1 &scalar)
 In-place division by a scalar. More...
 
CU_HOST_DEVICE bool operator== (const Vector &vec) const
 Element-wise equality. More...
 
CU_HOST_DEVICE bool operator!= (const Vector &vec) const
 Element-wise inequality. More...
 
CU_HOST_DEVICE T & operator[] (size_t idx)
 Access to the element idx. More...
 
const CU_HOST_DEVICE T & operator[] (size_t idx) const
 Access to the element idx. More...
 
CU_HOST_DEVICEnorm () const
 Euclidean norm of the vector. More...
 
CU_HOST_DEVICEnormsq () const
 Square of the Euclidean norm of the vector. More...
 
CU_HOST_DEVICE Vectornormalize (void)
 Normalize the vector. More...
 
CU_HOST_DEVICE Vector normalized (void) const
 Returns a normalized version of the vector. More...
 
bool iszero (void)
 
Vectorzero (void)
 
CU_HOST_DEVICE void set (const T &x)
 Set the values of a 1-D vector. More...
 
CU_HOST_DEVICE void set (const T &x, const T &y)
 Set the values of a 2-D vector. More...
 
CU_HOST_DEVICE void set (const T &x, const T &y, const T &z)
 Set the values of a 3-D vector. More...
 
CU_HOST_DEVICE void set (const T &x, const T &y, const T &z, const T &t)
 Set the values of a 4-D vector. More...
 
CU_HOST_DEVICE Vectoroperator= (const T &value)
 Set all the elements to value. More...
 
CU_HOST_DEVICE Vector cross (const Vector &other) const
 Compute the cross product as this x other. More...
 
CU_HOST_DEVICE void x (const T &v)
 Short access to the first element. More...
 
CU_HOST_DEVICE void y (const T &v)
 Short access to the second element. More...
 
CU_HOST_DEVICE void z (const T &v)
 Short access to the third element. More...
 
CU_HOST_DEVICE void t (const T &v)
 Short access to the fourth element. More...
 
CU_HOST_DEVICE T & x ()
 Short access to the first element. More...
 
CU_HOST_DEVICE T & y ()
 Short access to the second element. More...
 
CU_HOST_DEVICE T & z ()
 Short access to the third element. More...
 
CU_HOST_DEVICE T & t ()
 Short access to the fourth element. More...
 
const CU_HOST_DEVICE T & x () const
 Short access to the first element. More...
 
const CU_HOST_DEVICE T & y () const
 Short access to the second element. More...
 
const CU_HOST_DEVICE T & z () const
 Short access to the third element. More...
 
const CU_HOST_DEVICE T & t () const
 Short access to the fourth element. More...
 
CU_HOST_DEVICE void i (const T &v)
 Short access to the first element. More...
 
CU_HOST_DEVICE void j (const T &v)
 Short access to the second element. More...
 
CU_HOST_DEVICE void k (const T &v)
 Short access to the third element. More...
 
CU_HOST_DEVICE void l (const T &v)
 Short access to the fourth element. More...
 
CU_HOST_DEVICE T & i ()
 Short access to the first element. More...
 
CU_HOST_DEVICE T & j ()
 Short access to the second element. More...
 
CU_HOST_DEVICE T & k ()
 Short access to the third element. More...
 
CU_HOST_DEVICE T & l ()
 Short access to the fourth element. More...
 
const CU_HOST_DEVICE T & i () const
 Short access to the first element. More...
 
const CU_HOST_DEVICE T & j () const
 Short access to the second element. More...
 
const CU_HOST_DEVICE T & k () const
 Short access to the third element. More...
 
const CU_HOST_DEVICE T & l () const
 Short access to the fourth element. More...
 
CU_HOST_DEVICE Vector< 2, T > projectXY (void)
 Extract the two first elements of the vector. More...
 
CU_HOST_DEVICE bool operator< (const Vector &other) const
 Comparison operator. More...
 
CU_HOST_DEVICE bool operator<= (const Vector &other) const
 Comparison operator. More...
 
CU_HOST_DEVICE bool operator> (const Vector &other) const
 Comparison operator. More...
 
CU_HOST_DEVICE bool operator>= (const Vector &other) const
 Comparison operator. More...
 

Additional Inherited Members

- Public Types inherited from mgx::Vector< dim, T >
typedef T value_type
 
typedef T & reference_type
 
typedef T * pointer_type
 
typedef T * iterator
 
- Static Public Member Functions inherited from mgx::Vector< dim, T >
static CU_HOST_DEVICE size_t size ()
 Returns the size of the vector (i.e. More...
 
- Public Attributes inherited from mgx::Vector< dim, T >
const typedef T & const_reference_type
 
const typedef T * const_pointer_type
 
const typedef T * const_iterator
 
- Static Public Attributes inherited from mgx::Vector< dim, T >
static const size_t numElems
 
- Protected Attributes inherited from mgx::Vector< dim, T >
elems [dim]
 

Detailed Description

Implements the quaternion operations

Definition at line 29 of file Quaternion.hpp.

Constructor & Destructor Documentation

◆ Quaternion() [1/7]

mgx::Quaternion::Quaternion ( )
inline

Default constructor.

Provides an identity quaternion FIXME Shouldn't this be 0?

Definition at line 35 of file Quaternion.hpp.

◆ Quaternion() [2/7]

mgx::Quaternion::Quaternion ( const Point4d other)
inline

Creates a quaternion from a Point4d.

Definition at line 40 of file Quaternion.hpp.

◆ Quaternion() [3/7]

mgx::Quaternion::Quaternion ( double  x,
double  y,
double  z,
double  w 
)
inline

Creates a quaternion specified by its components.

Definition at line 45 of file Quaternion.hpp.

◆ Quaternion() [4/7]

mgx::Quaternion::Quaternion ( const Quaternion other)
inline

Copy constructor.

Definition at line 50 of file Quaternion.hpp.

◆ Quaternion() [5/7]

mgx::Quaternion::Quaternion ( const Point3d axis,
double  angle 
)

Creates a Quaternion corresponding to an axis rotation.

Parameters
axisAxis of the rotation. It needs not be normalized before hand. If it is null, then the Quaternion will correspond to the identity matrix.
angleAngle of the rotation.

◆ Quaternion() [6/7]

mgx::Quaternion::Quaternion ( const Point3d from,
const Point3d to 
)

Creates the quaternion corresponding to the rotation transforming from into to.

◆ Quaternion() [7/7]

mgx::Quaternion::Quaternion ( const Matrix3d m)

Creates the quaternion corresponding to the rotation matrix m.

Member Function Documentation

◆ angle()

double mgx::Quaternion::angle ( ) const

Returns the angle of the rotation corresponding to this quaternion.

◆ axis()

Point3d mgx::Quaternion::axis ( ) const

Returns the axis of the rotation corresponding to this quaternion.

◆ conjugate()

Quaternion mgx::Quaternion::conjugate ( ) const
inline

Return the conjugate of the current quaternion.

Definition at line 145 of file Quaternion.hpp.

◆ inverse()

Quaternion mgx::Quaternion::inverse ( ) const
inline

Return the quaternion corresponding to the inverse transform.

Definition at line 136 of file Quaternion.hpp.

◆ inverseRotate()

Point3d mgx::Quaternion::inverseRotate ( const Point3d v) const

Apply the inverse of the rotation contained in this quaternion on the vector.

It is identical to calling this->inverse().rotate()

◆ operator*()

Quaternion mgx::Quaternion::operator* ( const Quaternion other) const

Quaternion multiplication.

◆ operator*=() [1/2]

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

Quaternion in-place multiplication.

◆ operator*=() [2/2]

Quaternion& mgx::Quaternion::operator*= ( double  s)
inline

In-place multiplication of a quaternion by a scalar.

Definition at line 126 of file Quaternion.hpp.

◆ operator+()

Quaternion mgx::Quaternion::operator+ ( const Quaternion other) const
inline

Quaternion addition.

Definition at line 107 of file Quaternion.hpp.

◆ operator+=()

Quaternion& mgx::Quaternion::operator+= ( const Quaternion other)
inline

Quaternion in-place addition.

Definition at line 97 of file Quaternion.hpp.

◆ operator/()

Quaternion mgx::Quaternion::operator/ ( double  v) const
inline

Division of a quaternion by a real number.

Definition at line 162 of file Quaternion.hpp.

◆ operator/=()

Quaternion& mgx::Quaternion::operator/= ( double  v)
inline

Division of a quaternion by a real number.

Definition at line 152 of file Quaternion.hpp.

◆ operator=()

Quaternion& mgx::Quaternion::operator= ( const Quaternion other)

Assignment operator for quaternions.

◆ rotate()

Point3d mgx::Quaternion::rotate ( const Point3d v) const

Apply the rotation contained in this quaternion on the vector.

◆ setAxisAngle()

void mgx::Quaternion::setAxisAngle ( const Point3d axis,
double  angle 
)

Set the quaternion to the described rotation.

Parameters
axisAxis of the rotation
angleAngle of the rotation

◆ setMatrix() [1/2]

void mgx::Quaternion::setMatrix ( Matrix3d m) const

Fill the matrix as argument from the quaternion.

Multiplying with this matrix is equivalent to performing a rotation with this quaternion.

◆ setMatrix() [2/2]

void mgx::Quaternion::setMatrix ( Matrix4d m) const

Fill the matrix as argument from the quaternion.

Multiplying with this matrix is equivalent to performing a rotation with this quaternion.

◆ w() [1/2]

double& mgx::Quaternion::w ( )
inline

Accessing the real part of the quaternion.

Definition at line 88 of file Quaternion.hpp.

◆ w() [2/2]

const double& mgx::Quaternion::w ( ) const
inline

Accessing the real part of the quaternion.

Definition at line 92 of file Quaternion.hpp.


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