libalmath  2.5.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
AL::Math::Quaternion Struct Reference

Create and play with a Quaternion. More...

#include <alquaternion.h>

Public Member Functions

 Quaternion ()
 Create a Quaternion initialize with 0.0f. More...
 
 Quaternion (float pW, float pX, float pY, float pZ)
 Create a Quaternion initialize with explicit value. More...
 
 Quaternion (const std::vector< float > &pFloats)
 Create a Quaternion with an std::vector. More...
 
Quaternionoperator*= (const Quaternion &pQua2)
 Overloading of operator *= for Quaternion. More...
 
Quaternion operator* (const Quaternion &pQua2) const
 Overloading of operator * for Quaternion. More...
 
bool operator== (const Quaternion &pQua2) const
 Overloading of operator == for Quaternion. More...
 
bool operator!= (const Quaternion &pQua2) const
 Overloading of operator != for Quaternion. More...
 
Quaternion operator* (float pVal) const
 Overloading of operator * for Quaternion. More...
 
Quaternion operator/ (float pVal) const
 Overloading of operator / for Quaternion. More...
 
Quaternionoperator*= (float pVal)
 Overloading of operator *= for Quaternion. More...
 
Quaternionoperator/= (float pVal)
 Overloading of operator /= for Quaternion. More...
 
bool isNear (const Quaternion &pQua2, const float &pEpsilon=0.0001f) const
 Check if the actual Quaternion is near the one give in argument. More...
 
float norm () const
 Compute the norm of the actual Quaternion. More...
 
Quaternion normalize () const
 Normalize the actual Quaterion. More...
 
Quaternion inverse () const
 Compute the quaternion inverse of the actual Quaternion More...
 
void toVector (std::vector< float > &pReturnVector) const
 Return the Quaternion as a vector of float [w, x, y, z]. More...
 
std::vector< float > toVector (void) const
 

Static Public Member Functions

static Quaternion fromAngleAndAxisRotation (const float pAngle, const float pAxisX, const float pAxisY, const float pAxisZ)
 Create a Quaternion initialized with explicit angle and axis rotation. More...
 

Public Attributes

float w
 
float x
 
float y
 
float z
 

Detailed Description

Create and play with a Quaternion.

A Quaternion is just defined by w, x, y and z.

Definition at line 23 of file alquaternion.h.

Constructor & Destructor Documentation

AL::Math::Quaternion::Quaternion ( )

Create a Quaternion initialize with 0.0f.

$ \left[\begin{array}{c} w \\ x \\ y \\ z \end{array}\right] = \left[\begin{array}{c} 0.0 \\ 0.0 \\ 0.0 \\ 0.0 \end{array}\right]$

AL::Math::Quaternion::Quaternion ( float  pW,
float  pX,
float  pY,
float  pZ 
)

Create a Quaternion initialize with explicit value.

$ \left[\begin{array}{c} w \\ x \\ y \\ z \end{array}\right] = \left[\begin{array}{c} pW \\ pX \\ pY \\ pZ \end{array}\right]$

Parameters
pWthe float value for w
pXthe float value for x
pYthe float value for y
pZthe float value for z
AL::Math::Quaternion::Quaternion ( const std::vector< float > &  pFloats)

Create a Quaternion with an std::vector.

$ \left[\begin{array}{c} w \\ x \\ y \\ z \end{array}\right] = \left[\begin{array}{c} pFloats[0] \\ pFloats[1] \\ pFloats[2] \\ pFloats[3] \end{array}\right]$

Parameters
pFloatsAn std::vector<float> of size 4 for respectively: w, x, y and z

Member Function Documentation

static Quaternion AL::Math::Quaternion::fromAngleAndAxisRotation ( const float  pAngle,
const float  pAxisX,
const float  pAxisY,
const float  pAxisZ 
)
static

Create a Quaternion initialized with explicit angle and axis rotation.

Parameters
pAnglethe float value for angle in radian around axis rotation
pAxisXthe float value for x value of axis rotation
pAxisYthe float value for y value of axis rotation
pAxisZthe float value for z value of axis rotation
Quaternion AL::Math::Quaternion::inverse ( ) const

Compute the quaternion inverse of the actual Quaternion

Returns
the Quaternion inverse
bool AL::Math::Quaternion::isNear ( const Quaternion pQua2,
const float &  pEpsilon = 0.0001f 
) const

Check if the actual Quaternion is near the one give in argument.

Parameters
pQua2the second Quaternion
pEpsilonan optionnal epsilon distance
Returns
true if the distance between the two Quaternion is less than pEpsilon Check if |Qua1+Qua2| < epsilon or |Qua1-Qua2| < epsilon
float AL::Math::Quaternion::norm ( ) const

Compute the norm of the actual Quaternion.

$\sqrt{pQua.w^2+pQua.x^2+pQua.y^2+pQua.z^2}$

Returns
the float norm of the Quaternion
Quaternion AL::Math::Quaternion::normalize ( ) const

Normalize the actual Quaterion.

$result = \frac{pQua}{norm(pQua)}$

Returns
the Quaternion normalized
bool AL::Math::Quaternion::operator!= ( const Quaternion pQua2) const

Overloading of operator != for Quaternion.

Parameters
pQua2the second Quaternion
Quaternion AL::Math::Quaternion::operator* ( const Quaternion pQua2) const
inline

Overloading of operator * for Quaternion.

Parameters
pQua2the second Quaternion

Definition at line 115 of file alquaternion.h.

Quaternion AL::Math::Quaternion::operator* ( float  pVal) const
inline

Overloading of operator * for Quaternion.

Parameters
pValthe float factor

Definition at line 140 of file alquaternion.h.

Quaternion& AL::Math::Quaternion::operator*= ( const Quaternion pQua2)

Overloading of operator *= for Quaternion.

Parameters
pQua2the second Quaternion
Quaternion& AL::Math::Quaternion::operator*= ( float  pVal)

Overloading of operator *= for Quaternion.

Parameters
pValthe float factor
Quaternion AL::Math::Quaternion::operator/ ( float  pVal) const

Overloading of operator / for Quaternion.

Parameters
pValthe float factor
Quaternion& AL::Math::Quaternion::operator/= ( float  pVal)

Overloading of operator /= for Quaternion.

Parameters
pValthe float factor
bool AL::Math::Quaternion::operator== ( const Quaternion pQua2) const

Overloading of operator == for Quaternion.

Parameters
pQua2the second Quaternion
void AL::Math::Quaternion::toVector ( std::vector< float > &  pReturnVector) const

Return the Quaternion as a vector of float [w, x, y, z].

std::vector<float> AL::Math::Quaternion::toVector ( void  ) const

Member Data Documentation

float AL::Math::Quaternion::w

Definition at line 25 of file alquaternion.h.

float AL::Math::Quaternion::x

Definition at line 27 of file alquaternion.h.

float AL::Math::Quaternion::y

Definition at line 29 of file alquaternion.h.

float AL::Math::Quaternion::z

Definition at line 31 of file alquaternion.h.


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