Panda3D
Public Member Functions | Static Public Member Functions
LQuaternionf Class Reference

This is the base quaternion class. More...

#include "lquaternion.h"

Inheritance diagram for LQuaternionf:
LVecBase4f LOrientationf LRotationf

List of all members.

Public Member Functions

 LQuaternionf (const LVecBase4f &copy)
 LQuaternionf (float, const LVecBase3f &copy)
 LQuaternionf (float, float, float, float)
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_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.
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.
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.
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.
LVector3f get_forward (CoordinateSystem cs=CS_default) const
 Returns the orientation represented by this quaternion, expressed as a forward vector.
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
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.
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_same_direction (const LQuaternionf &other) const
 Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.
LQuaternionf multiply (const LQuaternionf &rhs) const
 actual multiply call (non virtual)
bool normalize ()
 Normalizes the vector in place.
LQuaternionf operator* (float scalar) const
LQuaternionf operator* (const LQuaternionf &) const
LMatrix3f operator* (const LMatrix3f &)
 Quat * Matrix = matrix.
LMatrix4f operator* (const LMatrix4f &)
 Quat * Matrix = matrix.
LQuaternionfoperator*= (const LQuaternionf &)
LQuaternionf operator+ (const LQuaternionf &other) const
LQuaternionf operator- () const
LQuaternionf operator- (const LQuaternionf &other) const
LQuaternionf operator/ (float scalar) const
void output (ostream &) const
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 LMatrix3f &m)
 Sets the quaternion according to the rotation represented by the matrix.
void set_from_matrix (const LMatrix4f &m)
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)
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 &)

Detailed Description

This is the base quaternion class.

Definition at line 90 of file lquaternion.h.


Member Function Documentation

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

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]

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

Definition at line 459 of file lquaternion.h.

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

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]

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]

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.

Returns the complex conjugate of this quat.

Definition at line 739 of file lquaternion.h.

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

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.

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

Based on the quat lib from VRPN.

Definition at line 123 of file lquaternion.cxx.

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

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

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

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.

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

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

Definition at line 631 of file lquaternion.h.

LVecBase3f LQuaternionf::get_hpr ( CoordinateSystem  cs = CS_default) const

Extracts the equivalent Euler angles from the unit quaternion.

Definition at line 201 of file lquaternion.cxx.

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

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

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]

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]

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]

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]

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]

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]

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

Definition at line 823 of file lquaternion.h.

bool LQuaternionf::is_same_direction ( const LQuaternionf other) const [inline]

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.

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

actual multiply call (non virtual)

Definition at line 306 of file lquaternion.h.

bool LQuaternionf::normalize ( ) [inline]

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]

Quat * Matrix = matrix.

Definition at line 416 of file lquaternion.h.

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

Quat * Matrix = matrix.

Definition at line 428 of file lquaternion.h.

void LQuaternionf::set_from_axis_angle ( float  angle_deg,
const LVector3f axis 
) [inline]

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]

angle_rad is the angle about the axis in radians.

axis must be normalized.

Definition at line 582 of file lquaternion.h.

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 305 of file lquaternion.cxx.

void LQuaternionf::set_hpr ( const LVecBase3f hpr,
CoordinateSystem  cs = CS_default 
)
LVecBase3f LQuaternionf::xform ( const LVecBase3f v) const [inline]

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(), PhysicsObject::add_local_torque(), and STTransform::operator*=().

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

Transforms a 4-d vector by the indicated rotation.

Definition at line 290 of file lquaternion.h.


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