A 4-dimensional unit vector used to store a rotation. More...
#include <matvec3D.h>
Public Member Functions | |
Quaternion | inverse () const |
double | norm () const |
void | normalise () |
double | operator% (const Quaternion &q) const |
position | operator* (const position &pt) const |
vec3 | operator* (const vec3 &v) const |
Quaternion | operator* (const Quaternion &q) const |
Quaternion | operator+ (const Quaternion &q) const |
Quaternion | operator- () const |
Quaternion | operator- (const Quaternion &q) const |
Quaternion & | operator= (const Quaternion &q) |
bool | operator== (Quaternion const &q) const |
Quaternion (const double &angle, const vec3 &axis) | |
Quaternion (const mat3 &R) | |
Quaternion (double W, double X, double Y, double Z) | |
Quaternion () | |
void | set (const SbRotation &SbRot) |
void | set (const double &angle, const vec3 &axis) |
void | set (const mat3 &R) |
void | set (double W, double X, double Y, double Z) |
void | set (const Quaternion &Q) |
void | ToAngleAxis (double &angle, vec3 &axis) const |
void | ToRotationMatrix (mat3 &m) const |
SbRotation | toSbRotation () const |
Static Public Member Functions | |
static void | Intermediate (const Quaternion &q0, const Quaternion &q1, const Quaternion &q2, Quaternion &a, Quaternion &b) |
static Quaternion | Slerp (double t, const Quaternion &p, const Quaternion &q) |
static Quaternion | Squad (double t, const Quaternion &p, const Quaternion &a, const Quaternion &b, const Quaternion &q) |
Public Attributes | |
double | w |
The four scalar components of a quaternion. | |
double | x |
double | y |
double | z |
Static Public Attributes | |
static const Quaternion | IDENTITY |
An identity rotation [1,0,0,0]. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Quaternion &q) |
std::istream & | operator>> (std::istream &is, Quaternion &q) |
A 4-dimensional unit vector used to store a rotation.
Quaternions are an efficient way to store and manipulate rotations.
Definition at line 339 of file matvec3D.h.
Quaternion::Quaternion | ( | ) | [inline] |
Default constructor, Quaternion is initialized to an identity rotation
Definition at line 345 of file matvec3D.h.
Quaternion::Quaternion | ( | double | W, | |
double | X, | |||
double | Y, | |||
double | Z | |||
) | [inline] |
Initializes quaternion with 4 scalar values (automatically normalized).
Definition at line 348 of file matvec3D.h.
Quaternion::Quaternion | ( | const mat3 & | R | ) | [inline] |
Initializes quaternion using a rotation matrix R.
Definition at line 351 of file matvec3D.h.
Quaternion::Quaternion | ( | const double & | angle, | |
const vec3 & | axis | |||
) | [inline] |
Initializes quaternion using a rotation exressed as in angle and axis format.
Definition at line 355 of file matvec3D.h.
static void Quaternion::Intermediate | ( | const Quaternion & | q0, | |
const Quaternion & | q1, | |||
const Quaternion & | q2, | |||
Quaternion & | a, | |||
Quaternion & | b | |||
) | [static] |
Quaternion Quaternion::inverse | ( | ) | const [inline] |
Returns the inverse quaternion.
Definition at line 1131 of file matvec3D.h.
double Quaternion::norm | ( | ) | const [inline] |
Returns the norm of the quaternion.
Definition at line 1124 of file matvec3D.h.
void Quaternion::normalise | ( | ) | [inline] |
Normalizes this quaternion.
Definition at line 1199 of file matvec3D.h.
double Quaternion::operator% | ( | const Quaternion & | q | ) | const [inline] |
Returns the dot product of this quaternion and q.
Definition at line 1117 of file matvec3D.h.
Returns the position p after it has been rotated by this quaternion.
Definition at line 1172 of file matvec3D.h.
Returns the vector v after it has been rotated by this quaternion.
Definition at line 1139 of file matvec3D.h.
Quaternion Quaternion::operator* | ( | const Quaternion & | q | ) | const [inline] |
Returns the normalized result of multiplying this quaternion by q.
Definition at line 1083 of file matvec3D.h.
Quaternion Quaternion::operator+ | ( | const Quaternion & | q | ) | const [inline] |
Returns the normalized result of adding q to this quaternion.
Definition at line 1069 of file matvec3D.h.
Quaternion Quaternion::operator- | ( | ) | const [inline] |
Unary negation operator. Negates each component of the quaternion.
Definition at line 1110 of file matvec3D.h.
Quaternion Quaternion::operator- | ( | const Quaternion & | q | ) | const [inline] |
Returns the normalized result of subtracting q from this quaternion.
Definition at line 1076 of file matvec3D.h.
Quaternion & Quaternion::operator= | ( | const Quaternion & | q | ) | [inline] |
Assignment operator, copies quaternion q.
Definition at line 1061 of file matvec3D.h.
bool Quaternion::operator== | ( | Quaternion const & | q | ) | const [inline] |
Comparison operator, returns true if the L2 distance between this quaternion and q is less than resabs.
Definition at line 1189 of file matvec3D.h.
void Quaternion::set | ( | const SbRotation & | SbRot | ) |
Sets this quaternion by converting from Inventor format.
Definition at line 294 of file matvec.cpp.
void Quaternion::set | ( | const double & | angle, | |
const vec3 & | axis | |||
) |
Sets this quaternion by converting the rotation from angle-axis formate. The angle is specified in radians.
Definition at line 274 of file matvec.cpp.
void Quaternion::set | ( | const mat3 & | R | ) |
Sets this quaternion by converting from rotation matrix R.
Definition at line 228 of file matvec.cpp.
void Quaternion::set | ( | double | W, | |
double | X, | |||
double | Y, | |||
double | Z | |||
) | [inline] |
Sets the value of the quaternion using 4 scalars and normalizes it.
Definition at line 362 of file matvec3D.h.
void Quaternion::set | ( | const Quaternion & | Q | ) | [inline] |
Copies the values of quaterion Q.
Definition at line 358 of file matvec3D.h.
Quaternion Quaternion::Slerp | ( | double | t, | |
const Quaternion & | p, | |||
const Quaternion & | q | |||
) | [static] |
Computes a rotation between p and q using spherical linear interpolation and the scalar t [0..1]. If t is 0, p will be returned. If t is 1, q will be returned.
Definition at line 367 of file matvec.cpp.
static Quaternion Quaternion::Squad | ( | double | t, | |
const Quaternion & | p, | |||
const Quaternion & | a, | |||
const Quaternion & | b, | |||
const Quaternion & | q | |||
) | [static] |
void Quaternion::ToAngleAxis | ( | double & | angle, | |
vec3 & | axis | |||
) | const |
Converts this quaternion to angle-axis format.
Definition at line 337 of file matvec.cpp.
void Quaternion::ToRotationMatrix | ( | mat3 & | R | ) | const |
Converts this quaternion to a 3x3 rotation matrix.
Definition at line 307 of file matvec.cpp.
SbRotation Quaternion::toSbRotation | ( | ) | const [inline] |
Converts a quaternion into an Inventor style SbRotation. Inventor stores their quaternions in a slightly different order, and uses floats.
Definition at line 1054 of file matvec3D.h.
std::ostream& operator<< | ( | std::ostream & | os, | |
const Quaternion & | q | |||
) | [friend] |
Writes the 4 values of a quaternion q in the format "(w, x, y, z)" to as stream os.
Definition at line 539 of file matvec.cpp.
std::istream& operator>> | ( | std::istream & | is, | |
Quaternion & | q | |||
) | [friend] |
Reads the 4 values of a quaternion q formatted as "(w, x, y, z)" from a stream is.
Definition at line 520 of file matvec.cpp.
const Quaternion Quaternion::IDENTITY [static] |
An identity rotation [1,0,0,0].
Definition at line 412 of file matvec3D.h.
double Quaternion::w |
The four scalar components of a quaternion.
Definition at line 342 of file matvec3D.h.
double Quaternion::x |
Definition at line 342 of file matvec3D.h.
double Quaternion::y |
Definition at line 342 of file matvec3D.h.
double Quaternion::z |
Definition at line 342 of file matvec3D.h.