Panda3D
|
This is the base quaternion class. More...
#include "lquaternion.h"
Public Member Functions | |
LQuaterniond (const LVecBase4d ©) | |
LQuaterniond (double, double, double, double) | |
LQuaterniond (double, const LVecBase3d ©) | |
bool | almost_equal (const LQuaterniond &other) const |
Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type. | |
bool | almost_equal (const LQuaterniond &other, double threshold) const |
Returns true if two quaternions are memberwise equal within a specified tolerance. | |
bool | almost_same_direction (const LQuaterniond &other, double threshold) const |
Returns true if two quaternions represent the same rotation within a specified tolerance. | |
double | angle_deg (const LQuaterniond &other) const |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees. | |
double | angle_rad (const LQuaterniond &other) const |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians. | |
LQuaterniond | conjugate () const |
Returns the complex conjugate of this quat. | |
bool | conjugate_from (const LQuaterniond &other) |
Computes the conjugate of the other quat, and stores the result in this quat. | |
bool | conjugate_in_place () |
Sets this to be the conjugate of the current quat. | |
void | extract_to_matrix (LMatrix3d &m) const |
Based on the quat lib from VRPN. | |
void | extract_to_matrix (LMatrix4d &m) const |
Based on the quat lib from VRPN. | |
double | get_angle () const |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
double | get_angle_rad () const |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
LVector3d | get_axis () const |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
LVector3d | get_axis_normalized () const |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
LVector3d | get_forward (CoordinateSystem cs=CS_default) const |
Returns the orientation represented by this quaternion, expressed as a forward vector. | |
LVecBase3d | get_hpr (CoordinateSystem cs=CS_default) const |
Extracts the equivalent Euler angles from the unit quaternion. | |
double | get_i () const |
double | get_j () const |
double | get_k () const |
double | get_r () const |
LVector3d | get_right (CoordinateSystem cs=CS_default) const |
Returns the orientation represented by this quaternion, expressed as a right vector. | |
LVector3d | get_up (CoordinateSystem cs=CS_default) const |
Returns the orientation represented by this quaternion, expressed as an up vector. | |
bool | invert_from (const LQuaterniond &other) |
Computes the inverse of the other quat, and stores the result in this quat. | |
bool | invert_in_place () |
Inverts the current quat. | |
bool | is_almost_identity (double tolerance) const |
Returns true if this quaternion represents the identity transformation within a given tolerance. | |
bool | is_identity () const |
Returns true if this quaternion represents the identity transformation: no rotation. | |
bool | is_same_direction (const LQuaterniond &other) const |
Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type. | |
LQuaterniond | multiply (const LQuaterniond &rhs) const |
actual multiply call (non virtual) | |
bool | normalize () |
Normalizes the vector in place. | |
LQuaterniond | operator* (const LQuaterniond &) const |
LMatrix3d | operator* (const LMatrix3d &) |
Quat * Matrix = matrix. | |
LMatrix4d | operator* (const LMatrix4d &) |
Quat * Matrix = matrix. | |
LQuaterniond | operator* (double scalar) const |
LQuaterniond & | operator*= (const LQuaterniond &) |
LQuaterniond | operator+ (const LQuaterniond &other) const |
LQuaterniond | operator- () const |
LQuaterniond | operator- (const LQuaterniond &other) const |
LQuaterniond | operator/ (double scalar) const |
void | output (ostream &) const |
void | set_from_axis_angle (double angle_deg, const LVector3d &axis) |
angle_deg is the angle about the axis in degrees. | |
void | set_from_axis_angle_rad (double angle_rad, const LVector3d &axis) |
angle_rad is the angle about the axis in radians. | |
void | set_from_matrix (const LMatrix3d &m) |
Sets the quaternion according to the rotation represented by the matrix. | |
void | set_from_matrix (const LMatrix4d &m) |
void | set_hpr (const LVecBase3d &hpr, CoordinateSystem cs=CS_default) |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles. | |
void | set_i (double i) |
void | set_j (double j) |
void | set_k (double k) |
void | set_r (double r) |
LVecBase4d | xform (const LVecBase4d &v) const |
Transforms a 4-d vector by the indicated rotation. | |
LVecBase3d | xform (const LVecBase3d &v) const |
Transforms a 3-d vector by the indicated rotation. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static const LQuaterniond & | ident_quat () |
Returns an identity quaternion. | |
static void | init_type () |
static LQuaterniond | pure_imaginary (const LVector3d &) |
This is the base quaternion class.
Definition at line 963 of file lquaternion.h.
bool LQuaterniond::almost_equal | ( | const LQuaterniond & | other | ) | const [inline] |
Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type.
Definition at line 1321 of file lquaternion.h.
bool LQuaterniond::almost_equal | ( | const LQuaterniond & | other, |
double | threshold | ||
) | const [inline] |
Returns true if two quaternions are memberwise equal within a specified tolerance.
Definition at line 1332 of file lquaternion.h.
bool LQuaterniond::almost_same_direction | ( | const LQuaterniond & | other, |
double | threshold | ||
) | const [inline] |
Returns true if two quaternions represent the same rotation within a specified tolerance.
Definition at line 1359 of file lquaternion.h.
double LQuaterniond::angle_deg | ( | const LQuaterniond & | other | ) | const [inline] |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees.
Definition at line 1238 of file lquaternion.h.
double LQuaterniond::angle_rad | ( | const LQuaterniond & | other | ) | const [inline] |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians.
Definition at line 1226 of file lquaternion.h.
LQuaterniond LQuaterniond::conjugate | ( | ) | const [inline] |
Returns the complex conjugate of this quat.
Definition at line 1612 of file lquaternion.h.
bool LQuaterniond::conjugate_from | ( | const LQuaterniond & | other | ) | [inline] |
Computes the conjugate of the other quat, and stores the result in this quat.
This is a fully general operation and makes no assumptions about the type of transform represented by the quat.
The other quat must be a different object than this quat. However, if you need to get a conjugate of a quat in place, see conjugate_in_place.
The return value is true if the quat was successfully inverted, false if there was a singularity.
Definition at line 1633 of file lquaternion.h.
bool LQuaterniond::conjugate_in_place | ( | ) | [inline] |
Sets this to be the conjugate of the current quat.
Returns true if the successful, false if the quat was singular.
Definition at line 1646 of file lquaternion.h.
void LQuaterniond::extract_to_matrix | ( | LMatrix4d & | m | ) | const |
Based on the quat lib from VRPN.
Definition at line 496 of file lquaternion.cxx.
void LQuaterniond::extract_to_matrix | ( | LMatrix3d & | m | ) | const |
Based on the quat lib from VRPN.
Definition at line 475 of file lquaternion.cxx.
double LQuaterniond::get_angle | ( | ) | const [inline] |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
This returns the angle, in degrees counterclockwise about the axis.
It is necessary to ensure the quaternion has been normalized (for instance, with a call to normalize()) before calling this method.
Definition at line 1444 of file lquaternion.h.
Referenced by EggTransform::add_rotate3d().
double LQuaterniond::get_angle_rad | ( | ) | const [inline] |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
This returns the angle, in radians counterclockwise about the axis.
It is necessary to ensure the quaternion has been normalized (for instance, with a call to normalize()) before calling this method.
Definition at line 1427 of file lquaternion.h.
LVector3d LQuaterniond::get_axis | ( | ) | const [inline] |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
This returns the axis; it is not normalized.
Definition at line 1396 of file lquaternion.h.
Referenced by EggTransform::add_rotate3d().
LVector3d LQuaterniond::get_axis_normalized | ( | ) | const [inline] |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
This returns the normalized axis.
Definition at line 1408 of file lquaternion.h.
LVector3d LQuaterniond::get_forward | ( | CoordinateSystem | cs = CS_default | ) | const [inline] |
Returns the orientation represented by this quaternion, expressed as a forward vector.
Definition at line 1504 of file lquaternion.h.
LVecBase3d LQuaterniond::get_hpr | ( | CoordinateSystem | cs = CS_default | ) | const |
Extracts the equivalent Euler angles from the unit quaternion.
Definition at line 570 of file lquaternion.cxx.
LVector3d LQuaterniond::get_right | ( | CoordinateSystem | cs = CS_default | ) | const [inline] |
Returns the orientation represented by this quaternion, expressed as a right vector.
Definition at line 1493 of file lquaternion.h.
LVector3d LQuaterniond::get_up | ( | CoordinateSystem | cs = CS_default | ) | const [inline] |
Returns the orientation represented by this quaternion, expressed as an up vector.
Definition at line 1482 of file lquaternion.h.
const LQuaterniond & LQuaterniond::ident_quat | ( | ) | [inline, static] |
Returns an identity quaternion.
Definition at line 1718 of file lquaternion.h.
bool LQuaterniond::invert_from | ( | const LQuaterniond & | other | ) | [inline] |
Computes the inverse of the other quat, and stores the result in this quat.
This is a fully general operation and makes no assumptions about the type of transform represented by the quat.
The other quat must be a different object than this quat. However, if you need to invert a quat in place, see invert_in_place.
The return value is true if the quat was successfully inverted, false if there was a singularity.
Definition at line 1671 of file lquaternion.h.
bool LQuaterniond::invert_in_place | ( | ) | [inline] |
Inverts the current quat.
Returns true if the inverse is successful, false if the quat was singular.
Definition at line 1684 of file lquaternion.h.
bool LQuaterniond::is_almost_identity | ( | double | tolerance | ) | const [inline] |
Returns true if this quaternion represents the identity transformation within a given tolerance.
Definition at line 1707 of file lquaternion.h.
bool LQuaterniond::is_identity | ( | ) | const [inline] |
Returns true if this quaternion represents the identity transformation: no rotation.
Definition at line 1696 of file lquaternion.h.
bool LQuaterniond::is_same_direction | ( | const LQuaterniond & | other | ) | const [inline] |
Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.
Definition at line 1348 of file lquaternion.h.
LQuaterniond LQuaterniond::multiply | ( | const LQuaterniond & | rhs | ) | const [inline] |
actual multiply call (non virtual)
Definition at line 1179 of file lquaternion.h.
bool LQuaterniond::normalize | ( | ) | [inline] |
Normalizes the vector in place.
Returns true if the vector was normalized, false if it was a zero-length vector.
Reimplemented from LVecBase4d.
Definition at line 1595 of file lquaternion.h.
Quat * Matrix = matrix.
Definition at line 1301 of file lquaternion.h.
Quat * Matrix = matrix.
Definition at line 1289 of file lquaternion.h.
void LQuaterniond::set_from_axis_angle | ( | double | angle_deg, |
const LVector3d & | axis | ||
) | [inline] |
angle_deg is the angle about the axis in degrees.
axis must be normalized.
Definition at line 1471 of file lquaternion.h.
void LQuaterniond::set_from_axis_angle_rad | ( | double | angle_rad, |
const LVector3d & | axis | ||
) | [inline] |
angle_rad is the angle about the axis in radians.
axis must be normalized.
Definition at line 1455 of file lquaternion.h.
void LQuaterniond::set_from_matrix | ( | const LMatrix3d & | m | ) |
Sets the quaternion according to the rotation represented by the matrix.
Originally we tried an algorithm presented by Do-While Jones, but that turned out to be broken. This is based on the quat lib from UNC.
Definition at line 674 of file lquaternion.cxx.
void LQuaterniond::set_hpr | ( | const LVecBase3d & | hpr, |
CoordinateSystem | cs = CS_default |
||
) |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
(from Real-time Rendering, p.49)
Definition at line 520 of file lquaternion.cxx.
LVecBase3d LQuaterniond::xform | ( | const LVecBase3d & | v | ) | const [inline] |
Transforms a 3-d vector by the indicated rotation.
Definition at line 1147 of file lquaternion.h.
LVecBase4d LQuaterniond::xform | ( | const LVecBase4d & | v | ) | const [inline] |
Transforms a 4-d vector by the indicated rotation.
Definition at line 1163 of file lquaternion.h.