Panda3D
|
This is the base quaternion class. More...
Public Member Functions | |
QuatD () | |
QuatD (VBase4D const copy) | |
QuatD (double, double, double, double) | |
QuatD (double, VBase3D const copy) | |
unsigned int | addHash (unsigned int hash) |
Adds the vector into the running hash. | |
unsigned int | addHash (unsigned int hash, double threshold) |
Adds the vector into the running hash. | |
addToCell (int i, double value) | |
addW (double value) | |
addX (double value) | |
addY (double value) | |
addZ (double value) | |
bool | almostEqual (QuatD const other, double threshold) |
Returns true if two quaternions are memberwise equal within a specified tolerance. | |
bool | almostEqual (QuatD const other) |
Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type. | |
bool | almostEqual (VBase4D const other) |
Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type. | |
bool | almostEqual (VBase4D const other, double threshold) |
Returns true if two vectors are memberwise equal within a specified tolerance. | |
bool | almostSameDirection (QuatD const other, double threshold) |
Returns true if two quaternions represent the same rotation within a specified tolerance. | |
double | angleDeg (QuatD const other) |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees. | |
double | angleRad (QuatD const other) |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians. | |
int | compareTo (VBase4D const other) |
This flavor of compare_to uses a default threshold value based on the numeric type. | |
int | compareTo (VBase4D const other, double threshold) |
Sorts vectors lexicographically, componentwise. | |
QuatD | conjugate () |
Returns the complex conjugate of this quat. | |
bool | conjugateFrom (QuatD const other) |
Computes the conjugate of the other quat, and stores the result in this quat. | |
bool | conjugateInPlace () |
Sets this to be the conjugate of the current quat. | |
double | dot (VBase4D const other) |
extractToMatrix (Mat3D m) | |
Based on the quat lib from VRPN. | |
extractToMatrix (Mat4D m) | |
Based on the quat lib from VRPN. | |
fill (double fill_value) | |
Sets each element of the vector to the indicated fill_value. | |
VBase4D | fmax (VBase4D const other) |
VBase4D | fmin (VBase4D const other) |
double | getAngle () |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
double | getAngleRad () |
This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
PyObject | getattr (string attr_name) |
This is used to implement swizzle masks. | |
Vec3D | getAxis () |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
Vec3D | getAxisNormalized () |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis. | |
double | getCell (int i) |
getData () | |
Returns the address of the first of the four data elements in the vector. | |
Vec3D | getForward (CoordinateSystem cs) |
Returns the orientation represented by this quaternion, expressed as a forward vector. | |
Vec3D | getForward () |
Returns the orientation represented by this quaternion, expressed as a forward vector. | |
unsigned int | getHash (double threshold) |
Returns a suitable hash for phash_map. | |
unsigned int | getHash () |
Returns a suitable hash for phash_map. | |
VBase3D | getHpr () |
Extracts the equivalent Euler angles from the unit quaternion. | |
VBase3D | getHpr (CoordinateSystem cs) |
Extracts the equivalent Euler angles from the unit quaternion. | |
double | getI () |
double | getJ () |
double | getK () |
int | getNumComponents () |
Returns the number of elements in the vector, four. | |
double | getR () |
Vec3D | getRight (CoordinateSystem cs) |
Returns the orientation represented by this quaternion, expressed as a right vector. | |
Vec3D | getRight () |
Returns the orientation represented by this quaternion, expressed as a right vector. | |
Vec3D | getUp (CoordinateSystem cs) |
Returns the orientation represented by this quaternion, expressed as an up vector. | |
Vec3D | getUp () |
Returns the orientation represented by this quaternion, expressed as an up vector. | |
double | getW () |
double | getX () |
double | getY () |
double | getZ () |
bool | invertFrom (QuatD const other) |
Computes the inverse of the other quat, and stores the result in this quat. | |
bool | invertInPlace () |
Inverts the current quat. | |
bool | isAlmostIdentity (double tolerance) |
Returns true if this quaternion represents the identity transformation within a given tolerance. | |
bool | isIdentity () |
Returns true if this quaternion represents the identity transformation: no rotation. | |
bool | isNan () |
Returns true if any component of the vector is not-a-number, false otherwise. | |
bool | isSameDirection (QuatD const other) |
Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type. | |
double | length () |
Returns the length of the vector, by the Pythagorean theorem. | |
double | lengthSquared () |
Returns the square of the vector's length, cheap and easy. | |
QuatD | multiply (QuatD const rhs) |
actual multiply call (non virtual) | |
bool | normalize () |
Normalizes the vector in place. | |
operator new (unsigned int size) | |
bool | operator!= (VBase4D const other) |
QuatD | operator* (QuatD const ) |
QuatD | operator* (double scalar) |
Mat3D | operator* (Mat3D const ) |
Quat * Matrix = matrix. | |
Mat4D | operator* (Mat4D const ) |
Quat * Matrix = matrix. | |
QuatD | operator*= (QuatD const ) |
VBase4D | operator*= (double scalar) |
QuatD | operator+ (QuatD const other) |
VBase4D | operator+ (VBase4D const other) |
VBase4D | operator+= (VBase4D const other) |
QuatD | operator- () |
VBase4D | operator- (VBase4D const other) |
QuatD | operator- (QuatD const other) |
VBase4D | operator-= (VBase4D const other) |
QuatD | operator/ (double scalar) |
VBase4D | operator/= (double scalar) |
bool | operator< (VBase4D const other) |
This performs a lexicographical comparison. | |
bool | operator== (VBase4D const other) |
double | operator[] (int i) |
operator[] (int i) | |
output (ostream) | |
VBase4D | project (VBase4D const onto) |
Returns a new vector representing the projection of this vector onto another one. | |
pythonRepr (ostream out, string class_name) | |
PyObject | reduce (PyObject self) |
This special Python method is implement to provide support for the pickle module. | |
set (double x, double y, double z, double w) | |
int | setattr (PyObject self, string attr_name, PyObject assign) |
This is used to implement write masks. | |
setCell (int i, double value) | |
setFromAxisAngle (double angle_deg, Vec3D const axis) | |
angle_deg is the angle about the axis in degrees. | |
setFromAxisAngleRad (double angle_rad, Vec3D const axis) | |
angle_rad is the angle about the axis in radians. | |
setFromMatrix (Mat3D const m) | |
Sets the quaternion according to the rotation represented by the matrix. | |
setFromMatrix (Mat4D const m) | |
setHpr (VBase3D const hpr, CoordinateSystem cs) | |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles. | |
setHpr (VBase3D const hpr) | |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles. | |
setI (double i) | |
setitem (int i, double v) | |
setJ (double j) | |
setK (double k) | |
setR (double r) | |
setW (double value) | |
setX (double value) | |
setY (double value) | |
setZ (double value) | |
VBase3D | xform (VBase3D const v) |
Transforms a 3-d vector by the indicated rotation. | |
VBase4D | xform (VBase4D const v) |
Transforms a 4-d vector by the indicated rotation. | |
Static Public Member Functions | |
static TypeHandle | getClassType () |
static QuatD const | identQuat () |
Returns an identity quaternion. | |
static QuatD | pureImaginary (Vec3D const ) |
static int | size () |
Returns 4: the number of components of a LVecBase4. | |
static VBase4D const | unitW () |
Returns a unit W vector. | |
static VBase4D const | unitX () |
Returns a unit X vector. | |
static VBase4D const | unitY () |
Returns a unit Y vector. | |
static VBase4D const | unitZ () |
Returns a unit Z vector. | |
static VBase4D const | zero () |
Returns a zero-length vector. |
This is the base quaternion class.
QuatD | ( | ) |
QuatD | ( | double | , |
double | , | ||
double | , | ||
double | |||
) |
Adds the vector into the running hash.
addToCell | ( | int | i, |
double | value | ||
) | [inherited] |
addW | ( | double | value | ) | [inherited] |
addX | ( | double | value | ) | [inherited] |
addY | ( | double | value | ) | [inherited] |
addZ | ( | double | value | ) | [inherited] |
bool almostEqual | ( | QuatD const | other | ) |
Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type.
bool almostEqual | ( | QuatD const | other, |
double | threshold | ||
) |
Returns true if two quaternions are memberwise equal within a specified tolerance.
bool almostEqual | ( | VBase4D const | other | ) | [inherited] |
Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.
bool almostEqual | ( | VBase4D const | other, |
double | threshold | ||
) | [inherited] |
Returns true if two vectors are memberwise equal within a specified tolerance.
bool almostSameDirection | ( | QuatD const | other, |
double | threshold | ||
) |
Returns true if two quaternions represent the same rotation within a specified tolerance.
double angleDeg | ( | QuatD const | other | ) |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees.
double angleRad | ( | QuatD const | other | ) |
Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians.
Sorts vectors lexicographically, componentwise.
Returns a number less than 0 if this vector sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent (within the indicated tolerance).
This flavor of compare_to uses a default threshold value based on the numeric type.
QuatD conjugate | ( | ) |
Returns the complex conjugate of this quat.
bool conjugateFrom | ( | QuatD const | other | ) |
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.
bool conjugateInPlace | ( | ) |
Sets this to be the conjugate of the current quat.
Returns true if the successful, false if the quat was singular.
double dot | ( | VBase4D const | other | ) | [inherited] |
extractToMatrix | ( | Mat3D | m | ) |
Based on the quat lib from VRPN.
extractToMatrix | ( | Mat4D | m | ) |
Based on the quat lib from VRPN.
fill | ( | double | fill_value | ) | [inherited] |
Sets each element of the vector to the indicated fill_value.
This is particularly useful for initializing to zero.
double getAngle | ( | ) |
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.
double getAngleRad | ( | ) |
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.
PyObject getattr | ( | string | attr_name | ) | [inherited] |
Vec3D getAxis | ( | ) |
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.
Vec3D getAxisNormalized | ( | ) |
This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
This returns the normalized axis.
double getCell | ( | int | i | ) | [inherited] |
static TypeHandle getClassType | ( | ) | [static] |
Reimplemented from VBase4D.
Reimplemented in LRotationd, and LOrientationd.
getData | ( | ) | [inherited] |
Returns the address of the first of the four data elements in the vector.
The remaining elements occupy the next positions consecutively in memory.
Vec3D getForward | ( | CoordinateSystem | cs | ) |
Returns the orientation represented by this quaternion, expressed as a forward vector.
Vec3D getForward | ( | ) |
Returns the orientation represented by this quaternion, expressed as a forward vector.
unsigned int getHash | ( | ) | [inherited] |
Returns a suitable hash for phash_map.
unsigned int getHash | ( | double | threshold | ) | [inherited] |
Returns a suitable hash for phash_map.
VBase3D getHpr | ( | CoordinateSystem | cs | ) |
Extracts the equivalent Euler angles from the unit quaternion.
VBase3D getHpr | ( | ) |
Extracts the equivalent Euler angles from the unit quaternion.
double getI | ( | ) |
double getJ | ( | ) |
double getK | ( | ) |
int getNumComponents | ( | ) | [inherited] |
Returns the number of elements in the vector, four.
double getR | ( | ) |
Vec3D getRight | ( | CoordinateSystem | cs | ) |
Returns the orientation represented by this quaternion, expressed as a right vector.
Vec3D getRight | ( | ) |
Returns the orientation represented by this quaternion, expressed as a right vector.
Vec3D getUp | ( | CoordinateSystem | cs | ) |
Returns the orientation represented by this quaternion, expressed as an up vector.
Vec3D getUp | ( | ) |
Returns the orientation represented by this quaternion, expressed as an up vector.
double getW | ( | ) | [inherited] |
double getX | ( | ) | [inherited] |
double getY | ( | ) | [inherited] |
double getZ | ( | ) | [inherited] |
static QuatD const identQuat | ( | ) | [static] |
Returns an identity quaternion.
bool invertFrom | ( | QuatD const | other | ) |
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.
bool invertInPlace | ( | ) |
Inverts the current quat.
Returns true if the inverse is successful, false if the quat was singular.
bool isAlmostIdentity | ( | double | tolerance | ) |
Returns true if this quaternion represents the identity transformation within a given tolerance.
bool isIdentity | ( | ) |
Returns true if this quaternion represents the identity transformation: no rotation.
bool isNan | ( | ) | [inherited] |
Returns true if any component of the vector is not-a-number, false otherwise.
bool isSameDirection | ( | QuatD const | other | ) |
Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.
double length | ( | ) | [inherited] |
Returns the length of the vector, by the Pythagorean theorem.
double lengthSquared | ( | ) | [inherited] |
Returns the square of the vector's length, cheap and easy.
bool normalize | ( | ) |
Normalizes the vector in place.
Returns true if the vector was normalized, false if it was a zero-length vector.
Reimplemented from VBase4D.
operator new | ( | unsigned int | size | ) | [inherited] |
bool operator!= | ( | VBase4D const | other | ) | [inherited] |
Reimplemented in LRotationd, and LOrientationd.
QuatD operator* | ( | double | scalar | ) |
Reimplemented from VBase4D.
Reimplemented in LRotationd.
VBase4D operator*= | ( | double | scalar | ) | [inherited] |
QuatD operator/ | ( | double | scalar | ) |
Reimplemented from VBase4D.
Reimplemented in LRotationd.
VBase4D operator/= | ( | double | scalar | ) | [inherited] |
bool operator< | ( | VBase4D const | other | ) | [inherited] |
This performs a lexicographical comparison.
It's of questionable mathematical meaning, but sometimes has a practical purpose for sorting unique vectors, especially in an STL container. Also see compare_to().
bool operator== | ( | VBase4D const | other | ) | [inherited] |
operator[] | ( | int | i | ) | [inherited] |
double operator[] | ( | int | i | ) | [inherited] |
PyObject reduce | ( | PyObject | self | ) | [inherited] |
This special Python method is implement to provide support for the pickle module.
set | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) | [inherited] |
int setattr | ( | PyObject | self, |
string | attr_name, | ||
PyObject | assign | ||
) | [inherited] |
setCell | ( | int | i, |
double | value | ||
) | [inherited] |
setFromAxisAngle | ( | double | angle_deg, |
Vec3D const | axis | ||
) |
angle_deg is the angle about the axis in degrees.
axis must be normalized.
setFromAxisAngleRad | ( | double | angle_rad, |
Vec3D const | axis | ||
) |
angle_rad is the angle about the axis in radians.
axis must be normalized.
setFromMatrix | ( | Mat4D const | m | ) |
setFromMatrix | ( | Mat3D const | 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.
setHpr | ( | VBase3D const | hpr, |
CoordinateSystem | cs | ||
) |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
(from Real-time Rendering, p.49)
setHpr | ( | VBase3D const | hpr | ) |
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
(from Real-time Rendering, p.49)
setI | ( | double | i | ) |
setitem | ( | int | i, |
double | v | ||
) | [inherited] |
setJ | ( | double | j | ) |
setK | ( | double | k | ) |
setR | ( | double | r | ) |
setW | ( | double | value | ) | [inherited] |
setX | ( | double | value | ) | [inherited] |
setY | ( | double | value | ) | [inherited] |
setZ | ( | double | value | ) | [inherited] |
static int size | ( | ) | [static, inherited] |
Returns 4: the number of components of a LVecBase4.
static VBase4D const unitW | ( | ) | [static, inherited] |
static VBase4D const unitX | ( | ) | [static, inherited] |
static VBase4D const unitY | ( | ) | [static, inherited] |
static VBase4D const unitZ | ( | ) | [static, inherited] |