cpe::quaternion Class Reference

Quaternion class. More...

+ Inheritance diagram for cpe::quaternion:
+ Collaboration diagram for cpe::quaternion:

Public Member Functions

 quaternion ()
 default constructor More...
 
 quaternion (const vec3 &axis, const double &angle)
 constructor from axis and angle More...
 
 quaternion (const vec4 &v)
 direct constructor More...
 
 quaternion (const double &x, const double &y, const double &z, const double &w)
 direct constructor More...
 
vec3 axis () const
 get the unit axis corresponding to the quaternion More...
 
double angle () const
 get the angle corresponding to the quaternion More...
 
matrix3 matrix () const
 compute the rotation matrix associated to the current quaternion More...
 
quaternion conjugated () const
 get the conjugate of the current quaterion More...
 
vec3 rotate (const vec3 &vec) const
 apply a rotation (encoded by the quaternion) to the vector/point 3D More...
 
quaternionoperator*= (const quaternion &q)
 internal multiplication by other quaternion More...
 
quaternionoperator*= (const double &s)
 internal multiplication by a scalar More...
 
quaternionoperator+= (const quaternion &q)
 internal addition with other quaternion More...
 
quaternionoperator-= (const quaternion &q)
 internal substraction with other quaternion More...
 
quaternionoperator/= (const double &s)
 internal division by a scalar More...
 
quaternion operator* (const quaternion &q) const
 multiplication by other quaternion More...
 
quaternion operator* (const vec3 &v) const
 multiplication with a v3 seen as a quaternion (v.w()=0) More...
 
quaternion operator* (const double &s) const
 multiplication with scalar More...
 
quaternion operator+ (const quaternion &q) const
 addition with other quaternionn More...
 
quaternion operator- (const quaternion &q) const
 substraction with other quaternionn More...
 
quaternion operator/ (const double &s) const
 division by a scalar More...
 
quaternion operator- () const
 unary negation More...
 
- Public Member Functions inherited from cpe::vec4
 vec4 ()
 empty constructor More...
 
 vec4 (const double &x, const double &y, const double &z, const double &w)
 direct constructor More...
 
const double & x () const
 get x coordinate More...
 
double & x ()
 get x coordinate More...
 
const double & y () const
 get y coordinate More...
 
double & y ()
 get y coordinate More...
 
const double & z () const
 get z coordinate More...
 
double & z ()
 get z coordinate More...
 
const double & w () const
 get w coordinate More...
 
double & w ()
 get w coordinate More...
 
const double & operator[] (const size_t &k) const
 Access to the k_th entry (k in [0,3]) More...
 
double & operator[] (const size_t &k)
 Access to the k_th entry (k in [0,3]) More...
 
const double & operator() (const size_t &k) const
 Access to the k_th entry (k in [0,3]) More...
 
double & operator() (const size_t &k)
 Access to the k_th entry (k in [0,3]) More...
 
void set_zero ()
 set every entry to 0 More...
 
const double * pointer () const
 fast pointer access More...
 
vec3 to_vec3 () const
 convert to v3 (x,y,z) More...
 
vec2 to_vec2 () const
 convert to v2 (x,y) More...
 
double dot (const vec4 &p) const
 perform dot product between two v4 More...
 
double norm () const
 get the norm of the vector More...
 
double norm2 () const
 get the square norm of the vector More...
 
vec4 normalized () const
 normalize the vector to unit length More...
 
vec4 operator+ (const vec4 &p2) const
 
  • operator
More...
 
vec4 operator+ (const double &s) const
 
  • operator
More...
 
vec4 operator- (const vec4 &p2) const
 
  • operator
More...
 
vec4 operator- (const double &s) const
 
  • operator
More...
 
vec4 operator* (const double &s) const
 multiply by a scalar operator More...
 
vec4 operator/ (const double &s) const
 divide by a scalar operator More...
 
vec4operator+= (const vec4 &p)
 internal + More...
 
vec4operator+= (const double &s)
 internal + More...
 
vec4operator-= (const vec4 &p)
 internal - More...
 
vec4operator-= (const double &s)
 internal - More...
 
vec4operator*= (const double &s)
 internal * More...
 
vec4operator/= (const double &s)
 internal / More...
 
vec4 operator- () const
 unary negation More...
 
vec4 product_compontentwise (const vec4 &p) const
 does componentwise mutliplication More...
 
vec4product_compontentwise_internal (const vec4 &p)
 does componentwise mutliplication More...
 
void scale (const double &sx, const double &sy, const double &sz, const double &sw)
 internal scaling (similar to componentwise) More...
 
std::string to_string () const
 export the value as string cout<<v4(2,3,6,7) => 2 3 6 7 More...
 

Static Public Member Functions

static quaternion slerp (const quaternion &q0, const quaternion &q1, const double alpha)
 Spherical Linear Interpolation SLERP. More...
 

Detailed Description

Quaternion class.

Constructor & Destructor Documentation

cpe::quaternion::quaternion ( )

default constructor

Referenced by conjugated(), operator*(), operator*=(), and operator-().

cpe::quaternion::quaternion ( const vec3 axis,
const double &  angle 
)

constructor from axis and angle

References cpe::vec3::normalized(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

cpe::quaternion::quaternion ( const vec4 v)

direct constructor

cpe::quaternion::quaternion ( const double &  x,
const double &  y,
const double &  z,
const double &  w 
)

direct constructor

Member Function Documentation

double cpe::quaternion::angle ( ) const

get the angle corresponding to the quaternion

References cpe::vec4::w().

+ Here is the call graph for this function:

vec3 cpe::quaternion::axis ( ) const

get the unit axis corresponding to the quaternion

References cpe::vec3::normalized(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::conjugated ( ) const

get the conjugate of the current quaterion

References quaternion(), cpe::vec4::vec4(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

matrix3 cpe::quaternion::matrix ( ) const

compute the rotation matrix associated to the current quaternion

Returns
a 3x3 rotation matrix

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::operator* ( const quaternion q) const

multiplication by other quaternion

quaternion cpe::quaternion::operator* ( const vec3 v) const

multiplication with a v3 seen as a quaternion (v.w()=0)

References quaternion(), cpe::vec4::w(), cpe::vec3::x(), cpe::vec4::x(), cpe::vec3::y(), cpe::vec4::y(), cpe::vec3::z(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::operator* ( const double &  s) const

multiplication with scalar

quaternion & cpe::quaternion::operator*= ( const quaternion q)

internal multiplication by other quaternion

References quaternion(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion & cpe::quaternion::operator*= ( const double &  s)

internal multiplication by a scalar

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::operator+ ( const quaternion q) const

addition with other quaternionn

quaternion & cpe::quaternion::operator+= ( const quaternion q)

internal addition with other quaternion

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::operator- ( const quaternion q) const

substraction with other quaternionn

quaternion cpe::quaternion::operator- ( ) const

unary negation

References quaternion(), cpe::vec4::vec4(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion & cpe::quaternion::operator-= ( const quaternion q)

internal substraction with other quaternion

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::operator/ ( const double &  s) const

division by a scalar

quaternion & cpe::quaternion::operator/= ( const double &  s)

internal division by a scalar

References cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:

vec3 cpe::quaternion::rotate ( const vec3 vec) const

apply a rotation (encoded by the quaternion) to the vector/point 3D

References cpe::vec4::w(), cpe::vec3::x(), cpe::vec4::x(), cpe::vec3::y(), cpe::vec4::y(), cpe::vec3::z(), and cpe::vec4::z().

+ Here is the call graph for this function:

quaternion cpe::quaternion::slerp ( const quaternion q0,
const quaternion q1,
const double  alpha 
)
static

Spherical Linear Interpolation SLERP.

Use (sin((1-t) theta )q0 +sin(t theta)q1)/sin(theta) But same results with (q1 q0^{-1})^{t} q0 (q1*q0.invert()).pow_q(t)*q0)

References cpe::vec4::dot(), cpe::vec4::norm(), cpe::vec4::w(), cpe::vec4::x(), cpe::vec4::y(), and cpe::vec4::z().

+ Here is the call graph for this function:


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