Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

LOrientationd Class Reference

This is a unit quaternion representing an orientation. More...

#include "lorientation.h"

Inheritance diagram for LOrientationd:
LQuaterniond LVecBase4d

List of all members.

Public Types

typedef const double * const_iterator
typedef const double * iterator

Public Member Functions

 LOrientationd (const LQuaterniond &)
 LOrientationd (const LVector3d &, float)
 vector + twist
 LOrientationd (const LMatrix3d &)
 matrix3
 LOrientationd (double, double, double, double)
 LOrientationd (const LMatrix4d &)
 matrix4
size_t add_hash (size_t hash) const
 Adds the vector into the running hash.
size_t add_hash (size_t hash, double threshold) const
 Adds the vector into the running hash.
void add_to_cell (int i, double value)
void add_w (double value)
void add_x (double value)
void add_y (double value)
void add_z (double value)
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_equal (const LVecBase4d &other, double threshold) const
 Returns true if two vectors are memberwise equal within a specified tolerance.
bool almost_equal (const LVecBase4d &other) const
 Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.
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.
iterator begin ()
 Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
const_iterator begin () const
 Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
int compare_to (const LVecBase4d &other, double threshold) const
 Sorts vectors lexicographically, componentwise.
int compare_to (const LVecBase4d &other) const
 This flavor of compare_to uses a default threshold value based on the numeric type.
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.
double dot (const LVecBase4d &other) const
iterator end ()
 Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
const_iterator end () const
 Returns an iterator that may be used to traverse the elements of the matrix, STL-style.
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.
void fill (double fill_value)
 Sets each element of the vector to the indicated fill_value.
LVecBase4d fmax (const LVecBase4d &other)
LVecBase4d fmin (const LVecBase4d &other)
void generate_hash (ChecksumHashGenerator &hashgen) const
 Adds the vector to the indicated hash generator.
void generate_hash (ChecksumHashGenerator &hashgen, double threshold) const
 Adds the vector to the indicated hash generator.
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.
double get_cell (int i) const
const double * get_data () const
 Returns the address of the first of the four data elements in the vector.
LVector3d get_forward (CoordinateSystem cs=CS_default) const
 Returns the orientation represented by this quaternion, expressed as a forward vector.
size_t get_hash () const
 Returns a suitable hash for phash_map.
size_t get_hash (double threshold) const
 Returns a suitable hash for phash_map.
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
int get_num_components () const
 Returns the number of elements in the vector, four.
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.
double get_w () const
double get_x () const
double get_y () const
double get_z () const
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_nan () const
 Returns true if any component of the vector is not-a-number, false otherwise.
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.
double length () const
 Returns the length of the vector, by the Pythagorean theorem.
double length_squared () const
 Returns the square of the vector's length, cheap and easy.
LQuaterniond multiply (const LQuaterniond &rhs) const
 actual multiply call (non virtual)
bool normalize ()
 Normalizes the vector in place.
bool operator!= (const LVecBase4d &other) const
LOrientationd operator* (const LQuaterniond &other) const
 Orientation * Orientation This is a meaningless operation, and will always simply return the rhs.
LOrientationd operator* (const LRotationd &other) const
 Orientation * rotation = Orientation Applies a rotation to an orientation.
LMatrix3d operator* (const LMatrix3d &)
 Quat * Matrix = matrix.
LMatrix4d operator* (const LMatrix4d &)
 Quat * Matrix = matrix.
LQuaterniond operator* (double scalar) const
void operator*= (double scalar)
LQuaterniondoperator*= (const LQuaterniond &)
LVecBase4d operator+ (const LVecBase4d &other) const
LQuaterniond operator+ (const LQuaterniond &other) const
void operator+= (const LVecBase4d &other)
LQuaterniond operator- (const LQuaterniond &other) const
LQuaterniond operator- () const
LVecBase4d operator- (const LVecBase4d &other) const
void operator-= (const LVecBase4d &other)
LQuaterniond operator/ (double scalar) const
void operator/= (double scalar)
bool operator< (const LVecBase4d &other) const
 This performs a lexicographical comparison.
bool operator== (const LVecBase4d &other) const
double & operator[] (int i)
double operator[] (int i) const
void output (ostream &) const
LVecBase4d project (const LVecBase4d &onto) const
 Returns a new vector representing the projection of this vector onto another one.
void read_datagram (DatagramIterator &source)
 Function to read itself from a datagramIterator.
void set (double x, double y, double z, double w)
void set_cell (int i, double value)
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 LMatrix4d &m)
void set_from_matrix (const LMatrix3d &m)
 Sets the quaternion according to the rotation represented by the matrix.
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)
void set_w (double value)
void set_x (double value)
void set_y (double value)
void set_z (double value)
void write_datagram (Datagram &destination) const
 Function to write itself into a datagram.
LVecBase3d xform (const LVecBase3d &v) const
 Transforms a 3-d vector by the indicated rotation.
LVecBase4d xform (const LVecBase4d &v) const
 Transforms a 4-d vector by the indicated rotation.

Static Public Member Functions

static TypeHandle get_class_type ()
static const LQuaterniondident_quat ()
 Returns an identity quaternion.
static void init_type ()
static LQuaterniond pure_imaginary (const LVector3d &)
static int size ()
 Returns 4: the number of components of a LVecBase4.
static const LVecBase4dunit_w ()
 Returns a unit W vector.
static const LVecBase4dunit_x ()
 Returns a unit X vector.
static const LVecBase4dunit_y ()
 Returns a unit Y vector.
static const LVecBase4dunit_z ()
 Returns a unit Z vector.
static const LVecBase4dzero ()
 Returns a zero-length vector.

Public Attributes

union {
   double   data [4]
   struct {
      double   _0
      double   _1
      double   _2
      double   _3
   }   v
_v

Detailed Description

This is a unit quaternion representing an orientation.

Definition at line 279 of file lorientation.h.


Constructor & Destructor Documentation

LOrientationd::LOrientationd ( const LVector3d point_at,
float  twist 
) [inline]

vector + twist

Definition at line 352 of file lorientation.h.

LOrientationd::LOrientationd ( const LMatrix3d m) [inline]

matrix3

Definition at line 369 of file lorientation.h.

LOrientationd::LOrientationd ( const LMatrix4d m) [inline]

matrix4

Definition at line 379 of file lorientation.h.


Member Function Documentation

size_t LVecBase4d::add_hash ( size_t  hash) const [inline, inherited]

Adds the vector into the running hash.

Definition at line 2022 of file lvecBase4.h.

size_t LVecBase4d::add_hash ( size_t  hash,
double  threshold 
) const [inline, inherited]

Adds the vector into the running hash.

Definition at line 2033 of file lvecBase4.h.

bool LQuaterniond::almost_equal ( const LQuaterniond other) const [inline, inherited]

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, inherited]

Returns true if two quaternions are memberwise equal within a specified tolerance.

Definition at line 1332 of file lquaternion.h.

bool LVecBase4d::almost_equal ( const LVecBase4d other,
double  threshold 
) const [inline, inherited]

Returns true if two vectors are memberwise equal within a specified tolerance.

Definition at line 2194 of file lvecBase4.h.

bool LVecBase4d::almost_equal ( const LVecBase4d other) const [inline, inherited]

Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.

Definition at line 2209 of file lvecBase4.h.

bool LQuaterniond::almost_same_direction ( const LQuaterniond other,
double  threshold 
) const [inline, inherited]

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, inherited]

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, inherited]

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.

LVecBase4d::iterator LVecBase4d::begin ( ) [inline, inherited]

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

Definition at line 1781 of file lvecBase4.h.

LVecBase4d::const_iterator LVecBase4d::begin ( ) const [inline, inherited]

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

Definition at line 1803 of file lvecBase4.h.

int LVecBase4d::compare_to ( const LVecBase4d other) const [inline, inherited]

This flavor of compare_to uses a default threshold value based on the numeric type.

Definition at line 1962 of file lvecBase4.h.

Referenced by EggVertex::compare_to().

int LVecBase4d::compare_to ( const LVecBase4d other,
double  threshold 
) const [inline, inherited]

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).

Definition at line 1977 of file lvecBase4.h.

LQuaterniond LQuaterniond::conjugate ( ) const [inline, inherited]

Returns the complex conjugate of this quat.

Definition at line 1612 of file lquaternion.h.

bool LQuaterniond::conjugate_from ( const LQuaterniond other) [inline, inherited]

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, inherited]

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.

LVecBase4d::iterator LVecBase4d::end ( ) [inline, inherited]

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

Definition at line 1792 of file lvecBase4.h.

LVecBase4d::const_iterator LVecBase4d::end ( ) const [inline, inherited]

Returns an iterator that may be used to traverse the elements of the matrix, STL-style.

Definition at line 1814 of file lvecBase4.h.

void LQuaterniond::extract_to_matrix ( LMatrix3d m) const [inherited]

Based on the quat lib from VRPN.

Definition at line 475 of file lquaternion.cxx.

void LQuaterniond::extract_to_matrix ( LMatrix4d m) const [inherited]

Based on the quat lib from VRPN.

Definition at line 496 of file lquaternion.cxx.

void LVecBase4d::fill ( double  fill_value) [inline, inherited]

Sets each element of the vector to the indicated fill_value.

This is particularly useful for initializing to zero.

Definition at line 1826 of file lvecBase4.h.

void LVecBase4d::generate_hash ( ChecksumHashGenerator hashgen) const [inline, inherited]

Adds the vector to the indicated hash generator.

Definition at line 2249 of file lvecBase4.h.

void LVecBase4d::generate_hash ( ChecksumHashGenerator hashgen,
double  threshold 
) const [inline, inherited]

Adds the vector to the indicated hash generator.

Definition at line 2260 of file lvecBase4.h.

double LQuaterniond::get_angle ( ) const [inline, inherited]

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, inherited]

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, inherited]

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, inherited]

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.

const double * LVecBase4d::get_data ( ) const [inline, 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.

Definition at line 1760 of file lvecBase4.h.

Referenced by XFileDataObject::set().

LVector3d LQuaterniond::get_forward ( CoordinateSystem  cs = CS_default) const [inline, inherited]

Returns the orientation represented by this quaternion, expressed as a forward vector.

Definition at line 1504 of file lquaternion.h.

size_t LVecBase4d::get_hash ( ) const [inline, inherited]

Returns a suitable hash for phash_map.

Definition at line 2000 of file lvecBase4.h.

size_t LVecBase4d::get_hash ( double  threshold) const [inline, inherited]

Returns a suitable hash for phash_map.

Definition at line 2011 of file lvecBase4.h.

LVecBase3d LQuaterniond::get_hpr ( CoordinateSystem  cs = CS_default) const [inherited]

Extracts the equivalent Euler angles from the unit quaternion.

Definition at line 570 of file lquaternion.cxx.

int LVecBase4d::get_num_components ( ) const [inline, inherited]

Returns the number of elements in the vector, four.

Definition at line 1770 of file lvecBase4.h.

LVector3d LQuaterniond::get_right ( CoordinateSystem  cs = CS_default) const [inline, inherited]

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, inherited]

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, inherited]

Returns an identity quaternion.

Definition at line 1718 of file lquaternion.h.

bool LQuaterniond::invert_from ( const LQuaterniond other) [inline, inherited]

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, inherited]

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, inherited]

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, inherited]

Returns true if this quaternion represents the identity transformation: no rotation.

Definition at line 1696 of file lquaternion.h.

bool LVecBase4d::is_nan ( ) const [inline, inherited]

Returns true if any component of the vector is not-a-number, false otherwise.

Definition at line 1594 of file lvecBase4.h.

bool LQuaterniond::is_same_direction ( const LQuaterniond other) const [inline, inherited]

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.

double LVecBase4d::length ( ) const [inline, inherited]

Returns the length of the vector, by the Pythagorean theorem.

Definition at line 1855 of file lvecBase4.h.

double LVecBase4d::length_squared ( ) const [inline, inherited]

Returns the square of the vector's length, cheap and easy.

Definition at line 1866 of file lvecBase4.h.

LQuaterniond LQuaterniond::multiply ( const LQuaterniond rhs) const [inline, inherited]

actual multiply call (non virtual)

Definition at line 1179 of file lquaternion.h.

bool LQuaterniond::normalize ( ) [inline, inherited]

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.

LMatrix3d LQuaterniond::operator* ( const LMatrix3d m) [inline, inherited]

Quat * Matrix = matrix.

Definition at line 1289 of file lquaternion.h.

LOrientationd LOrientationd::operator* ( const LQuaterniond other) const [inline]

Orientation * Orientation This is a meaningless operation, and will always simply return the rhs.

Reimplemented from LQuaterniond.

Definition at line 402 of file lorientation.h.

LMatrix4d LQuaterniond::operator* ( const LMatrix4d m) [inline, inherited]

Quat * Matrix = matrix.

Definition at line 1301 of file lquaternion.h.

LOrientationd LOrientationd::operator* ( const LRotationd other) const [inline]

Orientation * rotation = Orientation Applies a rotation to an orientation.

Definition at line 390 of file lorientation.h.

bool LVecBase4d::operator< ( const LVecBase4d other) const [inline, 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().

Definition at line 1926 of file lvecBase4.h.

LVecBase4d LVecBase4d::project ( const LVecBase4d onto) const [inline, inherited]

Returns a new vector representing the projection of this vector onto another one.

The resulting vector will be a scalar multiple of onto.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1912 of file lvecBase4.h.

void LVecBase4d::read_datagram ( DatagramIterator source) [inline, inherited]

Function to read itself from a datagramIterator.

Definition at line 2294 of file lvecBase4.h.

void LQuaterniond::set_from_axis_angle ( double  angle_deg,
const LVector3d axis 
) [inline, inherited]

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, inherited]

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) [inherited]

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 
) [inherited]

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.

int LVecBase4d::size ( ) [inline, static, inherited]

Returns 4: the number of components of a LVecBase4.

Definition at line 1583 of file lvecBase4.h.

const LVecBase4d & LVecBase4d::unit_w ( ) [inline, static, inherited]

Returns a unit W vector.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1538 of file lvecBase4.h.

const LVecBase4d & LVecBase4d::unit_x ( ) [inline, static, inherited]

Returns a unit X vector.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1508 of file lvecBase4.h.

const LVecBase4d & LVecBase4d::unit_y ( ) [inline, static, inherited]

Returns a unit Y vector.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1518 of file lvecBase4.h.

const LVecBase4d & LVecBase4d::unit_z ( ) [inline, static, inherited]

Returns a unit Z vector.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1528 of file lvecBase4.h.

void LVecBase4d::write_datagram ( Datagram destination) const [inline, inherited]

Function to write itself into a datagram.

Definition at line 2274 of file lvecBase4.h.

LVecBase3d LQuaterniond::xform ( const LVecBase3d v) const [inline, inherited]

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, inherited]

Transforms a 4-d vector by the indicated rotation.

Definition at line 1163 of file lquaternion.h.

const LVecBase4d & LVecBase4d::zero ( ) [inline, static, inherited]

Returns a zero-length vector.

Reimplemented in LPoint4d, and LVector4d.

Definition at line 1498 of file lvecBase4.h.

Referenced by PNMImage::get_average_xel_a().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations