Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# Quat Class Reference

This is the base quaternion class. More...

Inheritance diagram for Quat:

List of all members.

## Public Member Functions
| Quat ()
| Quat (VBase4 const copy)
| Quat (float, float, float, float)
| Quat (float, VBase3 const copy)
bool | almostEqual (Quat const other)
| Returns true if two quaternions are memberwise equal within a default tolerance based on the numeric type.
bool | almostEqual (Quat const other, float threshold)
| Returns true if two quaternions are memberwise equal within a specified tolerance.
bool | almostSameDirection (Quat const other, float threshold)
| Returns true if two quaternions represent the same rotation within a specified tolerance.
float | angleDeg (Quat const other)
| Returns the angle between the orientation represented by this quaternion and the other one, expressed in degrees.
float | angleRad (Quat const other)
| Returns the angle between the orientation represented by this quaternion and the other one, expressed in radians.
Quat | conjugate ()
| Returns the complex conjugate of this quat.
bool | conjugateFrom (Quat 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.
| extractToMatrix (Mat3 m)
| Based on the quat lib from VRPN.
| extractToMatrix (Mat4 m)
| Based on the quat lib from VRPN.
float | getAngle ()
| This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
float | getAngleRad ()
| This, along with get_axis(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
Vec3 | getAxis ()
| This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
Vec3 | getAxisNormalized ()
| This, along with get_angle(), returns the rotation represented by the quaternion as an angle about an arbitrary axis.
Vec3 | getForward (CoordinateSystem cs)
| Returns the orientation represented by this quaternion, expressed as a forward vector.
Vec3 | getForward ()
| Returns the orientation represented by this quaternion, expressed as a forward vector.
VBase3 | getHpr ()
| Extracts the equivalent Euler angles from the unit quaternion.
VBase3 | getHpr (CoordinateSystem cs)
| Extracts the equivalent Euler angles from the unit quaternion.
float | getI ()
float | getJ ()
float | getK ()
float | getR ()
Vec3 | getRight (CoordinateSystem cs)
| Returns the orientation represented by this quaternion, expressed as a right vector.
Vec3 | getRight ()
| Returns the orientation represented by this quaternion, expressed as a right vector.
Vec3 | getUp (CoordinateSystem cs)
| Returns the orientation represented by this quaternion, expressed as an up vector.
Vec3 | getUp ()
| Returns the orientation represented by this quaternion, expressed as an up vector.
bool | invertFrom (Quat const other)
| Computes the inverse of the other quat, and stores the result in this quat.
bool | invertInPlace ()
| Inverts the current quat.
bool | isAlmostIdentity (float 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 | isSameDirection (Quat const other)
| Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.
Quat | multiply (Quat const rhs)
| actual multiply call (non virtual)
bool | normalize ()
| Normalizes the vector in place.
Mat4 | operator* (Mat4 const )
| Quat * Matrix = matrix.
Quat | operator* (float scalar)
Quat | operator* (Quat const )
Mat3 | operator* (Mat3 const )
| Quat * Matrix = matrix.
Quat | operator*= (Quat const )
Quat | operator+ (Quat const other)
Quat | operator- ()
Quat | operator- (Quat const other)
Quat | operator/ (float scalar)
| output (ostream)
| setFromAxisAngle (float angle_deg, Vec3 const axis)
| angle_deg is the angle about the axis in degrees.
| setFromAxisAngleRad (float angle_rad, Vec3 const axis)
| angle_rad is the angle about the axis in radians.
| setFromMatrix (Mat4 const m)
| setFromMatrix (Mat3 const m)
| Sets the quaternion according to the rotation represented by the matrix.
| setHpr (VBase3 const hpr, CoordinateSystem cs)
| Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
| setHpr (VBase3 const hpr)
| Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
| setI (float i)
| setJ (float j)
| setK (float k)
| setR (float r)
VBase3 | xform (VBase3 const v)
| Transforms a 3-d vector by the indicated rotation.
VBase4 | xform (VBase4 const v)
| Transforms a 4-d vector by the indicated rotation.
## Static Public Member Functions
static TypeHandle | getClassType ()
static Quat const | identQuat ()
| Returns an identity quaternion.
static Quat | pureImaginary (Vec3 const )

## Detailed Description

This is the base quaternion class.

## Constructor & Destructor Documentation

Quat | ( |  | ) |

Quat | ( | VBase4 const | copy | ) |

Quat | ( | float | ,
|  | VBase3 const | copy
| ) |  |

Quat | ( | float | ,
|  | float | ,
|  | float | ,
|  | float |
| ) |  |

## Member Function Documentation

bool almostEqual | ( | Quat const | other | ) |

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

bool almostEqual | ( | Quat const | other,
|  | float | threshold
| ) |  |

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

bool almostSameDirection | ( | Quat const | other,
|  | float | threshold
| ) |  |

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

float angleDeg | ( | Quat const | other | ) |

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

float angleRad | ( | Quat const | other | ) |

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

Quat conjugate | ( |  | ) |

Returns the complex conjugate of this quat.

bool conjugateFrom | ( | Quat 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.

extractToMatrix | ( | Mat3 | m | ) |

Based on the quat lib from VRPN.

extractToMatrix | ( | Mat4 | m | ) |

Based on the quat lib from VRPN.

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

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

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

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

static TypeHandle getClassType | ( |  | ) | `[static]`

Reimplemented from VBase4.

Reimplemented in LRotationf, and LOrientationf.

Vec3 getForward | ( | CoordinateSystem | cs | ) |

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

Vec3 getForward | ( |  | ) |

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

VBase3 getHpr | ( | CoordinateSystem | cs | ) |

Extracts the equivalent Euler angles from the unit quaternion.

VBase3 getHpr | ( |  | ) |

Extracts the equivalent Euler angles from the unit quaternion.

float getI | ( |  | ) |

float getJ | ( |  | ) |

float getK | ( |  | ) |

float getR | ( |  | ) |

Vec3 getRight | ( | CoordinateSystem | cs | ) |

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

Vec3 getRight | ( |  | ) |

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

Vec3 getUp | ( |  | ) |

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

Vec3 getUp | ( | CoordinateSystem | cs | ) |

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

static Quat const identQuat | ( |  | ) | `[static]`

Returns an identity quaternion.

bool invertFrom | ( | Quat 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 | ( | float | 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 isSameDirection | ( | Quat const | other | ) |

Returns true if two quaternions represent the same rotation within a default tolerance based on the numeric type.

Quat multiply | ( | Quat const | rhs | ) |

actual multiply call (non virtual)

bool normalize | ( |  | ) |

Normalizes the vector in place.

Returns true if the vector was normalized, false if it was a zero-length vector.

Reimplemented from VBase4.

Mat4 operator* | ( | Mat4 | const | ) |

Quat * Matrix = matrix.

Quat operator* | ( | float | scalar | ) |

Reimplemented from VBase4.

Reimplemented in LRotationf.

Mat3 operator* | ( | Mat3 | const | ) |

Quat * Matrix = matrix.

Quat operator* | ( | Quat | const | ) |

Reimplemented in LRotationf, and LOrientationf.

Quat operator*= | ( | Quat | const | ) |

Quat operator+ | ( | Quat const | other | ) |

Quat operator- | ( |  | ) |

Reimplemented from VBase4.

Quat operator- | ( | Quat const | other | ) |

Quat operator/ | ( | float | scalar | ) |

Reimplemented from VBase4.

Reimplemented in LRotationf.

output | ( | ostream |  | ) |

Reimplemented from VBase4.

static Quat pureImaginary | ( | Vec3 | const | ) | `[static]`

setFromAxisAngle | ( | float | angle_deg,
|  | Vec3 const | axis
| ) |  |

angle_deg is the angle about the axis in degrees.

axis must be normalized.

setFromAxisAngleRad | ( | float | angle_rad,
|  | Vec3 const | axis
| ) |  |

angle_rad is the angle about the axis in radians.

axis must be normalized.

setFromMatrix | ( | Mat3 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.

setFromMatrix | ( | Mat4 const | m | ) |

setHpr | ( | VBase3 const | hpr | ) |

Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.

(from Real-time Rendering, p.49)

setHpr | ( | VBase3 const | hpr,
|  | CoordinateSystem | cs
| ) |  |

Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.

(from Real-time Rendering, p.49)

setI | ( | float | i | ) |

setJ | ( | float | j | ) |

setK | ( | float | k | ) |

setR | ( | float | r | ) |

VBase4 xform | ( | VBase4 const | v | ) |

Transforms a 4-d vector by the indicated rotation.

VBase3 xform | ( | VBase3 const | v | ) |

Transforms a 3-d vector by the indicated rotation.

All Classes Namespaces Functions Variables Enumerations Enumerator Properties