DubiousEngine
0.2.0
Simple Game Engine
|
Unit Quaternions are used to represent rotation. More...
#include <Unit_quaternion.h>
Public Member Functions | |
Unit_quaternionT ()=default | |
Default Constructor. More... | |
Unit_quaternionT (const QuaternionT< T > &q) | |
Copy Constructor. More... | |
Unit_quaternionT (const Unit_vectorT< T > &axis, float angle) | |
Construct from axis and angle. More... | |
float | w () const |
real component accessor More... | |
const VectorT< T > & | v () const |
imaginary component accessor More... | |
Unit_quaternionT | conjugate () const |
The conjugate. More... | |
void | get_matrix (float matrix[16]) const |
Get the rotation matrix. More... | |
std::tuple< Unit_vectorT< T >, float > | get_axis_angle () const |
Get the Axis and Angle. More... | |
Unit_quaternionT< T > | operator- () const |
Friends | |
class | Math_test::Unit_quaternion_test |
class | Physics_test::Collision_solver_test |
class | Coordinate_space |
Unit_quaternionT< T > | operator* (const Unit_quaternionT< T > &a, const Unit_quaternionT< T > &b) |
Unit Quaternions are used to represent rotation.
Everyone's favorite 4 dimensional, completely mysterious mathmatical construct. Quaternions with magnitude 1, Unit Quaternions, can be used to represent rotations in 3D space. This class implements all of the basic math (basically copy and paste of that found in Quaternion) but with more careful considerations for type conversions back to non-Unit Quaternions. It goes a bit further to include some functions for converting to other rotation representations.
Here are some resources I found useful in understanding Quaternions https://www.youtube.com/watch?v=mHVwd8gYLnI https://www.3dgep.com/understanding-quaternions/
|
default |
Default Constructor.
Will create a Quaternion that has X, Y, Z axis aligned with the global X, Y, and Z.
Dubious::Math::Unit_quaternionT< T >::Unit_quaternionT | ( | const QuaternionT< T > & | q | ) |
Copy Constructor.
Dubious::Math::Unit_quaternionT< T >::Unit_quaternionT | ( | const Unit_vectorT< T > & | axis, |
float | angle | ||
) |
Construct from axis and angle.
This is a more useful constructor where you can specify an axis and an angle around that axis. This is a right hand coordinate system, so the angle is counter-clockwise rotation around the axis
axis | - [in] The axis around which we will rotate |
angle | - [in] Magnitude of Rotation (in radians) |
|
inline |
The conjugate.
The conjugate is simply (w, -v) The magnitude of the Unit Quaternion is maintained
std::tuple< Unit_vectorT< T >, float > Dubious::Math::Unit_quaternionT< T >::get_axis_angle | ( | ) | const |
Get the Axis and Angle.
Return a unit vector representing the axis of rotation, as well as a float representing the angle around that axis, in radians
void Dubious::Math::Unit_quaternionT< T >::get_matrix | ( | float | matrix[16] | ) | const |
Get the rotation matrix.
Return the rotation matrix representation of this quaternion. This is basically a shortcut for OpenGL rotation as it takes this same matrix as an input. It's also handy for finding the three axis of rotation in one call
matrix | - [out] Will be filled with the rotation matrix |
|
inline |
|
inline |
imaginary component accessor
|
inline |
real component accessor
|
friend |
|
friend |
|
friend |
|
friend |