Bullet Collision Detection & Physics Library: btQuaternion Class Reference

Bullet Collision Detection & Physics Library

Public Member Functions | Static Public Member Functions | List of all members
btQuaternion Class Reference

The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatrix3x3, btVector3 and btTransform. More...

`#include <btQuaternion.h>`

Inheritance diagram for btQuaternion:
[legend]
Collaboration diagram for btQuaternion:
[legend]

## Public Member Functions
| btQuaternion ()
| No initialization constructor.
| btQuaternion (const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
| Constructor from scalars.
| btQuaternion (const btVector3 &_axis, const btScalar &_angle)
| Axis angle Constructor.
| btQuaternion (const btScalar &yaw, const btScalar &pitch, const btScalar &roll)
| Constructor from Euler angles.
void | setRotation (const btVector3 &axis, const btScalar &_angle)
| Set the rotation using axis angle notation.
void | setEuler (const btScalar &yaw, const btScalar &pitch, const btScalar &roll)
| Set the quaternion using Euler angles.
void | setEulerZYX (const btScalar &yawZ, const btScalar &pitchY, const btScalar &rollX)
| Set the quaternion using euler angles.
void | getEulerZYX (btScalar &yawZ, btScalar &pitchY, btScalar &rollX) const
| Get the euler angles from this quaternion.
btQuaternion & | operator+= (const btQuaternion &q)
| Add two quaternions.
btQuaternion & | operator-= (const btQuaternion &q)
| Subtract out a quaternion.
btQuaternion & | operator*= (const btScalar &s)
| Scale this quaternion.
btQuaternion & | operator*= (const btQuaternion &q)
| Multiply this quaternion by q on the right.
btScalar | dot (const btQuaternion &q) const
| Return the dot product between this quaternion and another.
btScalar | length2 () const
| Return the length squared of the quaternion.
btScalar | length () const
| Return the length of the quaternion.
btQuaternion & | safeNormalize ()
btQuaternion & | normalize ()
| Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.
btQuaternion | operator* (const btScalar &s) const
| Return a scaled version of this quaternion.
btQuaternion | operator/ (const btScalar &s) const
| Return an inversely scaled versionof this quaternion.
btQuaternion & | operator/= (const btScalar &s)
| Inversely scale this quaternion.
btQuaternion | normalized () const
| Return a normalized version of this quaternion.
btScalar | angle (const btQuaternion &q) const
| Return the half angle between this quaternion and the other.
btScalar | angleShortestPath (const btQuaternion &q) const
| Return the angle between this quaternion and the other along the shortest path.
btScalar | getAngle () const
| Return the angle [0, 2Pi] of rotation represented by this quaternion.
btScalar | getAngleShortestPath () const
| Return the angle [0, Pi] of rotation represented by this quaternion along the shortest path.
btVector3 | getAxis () const
| Return the axis of the rotation represented by this quaternion.
btQuaternion | inverse () const
| Return the inverse of this quaternion.
btQuaternion | operator+ (const btQuaternion &q2) const
| Return the sum of this quaternion and the other.
btQuaternion | operator- (const btQuaternion &q2) const
| Return the difference between this quaternion and the other.
btQuaternion | operator- () const
| Return the negative of this quaternion This simply negates each element.
btQuaternion | farthest (const btQuaternion &qd) const
btQuaternion | nearest (const btQuaternion &qd) const
btQuaternion | slerp (const btQuaternion &q, const btScalar &t) const
| Return the quaternion which is the result of Spherical Linear Interpolation between this and the other quaternion.
const btScalar & | getW () const
void | serialize (struct btQuaternionData &dataOut) const
void | deSerialize (const struct btQuaternionFloatData &dataIn)
void | deSerialize (const struct btQuaternionDoubleData &dataIn)
void | serializeFloat (struct btQuaternionFloatData &dataOut) const
void | deSerializeFloat (const struct btQuaternionFloatData &dataIn)
void | serializeDouble (struct btQuaternionDoubleData &dataOut) const
void | deSerializeDouble (const struct btQuaternionDoubleData &dataIn)
Public Member Functions inherited from btQuadWord
const btScalar & | getX () const
| Return the x value.
const btScalar & | getY () const
| Return the y value.
const btScalar & | getZ () const
| Return the z value.
void | setX (btScalar _x)
| Set the x value.
void | setY (btScalar _y)
| Set the y value.
void | setZ (btScalar _z)
| Set the z value.
void | setW (btScalar _w)
| Set the w value.
const btScalar & | x () const
| Return the x value.
const btScalar & | y () const
| Return the y value.
const btScalar & | z () const
| Return the z value.
const btScalar & | w () const
| Return the w value.
| operator btScalar * ()
| operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.
| operator const btScalar * () const
bool | operator== (const btQuadWord &other) const
bool | operator!= (const btQuadWord &other) const
void | setValue (const btScalar &_x, const btScalar &_y, const btScalar &_z)
| Set x,y,z and zero w.
void | setValue (const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
| Set the values.
| btQuadWord ()
| No initialization constructor.
| btQuadWord (const btScalar &_x, const btScalar &_y, const btScalar &_z)
| Three argument constructor (zeros w).
| btQuadWord (const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
| Initializing constructor.
void | setMax (const btQuadWord &other)
| Set each element to the max of the current values and the values of another btQuadWord.
void | setMin (const btQuadWord &other)
| Set each element to the min of the current values and the values of another btQuadWord.

## Static Public Member Functions
static const btQuaternion & | getIdentity ()

## Additional Inherited Members
Protected Attributes inherited from btQuadWord
btScalar | m_floats [4]

## Detailed Description

The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatrix3x3, btVector3 and btTransform.

Definition at line 49 of file btQuaternion.h.

## Constructor & Destructor Documentation

## ◆ btQuaternion() [1/4]

btQuaternion::btQuaternion | ( |  | ) |
| inline

No initialization constructor.

Definition at line 53 of file btQuaternion.h.

## ◆ btQuaternion() [2/4]

btQuaternion::btQuaternion | ( | const btScalar & | _x,
|  | const btScalar & | _y,
|  | const btScalar & | _z,
|  | const btScalar & | _w )
| inline

Constructor from scalars.

Definition at line 82 of file btQuaternion.h.

## ◆ btQuaternion() [3/4]

btQuaternion::btQuaternion | ( | const btVector3 & | _axis,
|  | const btScalar & | _angle )
| inline

Axis angle Constructor.

Parameters

  axis | The axis which the rotation is around
  angle | The magnitude of the rotation around the angle (Radians)

Definition at line 89 of file btQuaternion.h.

## ◆ btQuaternion() [4/4]

btQuaternion::btQuaternion | ( | const btScalar & | yaw,
|  | const btScalar & | pitch,
|  | const btScalar & | roll )
| inline

Constructor from Euler angles.

Parameters

  yaw | Angle around Y unless BT_EULER_DEFAULT_ZYX defined then Z
  pitch | Angle around X unless BT_EULER_DEFAULT_ZYX defined then Y
  roll | Angle around Z unless BT_EULER_DEFAULT_ZYX defined then X

Definition at line 97 of file btQuaternion.h.

## Member Function Documentation

## ◆ angle()

btScalar btQuaternion::angle | ( | const btQuaternion & | q | ) | const
| inline

Return the half angle between this quaternion and the other.

Parameters

  q | The other quaternion

Definition at line 448 of file btQuaternion.h.

## ◆ angleShortestPath()

btScalar btQuaternion::angleShortestPath | ( | const btQuaternion & | q | ) | const
| inline

Return the angle between this quaternion and the other along the shortest path.

Parameters

  q | The other quaternion

Definition at line 457 of file btQuaternion.h.

## ◆ deSerialize() [1/2]

void btQuaternion::deSerialize | ( | const struct btQuaternionDoubleData & | dataIn | ) |
| inline

Definition at line 1015 of file btQuaternion.h.

## ◆ deSerialize() [2/2]

void btQuaternion::deSerialize | ( | const struct btQuaternionFloatData & | dataIn | ) |
| inline

Definition at line 1009 of file btQuaternion.h.

## ◆ deSerializeDouble()

void btQuaternion::deSerializeDouble | ( | const struct btQuaternionDoubleData & | dataIn | ) |
| inline

Definition at line 996 of file btQuaternion.h.

## ◆ deSerializeFloat()

void btQuaternion::deSerializeFloat | ( | const struct btQuaternionFloatData & | dataIn | ) |
| inline

Definition at line 983 of file btQuaternion.h.

## ◆ dot()

btScalar btQuaternion::dot | ( | const btQuaternion & | q | ) | const
| inline

Return the dot product between this quaternion and another.

Parameters

  q | The other quaternion

Definition at line 337 of file btQuaternion.h.

## ◆ farthest()

btQuaternion btQuaternion::farthest | ( | const btQuaternion & | qd | ) | const
| inline

Definition at line 552 of file btQuaternion.h.

## ◆ getAngle()

btScalar btQuaternion::getAngle | ( |  | ) | const
| inline

Return the angle [0, 2Pi] of rotation represented by this quaternion.

Definition at line 468 of file btQuaternion.h.

## ◆ getAngleShortestPath()

btScalar btQuaternion::getAngleShortestPath | ( |  | ) | const
| inline

Return the angle [0, Pi] of rotation represented by this quaternion along the shortest path.

Definition at line 475 of file btQuaternion.h.

## ◆ getAxis()

btVector3 btQuaternion::getAxis | ( |  | ) | const
| inline

Return the axis of the rotation represented by this quaternion.

Definition at line 486 of file btQuaternion.h.

## ◆ getEulerZYX()

void btQuaternion::getEulerZYX | ( | btScalar & | yawZ,
|  | btScalar & | pitchY,
|  | btScalar & | rollX ) const
| inline

Get the euler angles from this quaternion.

Parameters

  yaw | Angle around Z
  pitch | Angle around Y
  roll | Angle around X

Definition at line 161 of file btQuaternion.h.

## ◆ getIdentity()

const btQuaternion & btQuaternion::getIdentity | ( |  | ) |
| inlinestatic

Definition at line 608 of file btQuaternion.h.

## ◆ getW()

const btScalar & btQuaternion::getW | ( |  | ) | const
| inline

Definition at line 614 of file btQuaternion.h.

## ◆ inverse()

btQuaternion btQuaternion::inverse | ( |  | ) | const
| inline

Return the inverse of this quaternion.

Definition at line 497 of file btQuaternion.h.

## ◆ length()

btScalar btQuaternion::length | ( |  | ) | const
| inline

Return the length of the quaternion.

Definition at line 370 of file btQuaternion.h.

## ◆ length2()

btScalar btQuaternion::length2 | ( |  | ) | const
| inline

Return the length squared of the quaternion.

Definition at line 364 of file btQuaternion.h.

## ◆ nearest()

btQuaternion btQuaternion::nearest | ( | const btQuaternion & | qd | ) | const
| inline

Definition at line 563 of file btQuaternion.h.

## ◆ normalize()

btQuaternion & btQuaternion::normalize | ( |  | ) |
| inline

Normalize the quaternion Such that x^2 + y^2 + z^2 +w^2 = 1.

Definition at line 385 of file btQuaternion.h.

## ◆ normalized()

btQuaternion btQuaternion::normalized | ( |  | ) | const
| inline

Return a normalized version of this quaternion.

Definition at line 442 of file btQuaternion.h.

## ◆ operator*()

btQuaternion btQuaternion::operator* | ( | const btScalar & | s | ) | const
| inline

Return a scaled version of this quaternion.

Parameters

  s | The scale factor

Definition at line 411 of file btQuaternion.h.

## ◆ operator*=() [1/2]

btQuaternion & btQuaternion::operator*= | ( | const btQuaternion & | q | ) |
| inline

Multiply this quaternion by q on the right.

Parameters

  q | The other quaternion Equivilant to this = this * q

Definition at line 254 of file btQuaternion.h.

## ◆ operator*=() [2/2]

btQuaternion & btQuaternion::operator*= | ( | const btScalar & | s | ) |
| inline

Scale this quaternion.

Parameters

  s | The scalar to scale by

Definition at line 234 of file btQuaternion.h.

## ◆ operator+()

btQuaternion btQuaternion::operator+ | ( | const btQuaternion & | q2 | ) | const
| inline

Return the sum of this quaternion and the other.

Parameters

  q2 | The other quaternion

Definition at line 511 of file btQuaternion.h.

## ◆ operator+=()

btQuaternion & btQuaternion::operator+= | ( | const btQuaternion & | q | ) |
| inline

Add two quaternions.

Parameters

  q | The quaternion to add to this one

Definition at line 200 of file btQuaternion.h.

## ◆ operator-() [1/2]

btQuaternion btQuaternion::operator- | ( |  | ) | const
| inline

Return the negative of this quaternion This simply negates each element.

Definition at line 540 of file btQuaternion.h.

## ◆ operator-() [2/2]

btQuaternion btQuaternion::operator- | ( | const btQuaternion & | q2 | ) | const
| inline

Return the difference between this quaternion and the other.

Parameters

  q2 | The other quaternion

Definition at line 526 of file btQuaternion.h.

## ◆ operator-=()

btQuaternion & btQuaternion::operator-= | ( | const btQuaternion & | q | ) |
| inline

Subtract out a quaternion.

Parameters

  q | The quaternion to subtract from this one

Definition at line 217 of file btQuaternion.h.

## ◆ operator/()

btQuaternion btQuaternion::operator/ | ( | const btScalar & | s | ) | const
| inline

Return an inversely scaled versionof this quaternion.

Parameters

  s | The inverse scale factor

Definition at line 427 of file btQuaternion.h.

## ◆ operator/=()

btQuaternion & btQuaternion::operator/= | ( | const btScalar & | s | ) |
| inline

Inversely scale this quaternion.

Parameters

  s | The scale factor

Definition at line 435 of file btQuaternion.h.

## ◆ safeNormalize()

btQuaternion & btQuaternion::safeNormalize | ( |  | ) |
| inline

Definition at line 374 of file btQuaternion.h.

## ◆ serialize()

void btQuaternion::serialize | ( | struct btQuaternionData & | dataOut | ) | const
| inline

could also do a memcpy, check if it is worth it

Definition at line 1002 of file btQuaternion.h.

## ◆ serializeDouble()

void btQuaternion::serializeDouble | ( | struct btQuaternionDoubleData & | dataOut | ) | const
| inline

could also do a memcpy, check if it is worth it

Definition at line 989 of file btQuaternion.h.

## ◆ serializeFloat()

void btQuaternion::serializeFloat | ( | struct btQuaternionFloatData & | dataOut | ) | const
| inline

could also do a memcpy, check if it is worth it

Definition at line 976 of file btQuaternion.h.

## ◆ setEuler()

void btQuaternion::setEuler | ( | const btScalar & | yaw,
|  | const btScalar & | pitch,
|  | const btScalar & | roll )
| inline

Set the quaternion using Euler angles.

Parameters

  yaw | Angle around Y
  pitch | Angle around X
  roll | Angle around Z

Definition at line 120 of file btQuaternion.h.

## ◆ setEulerZYX()

void btQuaternion::setEulerZYX | ( | const btScalar & | yawZ,
|  | const btScalar & | pitchY,
|  | const btScalar & | rollX )
| inline

Set the quaternion using euler angles.

Parameters

  yaw | Angle around Z
  pitch | Angle around Y
  roll | Angle around X

Definition at line 140 of file btQuaternion.h.

## ◆ setRotation()

void btQuaternion::setRotation | ( | const btVector3 & | axis,
|  | const btScalar & | _angle )
| inline

Set the rotation using axis angle notation.

Parameters

  axis | The axis around which to rotate
  angle | The magnitude of the rotation in Radians

Definition at line 108 of file btQuaternion.h.

## ◆ slerp()

btQuaternion btQuaternion::slerp | ( | const btQuaternion & | q,
|  | const btScalar & | t ) const
| inline

Return the quaternion which is the result of Spherical Linear Interpolation between this and the other quaternion.

Parameters

  q | The other quaternion to interpolate with
  t | The ratio between this and q to interpolate. If t = 0 the result is this, if t=1 the result is q. Slerp interpolates assuming constant velocity.

Definition at line 577 of file btQuaternion.h.

The documentation for this class was generated from the following file:

- btQuaternion.h