Clutter Engine 0.0.1
Loading...
Searching...
No Matches
Quaternion Struct Reference

Represents a quaternion for 3D rotations. More...

#include <Quaternion.h>

Public Member Functions

 Quaternion ()
 Default constructor. Initializes to identity quaternion.
 
 Quaternion (float inX, float inY, float inZ, float inW)
 Directly sets the quaternion components.
 
 Quaternion (const Vector3 &axis, float angle)
 Constructs the quaternion from an axis and angle.
 
 Quaternion (float inAll)
 Sets all components to the same value.
 
void Set (float inX, float inY, float inZ, float inW)
 Sets the quaternion components.
 
void Conjugate ()
 Conjugates the quaternion.
 
void Normalize ()
 Normalizes the quaternion in place.
 
float LengthSqr () const
 Returns the squared length of the quaternion.
 
float Length () const
 Returns the length (magnitude) of the quaternion.
 
Quaternion Normalized () const
 Returns a normalized copy of the quaternion.
 
Quaternion Inverse () const
 Returns the inverse of the quaternion.
 
Vector3 QuaternionToEuler () const
 Converts the quaternion to Euler angles (in radians).
 
std::string ToString ()
 Returns a string representation of the quaternion.
 
class Matrix4 AsMatrix () const
 Converts the quaternion to a 4x4 matrix.
 
class Matrix4Row AsMatrixRow () const
 Converts the quaternion to a row-major 4x4 matrix.
 

Static Public Member Functions

static Quaternion Normalize (const Quaternion &q)
 Returns a normalized copy of the provided quaternion.
 
static Quaternion Lerp (const Quaternion &a, const Quaternion &b, float f)
 Linearly interpolates between two quaternions.
 
static float Dot (const Quaternion &a, const Quaternion &b)
 Computes the dot product of two quaternions.
 
static Quaternion Slerp (const Quaternion &a, const Quaternion &b, float f)
 Spherical linear interpolation between two quaternions.
 
static Quaternion Concatenate (const Quaternion &q, const Quaternion &p)
 Concatenates two quaternions (applies q, then p).
 
static Quaternion FromEuler (const Vector3 &axis)
 Creates a quaternion from Euler angles (in degrees).
 
static Quaternion LookAt (const Vector3 &sourcePoint, const Vector3 &targetPoint, const Vector3 &up=Vector3::Up)
 Creates a quaternion that rotates from sourcePoint to targetPoint.
 

Public Attributes

float x
 X component.
 
float y
 Y component.
 
float z
 Z component.
 
float w
 W (scalar) component.
 

Static Public Attributes

static const Quaternion Identity
 The identity quaternion (no rotation).
 

Detailed Description

Represents a quaternion for 3D rotations.

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

Quaternion::Quaternion ( float inX,
float inY,
float inZ,
float inW )

Directly sets the quaternion components.

Parameters
inXX component
inYY component
inZZ component
inWW (scalar) component
Note
Do not use for axis/angle construction.

◆ Quaternion() [2/3]

Quaternion::Quaternion ( const Vector3 & axis,
float angle )

Constructs the quaternion from an axis and angle.

Parameters
axisNormalized axis of rotation
angleAngle in radians

◆ Quaternion() [3/3]

Quaternion::Quaternion ( float inAll)

Sets all components to the same value.

Parameters
inAllValue for all components

Member Function Documentation

◆ AsMatrix()

Matrix4 Quaternion::AsMatrix ( ) const

Converts the quaternion to a 4x4 matrix.

Returns
Matrix4 representation

◆ AsMatrixRow()

Matrix4Row Quaternion::AsMatrixRow ( ) const

Converts the quaternion to a row-major 4x4 matrix.

Returns
Matrix4Row representation

◆ Concatenate()

static Quaternion Quaternion::Concatenate ( const Quaternion & q,
const Quaternion & p )
inlinestatic

Concatenates two quaternions (applies q, then p).

Parameters
qFirst quaternion
pSecond quaternion
Returns
Concatenated quaternion

◆ Dot()

static float Quaternion::Dot ( const Quaternion & a,
const Quaternion & b )
inlinestatic

Computes the dot product of two quaternions.

Parameters
aFirst quaternion
bSecond quaternion
Returns
Dot product

◆ FromEuler()

static Quaternion Quaternion::FromEuler ( const Vector3 & axis)
inlinestatic

Creates a quaternion from Euler angles (in degrees).

Parameters
axisEuler angles (degrees) for x, y, z
Returns
Quaternion representing the rotation

◆ Inverse()

Quaternion Quaternion::Inverse ( ) const
inline

Returns the inverse of the quaternion.

Returns
Inverse quaternion

◆ Length()

float Quaternion::Length ( ) const
inline

Returns the length (magnitude) of the quaternion.

Returns
Length

◆ LengthSqr()

float Quaternion::LengthSqr ( ) const
inline

Returns the squared length of the quaternion.

Returns
Squared length

◆ Lerp()

static Quaternion Quaternion::Lerp ( const Quaternion & a,
const Quaternion & b,
float f )
inlinestatic

Linearly interpolates between two quaternions.

Parameters
aStart quaternion
bEnd quaternion
fInterpolation factor [0, 1]
Returns
Interpolated quaternion

◆ LookAt()

static Quaternion Quaternion::LookAt ( const Vector3 & sourcePoint,
const Vector3 & targetPoint,
const Vector3 & up = Vector3::Up )
inlinestatic

Creates a quaternion that rotates from sourcePoint to targetPoint.

Parameters
sourcePointSource position
targetPointTarget position
upUp direction (default: Vector3::Up)
Returns
Quaternion representing the look-at rotation

◆ Normalize()

static Quaternion Quaternion::Normalize ( const Quaternion & q)
inlinestatic

Returns a normalized copy of the provided quaternion.

Parameters
qQuaternion to normalize
Returns
Normalized quaternion

◆ Normalized()

Quaternion Quaternion::Normalized ( ) const
inline

Returns a normalized copy of the quaternion.

Returns
Normalized quaternion

◆ QuaternionToEuler()

Vector3 Quaternion::QuaternionToEuler ( ) const
inline

Converts the quaternion to Euler angles (in radians).

Returns
Euler angles as a Vector3 (pitch, yaw, roll)

◆ Set()

void Quaternion::Set ( float inX,
float inY,
float inZ,
float inW )

Sets the quaternion components.

Parameters
inXX component
inYY component
inZZ component
inWW (scalar) component

◆ Slerp()

static Quaternion Quaternion::Slerp ( const Quaternion & a,
const Quaternion & b,
float f )
inlinestatic

Spherical linear interpolation between two quaternions.

Parameters
aStart quaternion
bEnd quaternion
fInterpolation factor [0, 1]
Returns
Interpolated quaternion

◆ ToString()

std::string Quaternion::ToString ( )
inline

Returns a string representation of the quaternion.

Returns
String in the format "Rotation: (x, y, z, w)"

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