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

LOrientationf Class Reference

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

#include "lorientation.h"

Inheritance diagram for LOrientationf:
LQuaternionf LVecBase4f

List of all members.

Public Types

typedef const float * const_iterator
typedef const float * iterator

Public Member Functions

 LOrientationf (const LQuaternionf &)
 LOrientationf (const LVector3f &, float)
 vector + twist
 LOrientationf (const LMatrix3f &)
 matrix3
 LOrientationf (float, float, float, float)
 LOrientationf (const LMatrix4f &)
 matrix4
size_t add_hash (size_t hash) const
 Adds the vector into the running hash.
size_t add_hash (size_t hash, float threshold) const
 Adds the vector into the running hash.
void add_to_cell (int i, float value)
void add_w (float value)
void add_x (float value)
void add_y (float value)
void add_z (float value)
bool almost_equal (const LQuaternionf &other) const
 Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type.
bool almost_equal (const LQuaternionf &other, float threshold) const
 Returns true if two quaternions are memberwise equal within a specified tolerance.
bool almost_equal (const LVecBase4f &other, float threshold) const
 Returns true if two vectors are memberwise equal within a specified tolerance.
bool almost_equal (const LVecBase4f &other) const
 Returns true if two vectors are memberwise equal within a default tolerance based on the numeric type.
bool almost_same_direction (const LQuaternionf &other, float threshold) const
 Returns true if two quaternions represent the same rotation within a specified tolerance.
float angle_deg (const LQuaternionf &other) const
 Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees.
float angle_rad (const LQuaternionf &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 LVecBase4f &other, float threshold) const
 Sorts vectors lexicographically, componentwise.
int compare_to (const LVecBase4f &other) const
 This flavor of compare_to uses a default threshold value based on the numeric type.
LQuaternionf conjugate () const
 Returns the complex conjugate of this quat.
bool conjugate_from (const LQuaternionf &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.
float dot (const LVecBase4f &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 (LMatrix3f &m) const
 Based on the quat lib from VRPN.
void extract_to_matrix (LMatrix4f &m) const
 Based on the quat lib from VRPN.
void fill (float fill_value)
 Sets each element of the vector to the indicated fill_value.
LVecBase4f fmax (const LVecBase4f &other)
LVecBase4f fmin (const LVecBase4f &other)
void generate_hash (ChecksumHashGenerator &hashgen) const
 Adds the vector to the indicated hash generator.
void generate_hash (ChecksumHashGenerator &hashgen, float threshold) const
 Adds the vector to the indicated hash generator.
float get_angle () const
 This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
float get_angle_rad () const
 This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
LVector3f get_axis () const
 This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
LVector3f get_axis_normalized () const
 This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
float get_cell (int i) const
const float * get_data () const
 Returns the address of the first of the four data elements in the vector.
LVector3f 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 (float threshold) const
 Returns a suitable hash for phash_map.
LVecBase3f get_hpr (CoordinateSystem cs=CS_default) const
 Extracts the equivalent Euler angles from the unit quaternion.
float get_i () const
float get_j () const
float get_k () const
int get_num_components () const
 Returns the number of elements in the vector, four.
float get_r () const
LVector3f get_right (CoordinateSystem cs=CS_default) const
 Returns the orientation represented by this quaternion, expressed as a right vector.
LVector3f get_up (CoordinateSystem cs=CS_default) const
 Returns the orientation represented by this quaternion, expressed as an up vector.
float get_w () const
float get_x () const
float get_y () const
float get_z () const
bool invert_from (const LQuaternionf &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 (float 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 LQuaternionf &other) const
 Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.
float length () const
 Returns the length of the vector, by the Pythagorean theorem.
float length_squared () const
 Returns the square of the vector's length, cheap and easy.
LQuaternionf multiply (const LQuaternionf &rhs) const
 actual multiply call (non virtual)
bool normalize ()
 Normalizes the vector in place.
bool operator!= (const LVecBase4f &other) const
LOrientationf operator* (const LQuaternionf &other) const
 Orientation * Orientation This is a meaningless operation, and will always simply return the rhs.
LOrientationf operator* (const LRotationf &other) const
 Orientation * rotation = Orientation Applies a rotation to an orientation.
LMatrix3f operator* (const LMatrix3f &)
 Quat * Matrix = matrix.
LMatrix4f operator* (const LMatrix4f &)
 Quat * Matrix = matrix.
LQuaternionf operator* (float scalar) const
void operator*= (float scalar)
LQuaternionfoperator*= (const LQuaternionf &)
LVecBase4f operator+ (const LVecBase4f &other) const
LQuaternionf operator+ (const LQuaternionf &other) const
void operator+= (const LVecBase4f &other)
LQuaternionf operator- (const LQuaternionf &other) const
LQuaternionf operator- () const
LVecBase4f operator- (const LVecBase4f &other) const
void operator-= (const LVecBase4f &other)
LQuaternionf operator/ (float scalar) const
void operator/= (float scalar)
bool operator< (const LVecBase4f &other) const
 This performs a lexicographical comparison.
bool operator== (const LVecBase4f &other) const
float & operator[] (int i)
float operator[] (int i) const
void output (ostream &) const
LVecBase4f project (const LVecBase4f &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 (float x, float y, float z, float w)
void set_cell (int i, float value)
void set_from_axis_angle (float angle_deg, const LVector3f &axis)
 angle_deg is the angle about the axis in degrees.
void set_from_axis_angle_rad (float angle_rad, const LVector3f &axis)
 angle_rad is the angle about the axis in radians.
void set_from_matrix (const LMatrix4f &m)
void set_from_matrix (const LMatrix3f &m)
 Sets the quaternion according to the rotation represented by the matrix.
void set_hpr (const LVecBase3f &hpr, CoordinateSystem cs=CS_default)
 Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
void set_i (float i)
void set_j (float j)
void set_k (float k)
void set_r (float r)
void set_w (float value)
void set_x (float value)
void set_y (float value)
void set_z (float value)
void write_datagram (Datagram &destination) const
 Function to write itself into a datagram.
LVecBase3f xform (const LVecBase3f &v) const
 Transforms a 3-d vector by the indicated rotation.
LVecBase4f xform (const LVecBase4f &v) const
 Transforms a 4-d vector by the indicated rotation.

Static Public Member Functions

static TypeHandle get_class_type ()
static const LQuaternionfident_quat ()
 Returns an identity quaternion.
static void init_type ()
static LQuaternionf pure_imaginary (const LVector3f &)
static int size ()
 Returns 4: the number of components of a LVecBase4.
static const LVecBase4funit_w ()
 Returns a unit W vector.
static const LVecBase4funit_x ()
 Returns a unit X vector.
static const LVecBase4funit_y ()
 Returns a unit Y vector.
static const LVecBase4funit_z ()
 Returns a unit Z vector.
static const LVecBase4fzero ()
 Returns a zero-length vector.

Public Attributes

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

Detailed Description

This is a unit quaternion representing an orientation.

Definition at line 86 of file lorientation.h.


Constructor & Destructor Documentation

LOrientationf::LOrientationf ( const LVector3f point_at,
float  twist 
) [inline]

vector + twist

Definition at line 159 of file lorientation.h.

LOrientationf::LOrientationf ( const LMatrix3f m) [inline]

matrix3

Definition at line 176 of file lorientation.h.

LOrientationf::LOrientationf ( const LMatrix4f m) [inline]

matrix4

Definition at line 186 of file lorientation.h.


Member Function Documentation

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

Adds the vector into the running hash.

Definition at line 883 of file lvecBase4.h.

size_t LVecBase4f::add_hash ( size_t  hash,
float  threshold 
) const [inline, inherited]

Adds the vector into the running hash.

Definition at line 894 of file lvecBase4.h.

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

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

Definition at line 448 of file lquaternion.h.

bool LQuaternionf::almost_equal ( const LQuaternionf other,
float  threshold 
) const [inline, inherited]

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

Definition at line 459 of file lquaternion.h.

bool LVecBase4f::almost_equal ( const LVecBase4f other,
float  threshold 
) const [inline, inherited]

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

Definition at line 1055 of file lvecBase4.h.

Referenced by EggVertexPool::check_overall_color(), ColorScaleAttrib::fillin(), and EggLoader::make_polyset().

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

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

Definition at line 1070 of file lvecBase4.h.

bool LQuaternionf::almost_same_direction ( const LQuaternionf other,
float  threshold 
) const [inline, inherited]

Returns true if two quaternions represent the same rotation within a specified tolerance.

Definition at line 486 of file lquaternion.h.

float LQuaternionf::angle_deg ( const LQuaternionf other) const [inline, inherited]

Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees.

Definition at line 365 of file lquaternion.h.

float LQuaternionf::angle_rad ( const LQuaternionf other) const [inline, inherited]

Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians.

Definition at line 353 of file lquaternion.h.

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

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

Definition at line 642 of file lvecBase4.h.

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

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

Definition at line 664 of file lvecBase4.h.

int LVecBase4f::compare_to ( const LVecBase4f other) const [inline, inherited]
int LVecBase4f::compare_to ( const LVecBase4f other,
float  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 838 of file lvecBase4.h.

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

Returns the complex conjugate of this quat.

Definition at line 739 of file lquaternion.h.

bool LQuaternionf::conjugate_from ( const LQuaternionf 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 760 of file lquaternion.h.

bool LQuaternionf::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 773 of file lquaternion.h.

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

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

Definition at line 653 of file lvecBase4.h.

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

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

Definition at line 675 of file lvecBase4.h.

void LQuaternionf::extract_to_matrix ( LMatrix3f m) const [inherited]

Based on the quat lib from VRPN.

Definition at line 102 of file lquaternion.cxx.

Referenced by TrackerNode::do_transmit_data(), FFTCompressor::read_hprs(), PhysxActorDesc::set_global_hpr(), and FFTCompressor::write_hprs().

void LQuaternionf::extract_to_matrix ( LMatrix4f m) const [inherited]

Based on the quat lib from VRPN.

Definition at line 123 of file lquaternion.cxx.

void LVecBase4f::fill ( float  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 687 of file lvecBase4.h.

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

Adds the vector to the indicated hash generator.

Definition at line 1110 of file lvecBase4.h.

void LVecBase4f::generate_hash ( ChecksumHashGenerator hashgen,
float  threshold 
) const [inline, inherited]

Adds the vector to the indicated hash generator.

Definition at line 1121 of file lvecBase4.h.

float LQuaternionf::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 571 of file lquaternion.h.

float LQuaternionf::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 554 of file lquaternion.h.

LVector3f LQuaternionf::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 523 of file lquaternion.h.

LVector3f LQuaternionf::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 535 of file lquaternion.h.

const float * LVecBase4f::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 621 of file lvecBase4.h.

Referenced by DXGraphicsStateGuardian9::bind_light(), DXGraphicsStateGuardian8::bind_light(), GraphicsStateGuardian::fetch_specified_part(), DXGraphicsStateGuardian9::get_light_color(), and DXGraphicsStateGuardian8::get_light_color().

LVector3f LQuaternionf::get_forward ( CoordinateSystem  cs = CS_default) const [inline, inherited]

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

Definition at line 631 of file lquaternion.h.

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

Returns a suitable hash for phash_map.

Definition at line 861 of file lvecBase4.h.

size_t LVecBase4f::get_hash ( float  threshold) const [inline, inherited]

Returns a suitable hash for phash_map.

Definition at line 872 of file lvecBase4.h.

LVecBase3f LQuaternionf::get_hpr ( CoordinateSystem  cs = CS_default) const [inherited]

Extracts the equivalent Euler angles from the unit quaternion.

Definition at line 197 of file lquaternion.cxx.

Referenced by CLerpNodePathInterval::priv_step(), CLerpNodePathInterval::set_end_hpr(), and PhysicsObject::write().

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

Returns the number of elements in the vector, four.

Definition at line 631 of file lvecBase4.h.

LVector3f LQuaternionf::get_right ( CoordinateSystem  cs = CS_default) const [inline, inherited]

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

Definition at line 620 of file lquaternion.h.

LVector3f LQuaternionf::get_up ( CoordinateSystem  cs = CS_default) const [inline, inherited]

Returns the orientation represented by this quaternion, expressed as an up vector.

Definition at line 609 of file lquaternion.h.

const LQuaternionf & LQuaternionf::ident_quat ( ) [inline, static, inherited]

Returns an identity quaternion.

Definition at line 845 of file lquaternion.h.

Referenced by TrackerData::get_orient(), NodePath::get_quat(), PhysicsObject::PhysicsObject(), and PhysicsObject::reset_orientation().

bool LQuaternionf::invert_from ( const LQuaternionf 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 798 of file lquaternion.h.

bool LQuaternionf::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 811 of file lquaternion.h.

bool LQuaternionf::is_almost_identity ( float  tolerance) const [inline, inherited]

Returns true if this quaternion represents the identity transformation within a given tolerance.

Definition at line 834 of file lquaternion.h.

bool LQuaternionf::is_identity ( ) const [inline, inherited]

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

Definition at line 823 of file lquaternion.h.

bool LVecBase4f::is_nan ( ) const [inline, inherited]
bool LQuaternionf::is_same_direction ( const LQuaternionf 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 475 of file lquaternion.h.

float LVecBase4f::length ( ) const [inline, inherited]

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

Definition at line 716 of file lvecBase4.h.

float LVecBase4f::length_squared ( ) const [inline, inherited]

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

Definition at line 727 of file lvecBase4.h.

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

actual multiply call (non virtual)

Definition at line 306 of file lquaternion.h.

bool LQuaternionf::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 LVecBase4f.

Definition at line 722 of file lquaternion.h.

Referenced by FFTCompressor::read_hprs(), and FFTCompressor::write_hprs().

LMatrix3f LQuaternionf::operator* ( const LMatrix3f m) [inline, inherited]

Quat * Matrix = matrix.

Definition at line 416 of file lquaternion.h.

LOrientationf LOrientationf::operator* ( const LQuaternionf other) const [inline]

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

Reimplemented from LQuaternionf.

Definition at line 209 of file lorientation.h.

LMatrix4f LQuaternionf::operator* ( const LMatrix4f m) [inline, inherited]

Quat * Matrix = matrix.

Definition at line 428 of file lquaternion.h.

LOrientationf LOrientationf::operator* ( const LRotationf other) const [inline]

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

Definition at line 197 of file lorientation.h.

bool LVecBase4f::operator< ( const LVecBase4f 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 787 of file lvecBase4.h.

LVecBase4f LVecBase4f::project ( const LVecBase4f 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 LPoint4f, and LVector4f.

Definition at line 773 of file lvecBase4.h.

void LVecBase4f::read_datagram ( DatagramIterator source) [inline, inherited]
void LQuaternionf::set_from_axis_angle ( float  angle_deg,
const LVector3f axis 
) [inline, inherited]

angle_deg is the angle about the axis in degrees.

axis must be normalized.

Definition at line 598 of file lquaternion.h.

Referenced by PhysicsObject::add_impact().

void LQuaternionf::set_from_axis_angle_rad ( float  angle_rad,
const LVector3f axis 
) [inline, inherited]

angle_rad is the angle about the axis in radians.

axis must be normalized.

Definition at line 582 of file lquaternion.h.

void LQuaternionf::set_from_matrix ( const LMatrix3f 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 301 of file lquaternion.cxx.

void LQuaternionf::set_hpr ( const LVecBase3f hpr,
CoordinateSystem  cs = CS_default 
) [inherited]
int LVecBase4f::size ( ) [inline, static, inherited]

Returns 4: the number of components of a LVecBase4.

Definition at line 444 of file lvecBase4.h.

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

Returns a unit W vector.

Reimplemented in LPoint4f, and LVector4f.

Definition at line 399 of file lvecBase4.h.

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

Returns a unit X vector.

Reimplemented in LPoint4f, and LVector4f.

Definition at line 369 of file lvecBase4.h.

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

Returns a unit Y vector.

Reimplemented in LPoint4f, and LVector4f.

Definition at line 379 of file lvecBase4.h.

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

Returns a unit Z vector.

Reimplemented in LPoint4f, and LVector4f.

Definition at line 389 of file lvecBase4.h.

void LVecBase4f::write_datagram ( Datagram destination) const [inline, inherited]
LVecBase3f LQuaternionf::xform ( const LVecBase3f v) const [inline, inherited]

Transforms a 3-d vector by the indicated rotation.

Definition at line 274 of file lquaternion.h.

Referenced by PhysicsObject::add_local_impact(), PhysicsObject::add_local_impulse(), and PhysicsObject::add_local_torque().

LVecBase4f LQuaternionf::xform ( const LVecBase4f v) const [inline, inherited]

Transforms a 4-d vector by the indicated rotation.

Definition at line 290 of file lquaternion.h.

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

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