EMAN2
|
Quaternion is used in Rotation and Transformation to replace Euler angles. More...
#include <quaternion.h>
Public Member Functions | |
Quaternion () | |
Quaternion (float e0, float e1, float e2, float e3) | |
Quaternion (float radians, const Vec3f &axis) | |
Quaternion (const Vec3f &axis, float radians) | |
Quaternion (const vector< float > &matrix3) | |
~Quaternion () | |
float | norm () const |
Quaternion | conj () const |
float | abs () const |
void | normalize () |
Quaternion & | inverse () |
Quaternion | create_inverse () const |
Vec3f | rotate (const Vec3f &v) const |
float | to_angle () const |
Vec3f | to_axis () const |
vector< float > | to_matrix3 () const |
float | real () const |
Vec3f | unreal () const |
vector< float > | as_list () const |
Quaternion & | operator+= (const Quaternion &q) |
Quaternion & | operator-= (const Quaternion &q) |
Quaternion & | operator*= (const Quaternion &q) |
Quaternion & | operator*= (float s) |
Quaternion & | operator/= (const Quaternion &q) |
Quaternion & | operator/= (float s) |
Static Public Member Functions | |
static Quaternion | interpolate (const Quaternion &from, const Quaternion &to, float percent) |
Private Attributes | |
float | e0 |
float | e1 |
float | e2 |
float | e3 |
Quaternion is used in Rotation and Transformation to replace Euler angles.
Quaternions extend the concept of rotation in three dimensions to rotation in four dimensions. This avoids the problem of "gimbal-lock" and allows for the implementation of smooth and continuous rotation.
Euler angles have the disadvantage of being susceptible to "Gimbal lock" where attempts to rotate an object fail due to the order in which the rotations are performed.
Quaternions are a solution to this problem. Instead of rotating an object through a series of successive rotations, a quaternion allows the programmer to rotate an object through a single arbitary rotation axis.
Because the rotation axis is specifed as a unit direction vector, it may be calculated through vector mathematics or from spherical coordinates ie (longitude/latitude).
Quaternions offer another advantage in that they be interpolated. This allows for smooth and predictable rotation effects.
Definition at line 61 of file quaternion.h.
Quaternion::Quaternion | ( | ) |
Quaternion::Quaternion | ( | float | e0, |
float | e1, | ||
float | e2, | ||
float | e3 | ||
) |
Quaternion::Quaternion | ( | float | radians, |
const Vec3f & | axis | ||
) |
Quaternion::Quaternion | ( | const Vec3f & | axis, |
float | radians | ||
) |
|
explicit |
Definition at line 73 of file quaternion.cpp.
|
inline |
Definition at line 70 of file quaternion.h.
|
inline |
Definition at line 84 of file quaternion.h.
vector< float > Quaternion::as_list | ( | ) | const |
|
inline |
Quaternion Quaternion::create_inverse | ( | ) | const |
Definition at line 138 of file quaternion.cpp.
References inverse().
|
static |
Definition at line 372 of file quaternion.cpp.
Quaternion & Quaternion::inverse | ( | ) |
|
inline |
void Quaternion::normalize | ( | ) |
Quaternion & Quaternion::operator*= | ( | const Quaternion & | q | ) |
Definition at line 247 of file quaternion.cpp.
Quaternion & Quaternion::operator*= | ( | float | s | ) |
Quaternion & Quaternion::operator+= | ( | const Quaternion & | q | ) |
Quaternion & Quaternion::operator-= | ( | const Quaternion & | q | ) |
Quaternion & Quaternion::operator/= | ( | const Quaternion & | q | ) |
Definition at line 274 of file quaternion.cpp.
Quaternion & Quaternion::operator/= | ( | float | s | ) |
float Quaternion::real | ( | ) | const |
Definition at line 145 of file quaternion.cpp.
References EMAN::Vec3< Type >::cross(), e0, e1, e2, and e3.
float Quaternion::to_angle | ( | ) | const |
Definition at line 156 of file quaternion.cpp.
References e0, e1, e2, e3, and EMAN::Vec3< Type >::length().
Vec3f Quaternion::to_axis | ( | ) | const |
Definition at line 171 of file quaternion.cpp.
References e1, e2, e3, EMAN::Vec3< Type >::length(), and EMAN::Vec3< Type >::set_value().
vector< float > Quaternion::to_matrix3 | ( | ) | const |
Definition at line 187 of file quaternion.cpp.
Vec3f Quaternion::unreal | ( | ) | const |
Definition at line 213 of file quaternion.cpp.
|
private |
Definition at line 115 of file quaternion.h.
Referenced by as_list(), conj(), interpolate(), inverse(), norm(), normalize(), operator*=(), operator+=(), operator-=(), operator/=(), Quaternion(), real(), rotate(), to_angle(), and to_matrix3().
|
private |
Definition at line 116 of file quaternion.h.
Referenced by as_list(), conj(), interpolate(), inverse(), norm(), normalize(), operator*=(), operator+=(), operator-=(), operator/=(), Quaternion(), rotate(), to_angle(), to_axis(), to_matrix3(), and unreal().
|
private |
Definition at line 117 of file quaternion.h.
Referenced by as_list(), conj(), interpolate(), inverse(), norm(), normalize(), operator*=(), operator+=(), operator-=(), operator/=(), Quaternion(), rotate(), to_angle(), to_axis(), to_matrix3(), and unreal().
|
private |
Definition at line 118 of file quaternion.h.
Referenced by as_list(), conj(), interpolate(), inverse(), norm(), normalize(), operator*=(), operator+=(), operator-=(), operator/=(), Quaternion(), rotate(), to_angle(), to_axis(), to_matrix3(), and unreal().