LOST  0.0.1
LOST: Open-source Star Tracker
lost::Quaternion Class Reference

A quaternion is a common way to represent a 3d rotation. More...

#include <attitude-utils.hpp>

Public Member Functions

 Quaternion ()=default
 
 Quaternion (const Vec3 &)
 Creates a "pure quaternion" with the given vector for imaginary parts and zero for real part. More...
 
 Quaternion (const Vec3 &, decimal)
 Create a quaternion which represents a rotation of theta around the axis input. More...
 
 Quaternion (decimal real, decimal i, decimal j, decimal k)
 
Quaternion operator* (const Quaternion &other) const
 Multiply two quaternions using the usual definition of quaternion multiplication (effectively composes rotations) More...
 
Quaternion Conjugate () const
 Effectively computes a quaternion representing the inverse rotation of the original. More...
 
Vec3 Vector () const
 The vector formed by imaginary components of the quaternion. The axis of the represented rotation. More...
 
void SetVector (const Vec3 &)
 Set imaginary components. More...
 
Vec3 Rotate (const Vec3 &) const
 Rotate a 3d vector according to the rotation represented by the quaternion. More...
 
decimal Angle () const
 How many radians the rotation represented by this quaternion has. More...
 
decimal SmallestAngle () const
 Returns the smallest angle that can be used to represent the rotation represented by the quaternion. More...
 
void SetAngle (decimal)
 
EulerAngles ToSpherical () const
 
bool IsUnit (decimal tolerance) const
 Whether the quaternion is a unit quaternion. All quaternions representing rotations should be units. More...
 
Quaternion Canonicalize () const
 Ensure that the quaternion's real part is nonnegative. More...
 

Public Attributes

decimal real
 
decimal i
 
decimal j
 
decimal k
 

Detailed Description

A quaternion is a common way to represent a 3d rotation.

Definition at line 98 of file attitude-utils.hpp.

Constructor & Destructor Documentation

◆ Quaternion() [1/4]

lost::Quaternion::Quaternion ( )
default
Here is the caller graph for this function:

◆ Quaternion() [2/4]

lost::Quaternion::Quaternion ( const Vec3 input)
explicit

Creates a "pure quaternion" with the given vector for imaginary parts and zero for real part.

Definition at line 40 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ Quaternion() [3/4]

lost::Quaternion::Quaternion ( const Vec3 input,
decimal  theta 
)

Create a quaternion which represents a rotation of theta around the axis input.

Definition at line 46 of file attitude-utils.cpp.

◆ Quaternion() [4/4]

lost::Quaternion::Quaternion ( decimal  real,
decimal  i,
decimal  j,
decimal  k 
)
inline

Definition at line 104 of file attitude-utils.hpp.

Member Function Documentation

◆ Angle()

decimal lost::Quaternion::Angle ( ) const

How many radians the rotation represented by this quaternion has.

Definition at line 61 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ Canonicalize()

Quaternion lost::Quaternion::Canonicalize ( ) const

Ensure that the quaternion's real part is nonnegative.

Does not change the rotation represented by the quaternion.

Definition at line 127 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ Conjugate()

Quaternion lost::Quaternion::Conjugate ( ) const

Effectively computes a quaternion representing the inverse rotation of the original.

Definition at line 23 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsUnit()

bool lost::Quaternion::IsUnit ( decimal  tolerance) const

Whether the quaternion is a unit quaternion. All quaternions representing rotations should be units.

Definition at line 120 of file attitude-utils.cpp.

◆ operator*()

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

Multiply two quaternions using the usual definition of quaternion multiplication (effectively composes rotations)

Definition at line 14 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ Rotate()

Vec3 lost::Quaternion::Rotate ( const Vec3 input) const

Rotate a 3d vector according to the rotation represented by the quaternion.

Definition at line 55 of file attitude-utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAngle()

void lost::Quaternion::SetAngle ( decimal  newAngle)

Definition at line 76 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ SetVector()

void lost::Quaternion::SetVector ( const Vec3 vec)

Set imaginary components.

Definition at line 33 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ SmallestAngle()

decimal lost::Quaternion::SmallestAngle ( ) const

Returns the smallest angle that can be used to represent the rotation represented by the quaternion.

I.e, min(Angle, 2pi-Angle).

Definition at line 69 of file attitude-utils.cpp.

Here is the call graph for this function:

◆ ToSpherical()

EulerAngles lost::Quaternion::ToSpherical ( ) const

Definition at line 81 of file attitude-utils.cpp.

Here is the caller graph for this function:

◆ Vector()

Vec3 lost::Quaternion::Vector ( ) const

The vector formed by imaginary components of the quaternion. The axis of the represented rotation.

Definition at line 28 of file attitude-utils.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ i

decimal lost::Quaternion::i

Definition at line 122 of file attitude-utils.hpp.

◆ j

decimal lost::Quaternion::j

Definition at line 123 of file attitude-utils.hpp.

◆ k

decimal lost::Quaternion::k

Definition at line 124 of file attitude-utils.hpp.

◆ real

decimal lost::Quaternion::real

Definition at line 121 of file attitude-utils.hpp.


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