Atoms Crowd  7.0.0
Quat< T > Class Template Reference

#include <ImathQuat.h>

Public Types

typedef T BaseType
 

Public Member Functions

ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T & operator[] (int index) noexcept
 
constexpr ATOMSMATH_HOSTDEVICE T operator[] (int index) const noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 Quat (const Quat< S > &q) noexcept
 
template<class S >
constexpr bool operator== (const Quat< S > &q) const noexcept
 
template<class S >
constexpr bool operator!= (const Quat< S > &q) const noexcept
 
Basic Algebra

Note that the operator return values are NOT normalized

ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator*= (const Quat< T > &q) noexcept
 Quaternion multiplication.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator*= (T t) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator/= (const Quat< T > &q) noexcept
 Quaterion division, using the inverse()
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator/= (T t) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator+= (const Quat< T > &q) noexcept
 Quaternion addition.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator-= (const Quat< T > &q) noexcept
 Quaternion subtraction.
 
template<class S >
constexpr ATOMSMATH_HOSTDEVICE bool operator== (const Quat< S > &q) const noexcept
 Equality.
 
template<class S >
constexpr ATOMSMATH_HOSTDEVICE bool operator!= (const Quat< S > &q) const noexcept
 Inequality.
 
Query
constexpr ATOMSMATH_HOSTDEVICE T length () const noexcept
 Return the R4 length.
 
constexpr ATOMSMATH_HOSTDEVICE T angle () const noexcept
 Return the angle of the axis/angle representation.
 
constexpr ATOMSMATH_HOSTDEVICE Vec3< T > axis () const noexcept
 Return the axis of the axis/angle representation.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix33< T > toMatrix33 () const noexcept
 Return a 3x3 rotation matrix.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44< T > toMatrix44 () const noexcept
 Return a 4x4 rotation matrix.
 
ATOMSMATH_HOSTDEVICE Quat< T > log () const noexcept
 Return the logarithm of the quaterion.
 
ATOMSMATH_HOSTDEVICE Quat< T > exp () const noexcept
 Return the exponent of the quaterion.
 
Utility Methods
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > & invert () noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > inverse () const noexcept
 Return 1/this, leaving this unchanged.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > & normalize () noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > normalized () const noexcept
 Return a normalized quaternion, leaving this unmodified.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Vec3< T > rotateVector (const Vec3< T > &original) const noexcept
 Rotate the given point by the quaterion.
 
constexpr ATOMSMATH_HOSTDEVICE T euclideanInnerProduct (const Quat< T > &q) const noexcept
 Return the Euclidean inner product.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > & setAxisAngle (const Vec3< T > &axis, T radians) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat< T > & setRotation (const Vec3< T > &fromDirection, const Vec3< T > &toDirection) noexcept
 

Public Attributes

Direct access to elements
r
 The real part.
 
Vec3< T > v
 The imaginary vector.
 

Constructors

constexpr ATOMSMATH_HOSTDEVICE Quat () noexcept
 Default constructor is the identity quat.
 
constexpr ATOMSMATH_HOSTDEVICE Quat (const Quat &q) noexcept
 Copy constructor.
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Quat (const Quat< S > &q) noexcept
 Construct from a quaternion of a another base type.
 
constexpr ATOMSMATH_HOSTDEVICE Quat (T s, T i, T j, T k) noexcept
 Initialize with real part s and imaginary vector 1(i,j,k)`.
 
constexpr ATOMSMATH_HOSTDEVICE Quat (T s, Vec3< T > d) noexcept
 Initialize with real part s and imaginary vector d
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Quat< T > & operator= (const Quat< T > &q) noexcept
 Assignment.
 
 ~Quat () noexcept=default
 Destructor.
 
constexpr static ATOMSMATH_HOSTDEVICE Quat< T > identity () noexcept
 The identity quaternion.
 

Detailed Description

template<class T>
class Quat< T >

The Quat class implements the quaternion numerical type – you will probably want to use this class to represent orientations in R3 and to convert between various euler angle reps. You should probably use Imath::Euler<> for that.

Member Typedef Documentation

◆ BaseType

template<class T >
typedef T Quat< T >::BaseType

The base type: In templates that accept a parameter V, you can refer to T as V::BaseType

Member Function Documentation

◆ invert()

template<class T >
ATOMSMATH_CONSTEXPR14 Quat< T > & Quat< T >::invert
inlinenoexcept

Invert in place: this = 1 / this.

Returns
const reference to this.

◆ normalize()

template<class T >
ATOMSMATH_CONSTEXPR14 Quat< T > & Quat< T >::normalize
inlinenoexcept

Normalize in place

Returns
const reference to this.

◆ operator*=()

template<class T >
ATOMSMATH_CONSTEXPR14 const Quat< T > & Quat< T >::operator*= ( t)
inlinenoexcept

Scalar multiplication: multiply both real and imaginary parts by the given scalar.

◆ operator/=()

template<class T >
ATOMSMATH_CONSTEXPR14 const Quat< T > & Quat< T >::operator/= ( t)
inlinenoexcept

Scalar division: multiply both real and imaginary parts by the given scalar.

◆ operator[]() [1/2]

template<class T >
constexpr T Quat< T >::operator[] ( int  index) const
inlineconstexprnoexcept

Element access: q[0] is the real part, (q[1],q[2],q[3]) is the imaginary part.

◆ operator[]() [2/2]

template<class T >
ATOMSMATH_CONSTEXPR14 T & Quat< T >::operator[] ( int  index)
inlinenoexcept

Element access: q[0] is the real part, (q[1],q[2],q[3]) is the imaginary part.

◆ setAxisAngle()

template<class T >
ATOMSMATH_CONSTEXPR14 Quat< T > & Quat< T >::setAxisAngle ( const Vec3< T > &  axis,
radians 
)
inlinenoexcept

Set the quaterion to be a rotation around the given axis by the given angle.

Returns
const reference to this.

◆ setRotation()

template<class T >
ATOMSMATH_CONSTEXPR14 Quat< T > & Quat< T >::setRotation ( const Vec3< T > &  fromDirection,
const Vec3< T > &  toDirection 
)
inlinenoexcept

Set the quaternion to be a rotation that transforms the direction vector fromDirection to toDirection

Returns
const reference to this.

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