3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Math::Quaternion Struct Reference

A quaternion is a hyper-complex number that represents 3D rotations the same way 2D rotations can be represented by a complex number. More...

#include <Quaternion.hpp>

Public Member Functions

constexpr Quaternion (float x=0.0f, float y=0.0f, float z=0.0f, float w=1.0f)
constexpr Quaternion (std::initializer_list< float > lst)
float Length () const noexcept
 Returns the length of the quaternion. The length is defined as the square root of the sum of the squares of its components.
float LengthSquared () const noexcept
 Returns the lenght of this quaternion squared.
Quaternion & Normalize ()
Quaternion & Conjugate () noexcept
Quaternion & Inverse ()
 Creates an inverse Quaternion.
float Dot (const Quaternion &q) const noexcept
 Returns the dot Product between this quaternion and another quaternion.
float & Re () noexcept
 Returns the real part of this quaternion.
float Re () const noexcept
 Returns the real part of this quaternion.
Vector3 Im () const noexcept
 Returns the imaginary component of this quaternion.
Vector3 ToYawPitchRoll () const
 Converts this quaternion to yaw, pitch, and roll angles (in radians).
Quaternion & Hadamard (const Quaternion &q)
 Element wise (Hadamard) multiplication of this quaternion with another quaternion.
Quaternion & operator- () noexcept
 Negates this quaternion.
Quaternion operator+ (const Quaternion &q) const noexcept
 Adds another quaternion to this quaternion and returns the result.
Quaternion & operator+= (const Quaternion &q) noexcept
 Adds another quaternion to this quaternion in-place.
Quaternion operator- (const Quaternion &q) const noexcept
 Subtracts another quaternion from this quaternion and returns the result.
Quaternion & operator-= (const Quaternion &q) noexcept
 Subtracts another quaternion from this quaternion in-place.
Quaternion operator* (const Quaternion &q) const noexcept
 Multiplies (composes) this quaternion by another quaternion and returns the result.
Quaternion & operator*= (const Quaternion &q) noexcept
 Multiplies (composes) this quaternion by another quaternion in-place.
Quaternion operator* (float s) const noexcept
 Multiplies this quaternion by a scalar and returns the result.
Quaternion & operator*= (float s) noexcept
 Multiplies this quaternion by a scalar in-place.
Quaternion operator/ (float s) const
 Divides this quaternion by a scalar and returns the result.
Quaternion & operator/= (float s)
 Divides this quaternion by a scalar in-place.
auto operator<=> (const Quaternion &q) const noexcept=default
 Partial ordering comparison between this quaternion and another quaternion. The comparison is based on the lexicographical order of the components (X, Y, Z, W).

Static Public Member Functions

static Quaternion FromYawPitchRoll (float yaw, float pitch, float roll)
static Quaternion FromAxisAngle (const Vector3 &axis, float angle)
static Quaternion FromMatrix (const Matrix4x4 &m)
static Quaternion BetweenVectors (const Vector3 &a, const Vector3 &b)
static Quaternion Slerp (const Quaternion &a, const Quaternion &b, float t)
static float Dot (const Quaternion &a, const Quaternion &b)
 Returns the dot product of two quaternions.

Public Attributes

float X
 The X component of the quaternion.
float Y
 The Y component of the quaternion.
float Z
 The Z component of the quaternion.
float W
 The real/scalar component of the quaternion.

Detailed Description

A quaternion is a hyper-complex number that represents 3D rotations the same way 2D rotations can be represented by a complex number.

Constructor & Destructor Documentation

◆ Quaternion() [1/2]

Engine3DRadSpace.Math::Quaternion::Quaternion ( float x = 0.0f,
float y = 0.0f,
float z = 0.0f,
float w = 1.0f )
inlineexplicitconstexpr

◆ Quaternion() [2/2]

Engine3DRadSpace.Math::Quaternion::Quaternion ( std::initializer_list< float > lst)
inlineexplicitconstexpr

Member Function Documentation

◆ BetweenVectors()

Quaternion Quaternion::BetweenVectors ( const Vector3 & a,
const Vector3 & b )
static

◆ Conjugate()

Quaternion & Quaternion::Conjugate ( )
noexcept

◆ Dot() [1/2]

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

Returns the dot product of two quaternions.

Parameters
aThe first quaternion.
bThe second quaternion.
Returns
X * b.X + Y * b.Y + Z * b.Z + W * b.W

◆ Dot() [2/2]

float Quaternion::Dot ( const Quaternion & q) const
noexcept

Returns the dot Product between this quaternion and another quaternion.

Parameters
qOther quaternion.
Returns
X * q.X + Y * q.Y + Z * q.Z + W * q.W

◆ FromAxisAngle()

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

◆ FromMatrix()

Quaternion Quaternion::FromMatrix ( const Matrix4x4 & m)
static

◆ FromYawPitchRoll()

Quaternion Quaternion::FromYawPitchRoll ( float yaw,
float pitch,
float roll )
static

◆ Hadamard()

Quaternion & Quaternion::Hadamard ( const Quaternion & q)

Element wise (Hadamard) multiplication of this quaternion with another quaternion.

Parameters
qThe quaternion to multiply element-wise.
Returns
A reference to this quaternion after the Hadamard multiplication.

◆ Im()

Vector3 Quaternion::Im ( ) const
noexcept

Returns the imaginary component of this quaternion.

Returns
The vector containing the X, Y, and Z components.

◆ Inverse()

Quaternion & Quaternion::Inverse ( )

Creates an inverse Quaternion.

Returns
The inverse of this quaternion.

◆ Length()

float Quaternion::Length ( ) const
noexcept

Returns the length of the quaternion. The length is defined as the square root of the sum of the squares of its components.

Returns
The length of the quaternion.

◆ LengthSquared()

float Quaternion::LengthSquared ( ) const
noexcept

Returns the lenght of this quaternion squared.

Returns
X*X + Y*Y + Z*Z + W*W

◆ Normalize()

Quaternion & Quaternion::Normalize ( )

◆ operator*() [1/2]

Quaternion Quaternion::operator* ( const Quaternion & q) const
noexcept

Multiplies (composes) this quaternion by another quaternion and returns the result.

Parameters
qThe quaternion to multiply by.
Returns
The resulting quaternion after multiplication.

◆ operator*() [2/2]

Quaternion Quaternion::operator* ( float s) const
noexcept

Multiplies this quaternion by a scalar and returns the result.

Parameters
sThe scalar to multiply by.
Returns
The resulting quaternion after multiplication.

◆ operator*=() [1/2]

Quaternion & Quaternion::operator*= ( const Quaternion & q)
noexcept

Multiplies (composes) this quaternion by another quaternion in-place.

Parameters
qThe quaternion to multiply by.
Returns
A reference to this quaternion after multiplication.

◆ operator*=() [2/2]

Quaternion & Quaternion::operator*= ( float s)
noexcept

Multiplies this quaternion by a scalar in-place.

Parameters
sThe scalar to multiply by.
Returns
A reference to this quaternion after multiplication.

◆ operator+()

Quaternion Quaternion::operator+ ( const Quaternion & q) const
noexcept

Adds another quaternion to this quaternion and returns the result.

Parameters
qThe quaternion to add.
Returns
The resulting quaternion after addition.

◆ operator+=()

Quaternion & Quaternion::operator+= ( const Quaternion & q)
noexcept

Adds another quaternion to this quaternion in-place.

Parameters
qThe quaternion to add.
Returns
A reference to this quaternion after addition.

◆ operator-() [1/2]

Quaternion & Quaternion::operator- ( )
noexcept

Negates this quaternion.

Returns
A reference to this quaternion after negation.

◆ operator-() [2/2]

Quaternion Quaternion::operator- ( const Quaternion & q) const
noexcept

Subtracts another quaternion from this quaternion and returns the result.

Parameters
qThe quaternion to subtract.
Returns
The resulting quaternion after subtraction.

◆ operator-=()

Quaternion & Quaternion::operator-= ( const Quaternion & q)
noexcept

Subtracts another quaternion from this quaternion in-place.

Parameters
qThe quaternion to subtract.
Returns
A reference to this quaternion after subtraction.

◆ operator/()

Quaternion Quaternion::operator/ ( float s) const

Divides this quaternion by a scalar and returns the result.

Parameters
sThe scalar to divide by.
Returns
The resulting quaternion after division.

◆ operator/=()

Quaternion & Quaternion::operator/= ( float s)

Divides this quaternion by a scalar in-place.

Parameters
sThe scalar to divide by.
Returns
A reference to this quaternion after division.

◆ operator<=>()

auto Engine3DRadSpace.Math::Quaternion::operator<=> ( const Quaternion & q) const
defaultnoexcept

Partial ordering comparison between this quaternion and another quaternion. The comparison is based on the lexicographical order of the components (X, Y, Z, W).

Parameters
qThe quaternion to compare with.
Returns
The result of the partial ordering comparison.

◆ Re() [1/2]

float Quaternion::Re ( ) const
noexcept

Returns the real part of this quaternion.

Returns
The W coordinate.

◆ Re() [2/2]

float & Quaternion::Re ( )
noexcept

Returns the real part of this quaternion.

Returns
Reference to the W coordinate.

◆ Slerp()

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

◆ ToYawPitchRoll()

Vector3 Quaternion::ToYawPitchRoll ( ) const

Converts this quaternion to yaw, pitch, and roll angles (in radians).

Returns
A vector containing the yaw, pitch, and roll angles (in radians).

Member Data Documentation

◆ W

float Engine3DRadSpace.Math::Quaternion::W

The real/scalar component of the quaternion.

◆ X

float Engine3DRadSpace.Math::Quaternion::X

The X component of the quaternion.

◆ Y

float Engine3DRadSpace.Math::Quaternion::Y

The Y component of the quaternion.

◆ Z

float Engine3DRadSpace.Math::Quaternion::Z

The Z component of the quaternion.


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