Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::math::TQuaternion< T > Class Template Referencefinal

Represents a quaternion. More...

#include <TQuaternion.h>

Inheritance diagram for ph::math::TQuaternion< T >:
ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >

Public Member Functions

 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TQuaternion)
 
 TQuaternion (T vx, T vy, T vz, T vw)
 
template<typename U >
 TQuaternion (const TQuaternion< U > &other)
 
template<typename U >
 TQuaternion (const std::array< U, 4 > &xyzwValues)
 
 TQuaternion (const TVector3< T > &normalizedAxis, T radians)
 
 TQuaternion (const TMatrix4< T > &rotationMatrix)
 
T & x ()
 
T & y ()
 
T & z ()
 
T & w ()
 
const T & x () const
 
const T & y () const
 
const T & z () const
 
const T & w () const
 
TQuaternion mul (const TVector3< T > &xyz) const
 Quaternion multiplication (treating the input's w component as 0).
 
TQuaternion normalize () const
 
TQuaternionnormalizeLocal ()
 
length () const
 
TQuaternion conjugate () const
 
void conjugate (TQuaternion *out_result) const
 
TQuaternionconjugateLocal ()
 
TQuaternion mul (const TQuaternion &rhs) const
 
TQuaternionmulLocal (const TQuaternion &rhs)
 
TQuaternion mul (T rhs) const
 
TQuaternion sub (const TQuaternion &rhs) const
 
TQuaternion add (const TQuaternion &rhs) const
 
dot (const TQuaternion &rhs) const
 
void setRot (const TVector3< T > &normalizedAxis, T radians)
 
void toRotationMatrix (TMatrix4< T > *out_result) const
 
- Public Member Functions inherited from ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >
 TArithmeticArrayBase (T value)
 
 TArithmeticArrayBase (Elements values)
 
auto pow (const U exponent) const -> TQuaternion< T >
 
auto powLocal (const U exponent) -> TQuaternion< T > &
 
auto exp (const U exponent) const -> TQuaternion< T >
 
auto expLocal (const U exponent) -> TQuaternion< T > &
 
auto lerp (const TQuaternion< T > &rhs, const U factor) const -> TQuaternion< T >
 

Static Public Member Functions

static TQuaternion makeNoRotation ()
 

Additional Inherited Members

- Public Types inherited from ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >
using Elements
 
- Protected Member Functions inherited from ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >
 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TArithmeticArrayBase)
 
constexpr std::size_t size () const noexcept
 Number of elements of the array.
 
TQuaternion< T > add (const TQuaternion< T > &rhs) const
 
TQuaternion< T > add (T rhs) const
 
TQuaternion< T > & addLocal (const TQuaternion< T > &rhs)
 
TQuaternion< T > & addLocal (T rhs)
 
TQuaternion< T > sub (const TQuaternion< T > &rhs) const
 
TQuaternion< T > sub (T rhs) const
 
TQuaternion< T > & subLocal (const TQuaternion< T > &rhs)
 
TQuaternion< T > & subLocal (T rhs)
 
TQuaternion< T > mul (const TQuaternion< T > &rhs) const
 
TQuaternion< T > mul (T rhs) const
 
TQuaternion< T > & mulLocal (const TQuaternion< T > &rhs)
 
TQuaternion< T > & mulLocal (T rhs)
 
TQuaternion< T > div (const TQuaternion< T > &rhs) const
 
TQuaternion< T > div (T rhs) const
 
TQuaternion< T > & divLocal (const TQuaternion< T > &rhs)
 
TQuaternion< T > & divLocal (T rhs)
 
TQuaternion< T > pow (U exponent) const
 
TQuaternion< T > pow (const TQuaternion< T > &exponent) const
 
TQuaternion< T > & powLocal (U exponent)
 
TQuaternion< T > & powLocal (const TQuaternion< T > &exponent)
 
TQuaternion< T > sqrt () const
 
TQuaternion< T > & sqrtLocal ()
 
TQuaternion< T > abs () const
 
TQuaternion< T > & absLocal ()
 
TQuaternion< T > rcp () const
 
TQuaternion< T > & rcpLocal ()
 
sum () const
 
avg () const
 
product () const
 
min () const
 
TQuaternion< T > min (const TQuaternion< T > &other) const
 
std::size_t minIndex () const
 
max () const
 
TQuaternion< T > max (const TQuaternion< T > &other) const
 
std::size_t maxIndex () const
 
TQuaternion< T > ceil () const
 
TQuaternion< T > floor () const
 
TQuaternion< T > lerp (const TQuaternion< T > &rhs, U factor) const
 
bool isZero () const
 
bool isNonNegative () const
 
bool isFinite () const
 
TQuaternion< T > & set (T value)
 
TQuaternion< T > & set (std::size_t index, T value)
 
TQuaternion< T > & set (const std::array< T, N > &values)
 
T & operator[] (std::size_t index)
 
const T & operator[] (std::size_t index) const
 
bool isEqual (const TQuaternion< T > &other) const
 
bool isNear (const TQuaternion< T > &other, T margin) const
 
bool operator== (const TQuaternion< T > &other) const
 
bool operator!= (const TQuaternion< T > &other) const
 
TQuaternion< T > operator+ (const TQuaternion< T > &rhs) const
 
TQuaternion< T > operator+ (T rhs) const
 
TQuaternion< T > operator- (const TQuaternion< T > &rhs) const
 
TQuaternion< T > operator- (T rhs) const
 
TQuaternion< T > operator- () const
 
TQuaternion< T > operator* (const TQuaternion< T > &rhs) const
 
TQuaternion< T > operator* (T rhs) const
 
TQuaternion< T > operator/ (const TQuaternion< T > &rhs) const
 
TQuaternion< T > operator/ (T rhs) const
 
TQuaternion< T > & operator+= (const TQuaternion< T > &rhs)
 
TQuaternion< T > & operator+= (T rhs)
 
TQuaternion< T > & operator-= (const TQuaternion< T > &rhs)
 
TQuaternion< T > & operator-= (T rhs)
 
TQuaternion< T > & operator*= (const TQuaternion< T > &rhs)
 
TQuaternion< T > & operator*= (T rhs)
 
TQuaternion< T > & operator/= (const TQuaternion< T > &rhs)
 
TQuaternion< T > & operator/= (T rhs)
 
auto begin () noexcept -> typename std::array< T, N >::iterator
 
auto begin () const noexcept -> typename std::array< T, N >::const_iterator
 
auto end () noexcept -> typename std::array< T, N >::iterator
 
auto end () const noexcept -> typename std::array< T, N >::const_iterator
 
std::string toString () const
 
std::vector< T > toVector () const
 
std::array< T, N > toArray () const
 
TSpan< T, N > toSpan ()
 
TSpanView< T, N > toView () const
 
TQuaternion< T > exp (U exponent) const
 Sets the array to \( e^exponent \).
 
TQuaternion< T > & expLocal (U exponent)
 
TQuaternion< T > exp (const TQuaternion< T > &exponent) const
 Sets the array to \( e^{exponent_i} \).
 
TQuaternion< T > & expLocal (const TQuaternion< T > &exponent)
 
TQuaternion< T > clamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. None of value, lowerBound and upperBound can be NaN, or the method's behavior is undefined.
 
TQuaternion< T > clamp (const TQuaternion< T > &lowerBound, const TQuaternion< T > &upperBound) const
 
TQuaternion< T > & clampLocal (T lowerBound, T upperBound)
 
TQuaternion< T > & clampLocal (const TQuaternion< T > &lowerBound, const TQuaternion< T > &upperBound)
 
TQuaternion< T > safeClamp (T lowerBound, T upperBound) const
 Clamps current array's elements to specific range. If a floating-point value is non-finite (e.g., being Inf, NaN), its value is clamped to lowerBound. Neither lowerBound nor upperBound can be NaN, or the method's behavior is undefined.
 
TQuaternion< T > safeClamp (const TQuaternion< T > &lowerBound, const TQuaternion< T > &upperBound) const
 
TQuaternion< T > & safeClampLocal (T lowerBound, T upperBound)
 
TQuaternion< T > & safeClampLocal (const TQuaternion< T > &lowerBound, const TQuaternion< T > &upperBound)
 
TQuaternion< T > complement () const
 Complements the array's elements. Effectively performing 1 - (*this)[i] for each element.
 
TQuaternion< T > & complementLocal ()
 
TQuaternion< T > negate () const
 Applies a negative sign to the array's elements. These methods is only defined for signed element types.
 
TQuaternion< T > & negateLocal ()
 
- Protected Attributes inherited from ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >
std::array< T, N > m
 
- Static Protected Attributes inherited from ph::math::TArithmeticArrayBase< TQuaternion< T >, T, 4 >
static constexpr auto NUM_ELEMENTS
 

Detailed Description

template<typename T>
class ph::math::TQuaternion< T >

Represents a quaternion.

Constructor & Destructor Documentation

◆ TQuaternion() [1/5]

template<typename T >
ph::math::TQuaternion< T >::TQuaternion ( T vx,
T vy,
T vz,
T vw )
inline

◆ TQuaternion() [2/5]

template<typename T >
template<typename U >
ph::math::TQuaternion< T >::TQuaternion ( const TQuaternion< U > & other)
inlineexplicit

◆ TQuaternion() [3/5]

template<typename T >
template<typename U >
ph::math::TQuaternion< T >::TQuaternion ( const std::array< U, 4 > & xyzwValues)
inlineexplicit

◆ TQuaternion() [4/5]

template<typename T >
ph::math::TQuaternion< T >::TQuaternion ( const TVector3< T > & normalizedAxis,
T radians )
inline

◆ TQuaternion() [5/5]

template<typename T >
ph::math::TQuaternion< T >::TQuaternion ( const TMatrix4< T > & rotationMatrix)
inlineexplicit

Member Function Documentation

◆ add()

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::add ( const TQuaternion< T > & rhs) const
inline

◆ conjugate() [1/2]

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::conjugate ( ) const
inline

◆ conjugate() [2/2]

template<typename T >
void ph::math::TQuaternion< T >::conjugate ( TQuaternion< T > * out_result) const
inline

◆ conjugateLocal()

template<typename T >
TQuaternion< T > & ph::math::TQuaternion< T >::conjugateLocal ( )
inline

◆ dot()

template<typename T >
T ph::math::TQuaternion< T >::dot ( const TQuaternion< T > & rhs) const
inline

◆ length()

template<typename T >
T ph::math::TQuaternion< T >::length ( ) const
inline

◆ makeNoRotation()

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::makeNoRotation ( )
inlinestatic

◆ mul() [1/3]

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::mul ( const TQuaternion< T > & rhs) const
inline

◆ mul() [2/3]

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::mul ( const TVector3< T > & xyz) const
inline

Quaternion multiplication (treating the input's w component as 0).

◆ mul() [3/3]

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::mul ( T rhs) const
inline

◆ mulLocal()

template<typename T >
TQuaternion< T > & ph::math::TQuaternion< T >::mulLocal ( const TQuaternion< T > & rhs)
inline

◆ normalize()

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::normalize ( ) const
inline

◆ normalizeLocal()

template<typename T >
TQuaternion< T > & ph::math::TQuaternion< T >::normalizeLocal ( )
inline

◆ PH_DEFINE_INLINE_RULE_OF_5_MEMBERS()

template<typename T >
ph::math::TQuaternion< T >::PH_DEFINE_INLINE_RULE_OF_5_MEMBERS ( TQuaternion< T > )

◆ setRot()

template<typename T >
void ph::math::TQuaternion< T >::setRot ( const TVector3< T > & normalizedAxis,
T radians )
inline

◆ sub()

template<typename T >
TQuaternion< T > ph::math::TQuaternion< T >::sub ( const TQuaternion< T > & rhs) const
inline

◆ toRotationMatrix()

template<typename T >
void ph::math::TQuaternion< T >::toRotationMatrix ( TMatrix4< T > * out_result) const
inline

◆ w() [1/2]

template<typename T >
T & ph::math::TQuaternion< T >::w ( )
inline

◆ w() [2/2]

template<typename T >
const T & ph::math::TQuaternion< T >::w ( ) const
inline

◆ x() [1/2]

template<typename T >
T & ph::math::TQuaternion< T >::x ( )
inline

◆ x() [2/2]

template<typename T >
const T & ph::math::TQuaternion< T >::x ( ) const
inline

◆ y() [1/2]

template<typename T >
T & ph::math::TQuaternion< T >::y ( )
inline

◆ y() [2/2]

template<typename T >
const T & ph::math::TQuaternion< T >::y ( ) const
inline

◆ z() [1/2]

template<typename T >
T & ph::math::TQuaternion< T >::z ( )
inline

◆ z() [2/2]

template<typename T >
const T & ph::math::TQuaternion< T >::z ( ) const
inline

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