NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nc::rotations::Quaternion Class Reference

Holds a unit quaternion. More...

#include <Quaternion.hpp>

Public Member Functions

 Quaternion ()=default
 
 Quaternion (const NdArray< double > &inArray)
 
 Quaternion (const NdArray< double > &inAxis, double inAngle)
 
 Quaternion (const std::array< double, 4 > &components) noexcept
 
 Quaternion (const Vec3 &inAxis, double inAngle) noexcept
 
 Quaternion (double inI, double inJ, double inK, double inS) noexcept
 
 Quaternion (double roll, double pitch, double yaw) noexcept
 
double angleOfRotation () const noexcept
 
NdArray< double > angularVelocity (const Quaternion &inQuat2, double inTime) const
 
Vec3 axisOfRotation () const noexcept
 
Quaternion conjugate () const noexcept
 
double i () const noexcept
 
Quaternion inverse () const noexcept
 
double j () const noexcept
 
double k () const noexcept
 
Quaternion nlerp (const Quaternion &inQuat2, double inPercent) const
 
bool operator!= (const Quaternion &inRhs) const noexcept
 
NdArray< double > operator* (const NdArray< double > &inVec) const
 
Quaternion operator* (const Quaternion &inRhs) const noexcept
 
Vec3 operator* (const Vec3 &inVec3) const
 
Quaternion operator* (double inScalar) const noexcept
 
Quaternionoperator*= (const Quaternion &inRhs) noexcept
 
Quaternionoperator*= (double inScalar) noexcept
 
Quaternion operator+ (const Quaternion &inRhs) const noexcept
 
Quaternionoperator+= (const Quaternion &inRhs) noexcept
 
Quaternion operator- () const noexcept
 
Quaternion operator- (const Quaternion &inRhs) const noexcept
 
Quaternionoperator-= (const Quaternion &inRhs) noexcept
 
Quaternion operator/ (const Quaternion &inRhs) const noexcept
 
Quaternionoperator/= (const Quaternion &inRhs) noexcept
 
bool operator== (const Quaternion &inRhs) const noexcept
 
double pitch () const noexcept
 
void print () const
 
double roll () const noexcept
 
NdArray< double > rotate (const NdArray< double > &inVector) const
 
Vec3 rotate (const Vec3 &inVec3) const
 
double s () const noexcept
 
Quaternion slerp (const Quaternion &inQuat2, double inPercent) const
 
std::string str () const
 
NdArray< double > toDCM () const
 
NdArray< double > toNdArray () const
 
double yaw () const noexcept
 

Static Public Member Functions

static NdArray< double > angularVelocity (const Quaternion &inQuat1, const Quaternion &inQuat2, double inTime)
 
static Quaternion identity () noexcept
 
static Quaternion nlerp (const Quaternion &inQuat1, const Quaternion &inQuat2, double inPercent)
 
static Quaternion pitchRotation (double inAngle) noexcept
 
static Quaternion rollRotation (double inAngle) noexcept
 
static Quaternion slerp (const Quaternion &inQuat1, const Quaternion &inQuat2, double inPercent)
 
static Quaternion xRotation (double inAngle) noexcept
 
static Quaternion yawRotation (double inAngle) noexcept
 
static Quaternion yRotation (double inAngle) noexcept
 
static Quaternion zRotation (double inAngle) noexcept
 

Friends

std::ostream & operator<< (std::ostream &inOStream, const Quaternion &inQuat)
 

Detailed Description

Holds a unit quaternion.

Constructor & Destructor Documentation

◆ Quaternion() [1/7]

nc::rotations::Quaternion::Quaternion ( )
default

Default Constructor

◆ Quaternion() [2/7]

nc::rotations::Quaternion::Quaternion ( double  roll,
double  pitch,
double  yaw 
)
inlinenoexcept

Constructor

Parameters
rolleuler roll angle in radians
pitcheuler pitch angle in radians
yaweuler yaw angle in radians

◆ Quaternion() [3/7]

nc::rotations::Quaternion::Quaternion ( double  inI,
double  inJ,
double  inK,
double  inS 
)
inlinenoexcept

Constructor

Parameters
inI
inJ
inK
inS

◆ Quaternion() [4/7]

nc::rotations::Quaternion::Quaternion ( const std::array< double, 4 > &  components)
inlinenoexcept

Constructor

Parameters
components

◆ Quaternion() [5/7]

nc::rotations::Quaternion::Quaternion ( const NdArray< double > &  inArray)
inline

Constructor

Parameters
inArrayif size = 3 the roll, pitch, yaw euler angles if size = 4 the i, j, k, s components if shape = [3, 3] then direction cosine matrix

◆ Quaternion() [6/7]

nc::rotations::Quaternion::Quaternion ( const Vec3 inAxis,
double  inAngle 
)
inlinenoexcept

Constructor

Parameters
inAxisEuler axis
inAngleEuler angle in radians

◆ Quaternion() [7/7]

nc::rotations::Quaternion::Quaternion ( const NdArray< double > &  inAxis,
double  inAngle 
)
inline

Constructor

Parameters
inAxisEuler axis x,y,z vector components
inAngleEuler angle in radians

Member Function Documentation

◆ angleOfRotation()

double nc::rotations::Quaternion::angleOfRotation ( ) const
inlinenoexcept

the angle of rotation around the rotation axis that is described by the quaternion

Returns
radians

◆ angularVelocity() [1/2]

static NdArray< double > nc::rotations::Quaternion::angularVelocity ( const Quaternion inQuat1,
const Quaternion inQuat2,
double  inTime 
)
inlinestatic

angular velocity vector between the two quaternions. The norm of the array is the magnitude

Parameters
inQuat1
inQuat2
inTime(seperation time)
Returns
NdArray<double>

◆ angularVelocity() [2/2]

NdArray< double > nc::rotations::Quaternion::angularVelocity ( const Quaternion inQuat2,
double  inTime 
) const
inline

angular velocity vector between the two quaternions. The norm of the array is the magnitude

Parameters
inQuat2
inTime(seperation time)
Returns
NdArray<double>

◆ axisOfRotation()

Vec3 nc::rotations::Quaternion::axisOfRotation ( ) const
inlinenoexcept

the axis of rotation described by the quaternion

Returns
Vec3

◆ conjugate()

Quaternion nc::rotations::Quaternion::conjugate ( ) const
inlinenoexcept

quaternion conjugate

Returns
Quaternion

◆ i()

double nc::rotations::Quaternion::i ( ) const
inlinenoexcept

returns the i component

Returns
double

◆ identity()

static Quaternion nc::rotations::Quaternion::identity ( )
inlinestaticnoexcept

quaternion identity (0,0,0,1)

Returns
Quaternion

◆ inverse()

Quaternion nc::rotations::Quaternion::inverse ( ) const
inlinenoexcept

quaternion inverse

Returns
Quaterion

◆ j()

double nc::rotations::Quaternion::j ( ) const
inlinenoexcept

returns the j component

Returns
double

◆ k()

double nc::rotations::Quaternion::k ( ) const
inlinenoexcept

returns the k component

Returns
double

◆ nlerp() [1/2]

static Quaternion nc::rotations::Quaternion::nlerp ( const Quaternion inQuat1,
const Quaternion inQuat2,
double  inPercent 
)
inlinestatic

linearly interpolates between the two quaternions

Parameters
inQuat1
inQuat2
inPercent[0, 1]
Returns
Quaternion

◆ nlerp() [2/2]

Quaternion nc::rotations::Quaternion::nlerp ( const Quaternion inQuat2,
double  inPercent 
) const
inline

linearly interpolates between the two quaternions

Parameters
inQuat2
inPercent(0, 1)
Returns
Quaternion

◆ operator!=()

bool nc::rotations::Quaternion::operator!= ( const Quaternion inRhs) const
inlinenoexcept

equality operator

Parameters
inRhs
Returns
bool

◆ operator*() [1/4]

NdArray< double > nc::rotations::Quaternion::operator* ( const NdArray< double > &  inVec) const
inline

multiplication operator

Parameters
inVec
Returns
NdArray<double>

◆ operator*() [2/4]

Quaternion nc::rotations::Quaternion::operator* ( const Quaternion inRhs) const
inlinenoexcept

multiplication operator

Parameters
inRhs
Returns
Quaternion

◆ operator*() [3/4]

Vec3 nc::rotations::Quaternion::operator* ( const Vec3 inVec3) const
inline

multiplication operator

Parameters
inVec3
Returns
Vec3

◆ operator*() [4/4]

Quaternion nc::rotations::Quaternion::operator* ( double  inScalar) const
inlinenoexcept

multiplication operator, only useful for multiplying by negative 1, all others will be renormalized back out

Parameters
inScalar
Returns
Quaternion

◆ operator*=() [1/2]

Quaternion & nc::rotations::Quaternion::operator*= ( const Quaternion inRhs)
inlinenoexcept

multiplication assignment operator

Parameters
inRhs
Returns
Quaternion

◆ operator*=() [2/2]

Quaternion & nc::rotations::Quaternion::operator*= ( double  inScalar)
inlinenoexcept

multiplication operator, only useful for multiplying by negative 1, all others will be renormalized back out

Parameters
inScalar
Returns
Quaternion

◆ operator+()

Quaternion nc::rotations::Quaternion::operator+ ( const Quaternion inRhs) const
inlinenoexcept

addition operator

Parameters
inRhs
Returns
Quaternion

◆ operator+=()

Quaternion & nc::rotations::Quaternion::operator+= ( const Quaternion inRhs)
inlinenoexcept

addition assignment operator

Parameters
inRhs
Returns
Quaternion

◆ operator-() [1/2]

Quaternion nc::rotations::Quaternion::operator- ( ) const
inlinenoexcept

negative operator

Returns
Quaternion

◆ operator-() [2/2]

Quaternion nc::rotations::Quaternion::operator- ( const Quaternion inRhs) const
inlinenoexcept

subtraction operator

Parameters
inRhs
Returns
Quaternion

◆ operator-=()

Quaternion & nc::rotations::Quaternion::operator-= ( const Quaternion inRhs)
inlinenoexcept

subtraction assignment operator

Parameters
inRhs
Returns
Quaternion

◆ operator/()

Quaternion nc::rotations::Quaternion::operator/ ( const Quaternion inRhs) const
inlinenoexcept

division operator

Parameters
inRhs
Returns
Quaternion

◆ operator/=()

Quaternion & nc::rotations::Quaternion::operator/= ( const Quaternion inRhs)
inlinenoexcept

division assignment operator

Parameters
inRhs
Returns
Quaternion

◆ operator==()

bool nc::rotations::Quaternion::operator== ( const Quaternion inRhs) const
inlinenoexcept

equality operator

Parameters
inRhs
Returns
bool

◆ pitch()

double nc::rotations::Quaternion::pitch ( ) const
inlinenoexcept

The euler pitch angle in radians

Returns
euler pitch angle in radians

◆ pitchRotation()

static Quaternion nc::rotations::Quaternion::pitchRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the pitch axis

Parameters
inAngle(radians)
Returns
Quaternion

◆ print()

void nc::rotations::Quaternion::print ( ) const
inline

prints the Quaternion to the console

◆ roll()

double nc::rotations::Quaternion::roll ( ) const
inlinenoexcept

The euler roll angle in radians

Returns
euler roll angle in radians

◆ rollRotation()

static Quaternion nc::rotations::Quaternion::rollRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the roll axis

Parameters
inAngle(radians)
Returns
Quaternion

◆ rotate() [1/2]

NdArray< double > nc::rotations::Quaternion::rotate ( const NdArray< double > &  inVector) const
inline

rotate a vector using the quaternion

Parameters
inVector(cartesian vector with x,y,z components)
Returns
NdArray<double> (cartesian vector with x,y,z components)

◆ rotate() [2/2]

Vec3 nc::rotations::Quaternion::rotate ( const Vec3 inVec3) const
inline

rotate a vector using the quaternion

Parameters
inVec3
Returns
Vec3

◆ s()

double nc::rotations::Quaternion::s ( ) const
inlinenoexcept

returns the s component

Returns
double

◆ slerp() [1/2]

static Quaternion nc::rotations::Quaternion::slerp ( const Quaternion inQuat1,
const Quaternion inQuat2,
double  inPercent 
)
inlinestatic

spherical linear interpolates between the two quaternions

Parameters
inQuat1
inQuat2
inPercent(0, 1)
Returns
Quaternion

◆ slerp() [2/2]

Quaternion nc::rotations::Quaternion::slerp ( const Quaternion inQuat2,
double  inPercent 
) const
inline

spherical linear interpolates between the two quaternions

Parameters
inQuat2
inPercent(0, 1)
Returns
Quaternion

◆ str()

std::string nc::rotations::Quaternion::str ( ) const
inline

returns the quaternion as a string representation

Returns
std::string

◆ toDCM()

NdArray< double > nc::rotations::Quaternion::toDCM ( ) const
inline

returns the direction cosine matrix

Returns
NdArray<double>

◆ toNdArray()

NdArray< double > nc::rotations::Quaternion::toNdArray ( ) const
inline

returns the quaternion as an NdArray

Returns
NdArray<double>

◆ xRotation()

static Quaternion nc::rotations::Quaternion::xRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the x-axis by the input angle

Parameters
inAngle(radians)
Returns
Quaternion

◆ yaw()

double nc::rotations::Quaternion::yaw ( ) const
inlinenoexcept

The euler yaw angle in radians

Returns
euler yaw angle in radians

◆ yawRotation()

static Quaternion nc::rotations::Quaternion::yawRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the yaw axis

Parameters
inAngle(radians)
Returns
Quaternion

◆ yRotation()

static Quaternion nc::rotations::Quaternion::yRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the y-axis by the input angle

Parameters
inAngle(radians)
Returns
Quaternion

◆ zRotation()

static Quaternion nc::rotations::Quaternion::zRotation ( double  inAngle)
inlinestaticnoexcept

returns a quaternion to rotate about the y-axis by the input angle

Parameters
inAngle(radians)
Returns
Quaternion

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  inOStream,
const Quaternion inQuat 
)
friend

IO operator for the Quaternion class

Parameters
inOStream
inQuat
Returns
std::ostream&

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