Theoretica
A C++ numerical and automatic mathematical library
theoretica::quat< Type > Class Template Reference

Quaternion class in the form \(a + bi + cj + dk\). More...

#include <quat.h>

Public Member Functions

 quat ()
 Construct a quaternion with all zero components.
 
 quat (Type r)
 Construct a quaternion from a real number.
 
 quat (Type a, Type b, Type c, Type d)
 Construct a quaternion from its components.
 
 quat (const quat &q)
 Copy constructor.
 
quatoperator= (const quat &q)
 Assignment operator.
 
template<typename T >
quatoperator= (const std::array< T, 4 > &v)
 Assignment operator from a 4D array.
 
Type Re () const
 Get the real part of the quaternion.
 
Type Im1 () const
 Get the first imaginary part of the quaternion.
 
Type Im2 () const
 Get the second imaginary part of the quaternion.
 
Type Im3 () const
 Get the third imaginary part of the quaternion.
 
quat conjugate () const
 Compute the conjugate of the quaternion.
 
Type sqr_norm () const
 Compute the square norm of the quaternion.
 
Type norm () const
 Compute the norm of the quaternion.
 
quat inverse () const
 Compute the inverse of the quaternion.
 
quatinvert ()
 Invert the quaternion.
 
quat operator+ () const
 Identity (for consistency)
 
quat operator- () const
 Get the opposite of the quaternion.
 
quat operator+ (Type k) const
 Sum a quaternion and a scalar value.
 
quat operator- (Type k) const
 Subtract a quaternion and a scalar value.
 
quat operator* (Type k) const
 Multiply a quaternion by a scalar value.
 
quat operator/ (Type k) const
 Divide a quaternion by a scalar value.
 
quat operator+ (const quat &other) const
 Add two quaternions.
 
quat operator- (const quat &other) const
 Subtract two quaternions.
 
quat operator* (const quat &q) const
 Multiply two quaternions.
 
quat operator/ (const quat &other) const
 Divide two quaternions.
 
quatoperator*= (Type k)
 Multiply this quaternion by a scalar value.
 
quatoperator/= (Type k)
 Divide this quaternion by a scalar value.
 
quatoperator+= (const quat &other)
 Add a quaternion to this one.
 
quatoperator-= (const quat &other)
 Subtract a quaternion to this one.
 
quatoperator*= (const quat &other)
 Multiply this quaternion by another one.
 
quatoperator/= (const quat &other)
 Divide this quaternion by another one.
 
template<typename Vector >
Vector transform (const Vector &v) const
 Transform a 3D vector.
 
std::string to_string () const
 Convert the quaternion to string representation.
 
 operator std::string ()
 Convert the quaternion to string representation.
 

Static Public Member Functions

template<typename Vector >
static quat rotation (Type rad, const Vector &axis)
 Construct a quaternion which represents a rotation of <rad> radians around the <axis> arbitrary axis.
 
template<typename Vector >
static Vector rotate (const Vector &v, Type rad, const Vector &axis)
 Rotate a 3D vector <v> by <rad> radians around the <axis> arbitrary axis.
 

Public Attributes

Type a
 Real part.
 
Type b
 Imaginary parts.
 
Type c
 
Type d
 

Friends

Type Re (const quat &q)
 Extract the real part of the quaternion.
 
Type Im1 (const quat &q)
 Extract the first imaginary part of the quaternion.
 
Type Im2 (const quat &q)
 Extract the second imaginary part of the quaternion.
 
Type Im3 (const quat &q)
 Extract the third imaginary part of the quaternion.
 
quat operator+ (Type r, const quat &z)
 
quat operator- (Type r, const quat &z)
 
quat operator* (Type r, const quat &z)
 
quat operator/ (Type r, const quat &z)
 
std::ostream & operator<< (std::ostream &out, const quat &obj)
 Stream the quaternion in string representation to an output stream (std::ostream)
 

Detailed Description

template<typename Type = real>
class theoretica::quat< Type >

Quaternion class in the form \(a + bi + cj + dk\).


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