RoboidControl
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Passer::LinearAlgebra::Quaternion Struct Reference

A quaternion. More...

#include <Quaternion.h>

Inheritance diagram for Passer::LinearAlgebra::Quaternion:
Passer::LinearAlgebra::Quat

Public Member Functions

 Quaternion ()
 Create a new identity quaternion.
 
 Quaternion (float _x, float _y, float _z, float _w)
 create a new quaternion with the given values
 
 Quaternion (Quat q)
 Create a quaternion from C-style Quat.
 
 ~Quaternion ()
 Quaternion destructor.
 
void Normalize ()
 Convert to unit quaternion.
 
Vector3 operator* (const Vector3 &vector) const
 Rotate a vector using this quaterion.
 
Quaternion operator* (const Quaternion &rotation) const
 Multiply this quaternion with another quaternion.
 
bool operator== (const Quaternion &quaternion)
 Check the equality of two quaternions.
 
void ToAngleAxis (float *angle, Vector3 *axis)
 Convert this quaternion to angle/axis representation.
 

Static Public Member Functions

static Quaternion Normalize (const Quaternion &q)
 Convert to unity quaternion.
 
static Vector3 ToAngles (const Quaternion &q)
 Convert to euler angles.
 
static Quaternion Inverse (Quaternion quaternion)
 The inverse of quaterion.
 
static Quaternion LookRotation (const Vector3 &forward, const Vector3 &upwards)
 A rotation which looks in the given direction.
 
static Quaternion LookRotation (const Vector3 &forward)
 Creates a quaternion with the given forward direction with up = Vector3::up.
 
static Quaternion FromToRotation (Vector3 fromDirection, Vector3 toDirection)
 Calculat the rotation from on vector to another.
 
static Quaternion RotateTowards (const Quaternion &from, const Quaternion &to, float maxDegreesDelta)
 Rotate form one orientation to anther with a maximum amount of degrees.
 
static Quaternion AngleAxis (float angle, const Vector3 &axis)
 Convert an angle/axis representation to a quaternion.
 
static float Angle (Quaternion orientation1, Quaternion orientation2)
 Get the angle between two orientations.
 
static Quaternion Slerp (const Quaternion &rotation1, const Quaternion &rotation2, float factor)
 Sherical lerp between two rotations.
 
static Quaternion SlerpUnclamped (const Quaternion &rotation1, const Quaternion &rotation2, float factor)
 Unclamped sherical lerp between two rotations.
 
static Quaternion Euler (float x, float y, float z)
 Create a rotation from euler angles.
 
static Quaternion Euler (Vector3 eulerAngles)
 Create a rotation from a vector containing euler angles.
 
static Quaternion EulerXYZ (float x, float y, float z)
 Create a rotation from euler angles.
 
static Quaternion EulerXYZ (Vector3 eulerAngles)
 Create a rotation from a vector containing euler angles.
 
static float GetAngleAround (Vector3 axis, Quaternion rotation)
 Returns the angle of around the give axis for a rotation.
 
static Quaternion GetRotationAround (Vector3 axis, Quaternion rotation)
 Returns the rotation limited around the given axis.
 
static void GetSwingTwist (Vector3 axis, Quaternion rotation, Quaternion *swing, Quaternion *twist)
 Swing-twist decomposition of a rotation.
 
static float Dot (Quaternion rotation1, Quaternion rotation2)
 Calculate the dot product of two quaternions.
 

Public Attributes

float x
 The x component.
 
float y
 The y component.
 
float z
 The z component.
 
float w
 The w component.
 

Static Public Attributes

static const Quaternion identity = Quaternion(0, 0, 0, 1)
 An identity quaternion.
 

Detailed Description

A quaternion.

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

Quaternion::Quaternion ( )

Create a new identity quaternion.

◆ Quaternion() [2/3]

Quaternion::Quaternion ( float  _x,
float  _y,
float  _z,
float  _w 
)

create a new quaternion with the given values

Parameters
_xx component
_yy component
_zz component
_ww component

◆ Quaternion() [3/3]

Quaternion::Quaternion ( Quat  q)

Create a quaternion from C-style Quat.

Parameters
q

◆ ~Quaternion()

Quaternion::~Quaternion ( )

Quaternion destructor.

Member Function Documentation

◆ Normalize() [1/2]

void Quaternion::Normalize ( )

Convert to unit quaternion.

This will preserve the orientation, but ensures that it is a unit quaternion.

◆ Normalize() [2/2]

Quaternion Quaternion::Normalize ( const Quaternion q)
static

Convert to unity quaternion.

Parameters
qThe quaternion to convert
Returns
A unit quaternion

This will preserve the orientation, but ensures that it is a unit quaternion.

◆ ToAngles()

Vector3 Quaternion::ToAngles ( const Quaternion q)
static

Convert to euler angles.

Parameters
qThe quaternion to convert
Returns
A vector containing euler angles

The euler angles performed in the order: Z, X, Y

◆ operator*() [1/2]

Vector3 Passer::LinearAlgebra::Quaternion::operator* ( const Vector3 vector) const

Rotate a vector using this quaterion.

Parameters
vectorThe vector to rotate
Returns
The rotated vector

◆ operator*() [2/2]

Quaternion Passer::LinearAlgebra::Quaternion::operator* ( const Quaternion rotation) const

Multiply this quaternion with another quaternion.

Parameters
rotationThe quaternion to multiply with
Returns
The resulting rotation

The result will be this quaternion rotated according to the give rotation.

◆ operator==()

bool Quaternion::operator== ( const Quaternion quaternion)

Check the equality of two quaternions.

Parameters
quaternionThe quaternion to compare to
Returns
True when the components of the quaternions are identical

Note that this does not compare the rotations themselves. Two quaternions with the same rotational effect may have different components. Use Quaternion::Angle to check if the rotations are the same.

◆ Inverse()

Quaternion Quaternion::Inverse ( Quaternion  quaternion)
static

The inverse of quaterion.

Parameters
quaternionThe quaternion for which the inverse is needed
Returns
The inverted quaternion

◆ LookRotation() [1/2]

static Quaternion Passer::LinearAlgebra::Quaternion::LookRotation ( const Vector3 forward,
const Vector3 upwards 
)
static

A rotation which looks in the given direction.

Parameters
forwardThe look direction
upwardsThe up direction
Returns
The look rotation

◆ LookRotation() [2/2]

Quaternion Quaternion::LookRotation ( const Vector3 forward)
static

Creates a quaternion with the given forward direction with up = Vector3::up.

Parameters
forwardThe look direction
Returns
The rotation for this direction

For the rotation, Vector::up is used for the up direction. Note: if the forward direction == Vector3::up, the result is Quaternion::identity

◆ FromToRotation()

Quaternion Quaternion::FromToRotation ( Vector3  fromDirection,
Vector3  toDirection 
)
static

Calculat the rotation from on vector to another.

Parameters
fromDirectionThe from direction
toDirectionThe to direction
Returns
The rotation from the first to the second vector

◆ RotateTowards()

Quaternion Quaternion::RotateTowards ( const Quaternion from,
const Quaternion to,
float  maxDegreesDelta 
)
static

Rotate form one orientation to anther with a maximum amount of degrees.

Parameters
fromThe from rotation
toThe destination rotation
maxDegreesDeltaThe maximum amount of degrees to rotate
Returns
The possibly limited rotation

◆ AngleAxis()

Quaternion Quaternion::AngleAxis ( float  angle,
const Vector3 axis 
)
static

Convert an angle/axis representation to a quaternion.

Parameters
angleThe angle
axisThe axis
Returns
The resulting quaternion

◆ ToAngleAxis()

void Quaternion::ToAngleAxis ( float angle,
Vector3 axis 
)

Convert this quaternion to angle/axis representation.

Parameters
angleA pointer to the angle for the result
axisA pointer to the axis for the result

◆ Angle()

float Quaternion::Angle ( Quaternion  orientation1,
Quaternion  orientation2 
)
static

Get the angle between two orientations.

Parameters
orientation1The first orientation
orientation2The second orientation
Returns
The smallest angle in degrees between the two orientations

◆ Slerp()

Quaternion Quaternion::Slerp ( const Quaternion rotation1,
const Quaternion rotation2,
float  factor 
)
static

Sherical lerp between two rotations.

Parameters
rotation1The first rotation
rotation2The second rotation
factorThe factor between 0 and 1.
Returns
The resulting rotation

A factor 0 returns rotation1, factor1 returns rotation2.

◆ SlerpUnclamped()

Quaternion Quaternion::SlerpUnclamped ( const Quaternion rotation1,
const Quaternion rotation2,
float  factor 
)
static

Unclamped sherical lerp between two rotations.

Parameters
rotation1The first rotation
rotation2The second rotation
factorThe factor
Returns
The resulting rotation

A factor 0 returns rotation1, factor1 returns rotation2. Values outside the 0..1 range will result in extrapolated rotations

◆ Euler() [1/2]

Quaternion Quaternion::Euler ( float  x,
float  y,
float  z 
)
static

Create a rotation from euler angles.

Parameters
xThe angle around the right axis
yThe angle around the upward axis
zThe angle around the forward axis
Returns
The resulting quaternion

Rotation are appied in the order Z, X, Y.

◆ Euler() [2/2]

static Quaternion Passer::LinearAlgebra::Quaternion::Euler ( Vector3  eulerAngles)
static

Create a rotation from a vector containing euler angles.

Parameters
eulerAnglesVector with the euler angles
Returns
The resulting quaternion

Rotation are appied in the order Z, X, Y.

◆ EulerXYZ() [1/2]

Quaternion Quaternion::EulerXYZ ( float  x,
float  y,
float  z 
)
static

Create a rotation from euler angles.

Parameters
xThe angle around the right axis
yThe angle around the upward axis
zThe angle around the forward axis
Returns
The resulting quaternion

Rotation are appied in the order X, Y, Z.

◆ EulerXYZ() [2/2]

static Quaternion Passer::LinearAlgebra::Quaternion::EulerXYZ ( Vector3  eulerAngles)
static

Create a rotation from a vector containing euler angles.

Parameters
eulerAnglesVector with the euler angles
Returns
The resulting quaternion

Rotation are appied in the order X, Y, Z.

◆ GetAngleAround()

float Quaternion::GetAngleAround ( Vector3  axis,
Quaternion  rotation 
)
static

Returns the angle of around the give axis for a rotation.

Parameters
axisThe axis around which the angle should be computed
rotationThe source rotation
Returns
The signed angle around the axis

◆ GetRotationAround()

Quaternion Quaternion::GetRotationAround ( Vector3  axis,
Quaternion  rotation 
)
static

Returns the rotation limited around the given axis.

Parameters
axisThe axis which which the rotation should be limited
rotationThe source rotation
Returns
The rotation around the given axis

◆ GetSwingTwist()

void Quaternion::GetSwingTwist ( Vector3  axis,
Quaternion  rotation,
Quaternion swing,
Quaternion twist 
)
static

Swing-twist decomposition of a rotation.

Parameters
axisThe base direction for the decomposition
rotationThe source rotation
swingA pointer to the quaternion for the swing result
twistA pointer to the quaternion for the twist result

◆ Dot()

float Quaternion::Dot ( Quaternion  rotation1,
Quaternion  rotation2 
)
static

Calculate the dot product of two quaternions.

Parameters
rotation1The first rotation
rotation2The second rotation
Returns

Member Data Documentation

◆ identity

const Quaternion Quaternion::identity = Quaternion(0, 0, 0, 1)
static

An identity quaternion.

◆ x

float Passer::LinearAlgebra::Quat::x
inherited

The x component.

◆ y

float Passer::LinearAlgebra::Quat::y
inherited

The y component.

◆ z

float Passer::LinearAlgebra::Quat::z
inherited

The z component.

◆ w

float Passer::LinearAlgebra::Quat::w
inherited

The w component.


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