Bullet Collision Detection & Physics Library: btVector3 Class Reference

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
btVector3 Class Reference

btVector3 can be used to represent 3D points and vectors. More...

`#include <btVector3.h>`

Inheritance diagram for btVector3:
[legend]

## Public Member Functions
| BT_DECLARE_ALIGNED_ALLOCATOR ()
| btVector3 ()
| No initialization constructor.
| btVector3 (const btScalar &_x, const btScalar &_y, const btScalar &_z)
| Constructor from scalars.
btVector3 & | operator+= (const btVector3 &v)
| Add a vector to this one.
btVector3 & | operator-= (const btVector3 &v)
| Subtract a vector from this one.
btVector3 & | operator*= (const btScalar &s)
| Scale the vector.
btVector3 & | operator/= (const btScalar &s)
| Inversely scale the vector.
btScalar | dot (const btVector3 &v) const
| Return the dot product.
btScalar | length2 () const
| Return the length of the vector squared.
btScalar | length () const
| Return the length of the vector.
btScalar | norm () const
| Return the norm (length) of the vector.
btScalar | safeNorm () const
| Return the norm (length) of the vector.
btScalar | distance2 (const btVector3 &v) const
| Return the distance squared between the ends of this and another vector This is symantically treating the vector like a point.
btScalar | distance (const btVector3 &v) const
| Return the distance between the ends of this and another vector This is symantically treating the vector like a point.
btVector3 & | safeNormalize ()
btVector3 & | normalize ()
| Normalize this vector x^2 + y^2 + z^2 = 1.
btVector3 | normalized () const
| Return a normalized version of this vector.
btVector3 | rotate (const btVector3 &wAxis, const btScalar angle) const
| Return a rotated version of this vector.
btScalar | angle (const btVector3 &v) const
| Return the angle between this and another vector.
btVector3 | absolute () const
| Return a vector with the absolute values of each element.
btVector3 | cross (const btVector3 &v) const
| Return the cross product between this and another vector.
btScalar | triple (const btVector3 &v1, const btVector3 &v2) const
int | minAxis () const
| Return the axis with the smallest value Note return values are 0,1,2 for x, y, or z.
int | maxAxis () const
| Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
int | furthestAxis () const
int | closestAxis () const
void | setInterpolate3 (const btVector3 &v0, const btVector3 &v1, btScalar rt)
btVector3 | lerp (const btVector3 &v, const btScalar &t) const
| Return the linear interpolation between this and another vector.
btVector3 & | operator*= (const btVector3 &v)
| Elementwise multiply this vector by the other.
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 btVector3 &other) const
bool | operator!= (const btVector3 &other) const
void | setMax (const btVector3 &other)
| Set each element to the max of the current values and the values of another btVector3.
void | setMin (const btVector3 &other)
| Set each element to the min of the current values and the values of another btVector3.
void | setValue (const btScalar &_x, const btScalar &_y, const btScalar &_z)
void | getSkewSymmetricMatrix (btVector3 *v0, btVector3 *v1, btVector3 *v2) const
void | setZero ()
bool | isZero () const
bool | fuzzyZero () const
void | serialize (struct btVector3Data &dataOut) const
void | deSerialize (const struct btVector3DoubleData &dataIn)
void | deSerialize (const struct btVector3FloatData &dataIn)
void | serializeFloat (struct btVector3FloatData &dataOut) const
void | deSerializeFloat (const struct btVector3FloatData &dataIn)
void | serializeDouble (struct btVector3DoubleData &dataOut) const
void | deSerializeDouble (const struct btVector3DoubleData &dataIn)
long | maxDot (const btVector3 *array, long array_count, btScalar &dotOut) const
| returns index of maximum dot product between this and vectors in array[]
long | minDot (const btVector3 *array, long array_count, btScalar &dotOut) const
| returns index of minimum dot product between this and vectors in array[]
btVector3 | dot3 (const btVector3 &v0, const btVector3 &v1, const btVector3 &v2) const

## Public Attributes
btScalar | m_floats [4]

## Detailed Description

btVector3 can be used to represent 3D points and vectors.

It has an un-used w component to suit 16-byte alignment when btVector3 is stored in containers. This extra component can be used by derived classes (Quaternion?) or by user Ideally, this class should be replaced by a platform optimized SIMD version that keeps the data in registers

Definition at line 80 of file btVector3.h.

## Constructor & Destructor Documentation

## ◆ btVector3() [1/2]

btVector3::btVector3 | ( |  | ) |
| inline

No initialization constructor.

Definition at line 117 of file btVector3.h.

## ◆ btVector3() [2/2]

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

Constructor from scalars.

Parameters

  x | X value
  y | Y value
  z | Z value

Definition at line 126 of file btVector3.h.

## Member Function Documentation

## ◆ absolute()

btVector3 btVector3::absolute | ( |  | ) | const
| inline

Return a vector with the absolute values of each element.

Definition at line 364 of file btVector3.h.

## ◆ angle()

btScalar btVector3::angle | ( | const btVector3 & | v | ) | const
| inline

Return the angle between this and another vector.

Parameters

  v | The other vector

Definition at line 356 of file btVector3.h.

## ◆ BT_DECLARE_ALIGNED_ALLOCATOR()

btVector3::BT_DECLARE_ALIGNED_ALLOCATOR | ( |  | ) |

## ◆ closestAxis()

int btVector3::closestAxis | ( |  | ) | const
| inline

Definition at line 487 of file btVector3.h.

## ◆ cross()

btVector3 btVector3::cross | ( | const btVector3 & | v | ) | const
| inline

Return the cross product between this and another vector.

Parameters

  v | The other vector

Definition at line 380 of file btVector3.h.

## ◆ deSerialize() [1/2]

void btVector3::deSerialize | ( | const struct btVector3DoubleData & | dataIn | ) |
| inline

Definition at line 1330 of file btVector3.h.

## ◆ deSerialize() [2/2]

void btVector3::deSerialize | ( | const struct btVector3FloatData & | dataIn | ) |
| inline

Definition at line 1324 of file btVector3.h.

## ◆ deSerializeDouble()

void btVector3::deSerializeDouble | ( | const struct btVector3DoubleData & | dataIn | ) |
| inline

Definition at line 1311 of file btVector3.h.

## ◆ deSerializeFloat()

void btVector3::deSerializeFloat | ( | const struct btVector3FloatData & | dataIn | ) |
| inline

Definition at line 1298 of file btVector3.h.

## ◆ distance()

btScalar btVector3::distance | ( | const btVector3 & | v | ) | const
| inline

Return the distance between the ends of this and another vector This is symantically treating the vector like a point.

Definition at line 944 of file btVector3.h.

## ◆ distance2()

btScalar btVector3::distance2 | ( | const btVector3 & | v | ) | const
| inline

Return the distance squared between the ends of this and another vector This is symantically treating the vector like a point.

Definition at line 939 of file btVector3.h.

## ◆ dot()

btScalar btVector3::dot | ( | const btVector3 & | v | ) | const
| inline

Return the dot product.

Parameters

  v | The other vector in the dot product

Definition at line 229 of file btVector3.h.

## ◆ dot3()

btVector3 btVector3::dot3 | ( | const btVector3 & | v0,
|  | const btVector3 & | v1,
|  | const btVector3 & | v2
| ) |  | const
| inline

Definition at line 720 of file btVector3.h.

## ◆ furthestAxis()

int btVector3::furthestAxis | ( |  | ) | const
| inline

Definition at line 482 of file btVector3.h.

## ◆ fuzzyZero()

bool btVector3::fuzzyZero | ( |  | ) | const
| inline

Definition at line 688 of file btVector3.h.

## ◆ getSkewSymmetricMatrix()

void btVector3::getSkewSymmetricMatrix | ( | btVector3 * | v0,
|  | btVector3 * | v1,
|  | btVector3 * | v2
| ) |  | const
| inline

Definition at line 648 of file btVector3.h.

## ◆ getX()

const btScalar & btVector3::getX | ( |  | ) | const
| inline

Return the x value.

Definition at line 561 of file btVector3.h.

## ◆ getY()

const btScalar & btVector3::getY | ( |  | ) | const
| inline

Return the y value.

Definition at line 563 of file btVector3.h.

## ◆ getZ()

const btScalar & btVector3::getZ | ( |  | ) | const
| inline

Return the z value.

Definition at line 565 of file btVector3.h.

## ◆ isZero()

bool btVector3::isZero | ( |  | ) | const
| inline

Definition at line 683 of file btVector3.h.

## ◆ length()

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

Return the length of the vector.

Definition at line 257 of file btVector3.h.

## ◆ length2()

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

Return the length of the vector squared.

Definition at line 251 of file btVector3.h.

## ◆ lerp()

btVector3 btVector3::lerp | ( | const btVector3 & | v,
|  | const btScalar & | t
| ) |  | const
| inline

Return the linear interpolation between this and another vector.

Parameters

  v | The other vector
  t | The ration of this to v (t = 0 => return this, t=1 => return other)

Definition at line 521 of file btVector3.h.

## ◆ maxAxis()

int btVector3::maxAxis | ( |  | ) | const
| inline

Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.

Definition at line 477 of file btVector3.h.

## ◆ maxDot()

long btVector3::maxDot | ( | const btVector3 * | array,
|  | long | array_count,
|  | btScalar & | dotOut
| ) |  | const
| inline

returns index of maximum dot product between this and vectors in array[]

Parameters

  array | The other vectors
  array_count | The number of other vectors
  dotOut | The maximum dot product

Definition at line 998 of file btVector3.h.

## ◆ minAxis()

int btVector3::minAxis | ( |  | ) | const
| inline

Return the axis with the smallest value Note return values are 0,1,2 for x, y, or z.

Definition at line 470 of file btVector3.h.

## ◆ minDot()

long btVector3::minDot | ( | const btVector3 * | array,
|  | long | array_count,
|  | btScalar & | dotOut
| ) |  | const
| inline

returns index of minimum dot product between this and vectors in array[]

Parameters

  array | The other vectors
  array_count | The number of other vectors
  dotOut | The minimum dot product

Definition at line 1033 of file btVector3.h.

## ◆ norm()

btScalar btVector3::norm | ( |  | ) | const
| inline

Return the norm (length) of the vector.

Definition at line 263 of file btVector3.h.

## ◆ normalize()

btVector3 & btVector3::normalize | ( |  | ) |
| inline

Normalize this vector x^2 + y^2 + z^2 = 1.

Definition at line 303 of file btVector3.h.

## ◆ normalized()

btVector3 btVector3::normalized | ( |  | ) | const
| inline

Return a normalized version of this vector.

Definition at line 949 of file btVector3.h.

## ◆ operator btScalar *()

btVector3::operator btScalar * | ( |  | ) |
| inline

operator btScalar*() replaces operator[], using implicit conversion. We added operator != and operator == to avoid pointer comparisons.

Definition at line 586 of file btVector3.h.

## ◆ operator const btScalar *()

btVector3::operator const btScalar * | ( |  | ) | const
| inline

Definition at line 587 of file btVector3.h.

## ◆ operator!=()

bool btVector3::operator!= | ( | const btVector3 & | other | ) | const
| inline

Definition at line 601 of file btVector3.h.

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

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

Scale the vector.

Parameters

  s | Scale factor

Definition at line 191 of file btVector3.h.

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

btVector3 & btVector3::operator*= | ( | const btVector3 & | v | ) |
| inline

Elementwise multiply this vector by the other.

Parameters

  v | The other vector

Definition at line 546 of file btVector3.h.

## ◆ operator+=()

btVector3 & btVector3::operator+= | ( | const btVector3 & | v | ) |
| inline

Add a vector to this one.

Parameters

  The | vector to add to this one

Definition at line 159 of file btVector3.h.

## ◆ operator-=()

btVector3 & btVector3::operator-= | ( | const btVector3 & | v | ) |
| inline

Subtract a vector from this one.

Parameters

  The | vector to subtract

Definition at line 175 of file btVector3.h.

## ◆ operator/=()

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

Inversely scale the vector.

Parameters

  s | Scale factor to divide by

Definition at line 209 of file btVector3.h.

## ◆ operator==()

bool btVector3::operator== | ( | const btVector3 & | other | ) | const
| inline

Definition at line 589 of file btVector3.h.

## ◆ rotate()

btVector3 btVector3::rotate | ( | const btVector3 & | wAxis,
|  | const btScalar | angle
| ) |  | const
| inline

Return a rotated version of this vector.

Parameters

  wAxis | The axis to rotate about
  angle | The angle to rotate by

Definition at line 956 of file btVector3.h.

## ◆ safeNorm()

btScalar btVector3::safeNorm | ( |  | ) | const
| inline

Return the norm (length) of the vector.

Definition at line 269 of file btVector3.h.

## ◆ safeNormalize()

btVector3 & btVector3::safeNormalize | ( |  | ) |
| inline

Definition at line 286 of file btVector3.h.

## ◆ serialize()

void btVector3::serialize | ( | struct btVector3Data & | dataOut | ) | const
| inline

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

Definition at line 1317 of file btVector3.h.

## ◆ serializeDouble()

void btVector3::serializeDouble | ( | struct btVector3DoubleData & | dataOut | ) | const
| inline

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

Definition at line 1304 of file btVector3.h.

## ◆ serializeFloat()

void btVector3::serializeFloat | ( | struct btVector3FloatData & | dataOut | ) | const
| inline

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

Definition at line 1291 of file btVector3.h.

## ◆ setInterpolate3()

void btVector3::setInterpolate3 | ( | const btVector3 & | v0,
|  | const btVector3 & | v1,
|  | btScalar | rt
| ) |  |
| inline

Definition at line 492 of file btVector3.h.

## ◆ setMax()

void btVector3::setMax | ( | const btVector3 & | other | ) |
| inline

Set each element to the max of the current values and the values of another btVector3.

Parameters

  other | The other btVector3 to compare with

Definition at line 609 of file btVector3.h.

## ◆ setMin()

void btVector3::setMin | ( | const btVector3 & | other | ) |
| inline

Set each element to the min of the current values and the values of another btVector3.

Parameters

  other | The other btVector3 to compare with

Definition at line 626 of file btVector3.h.

## ◆ setValue()

void btVector3::setValue | ( | const btScalar & | _x,
|  | const btScalar & | _y,
|  | const btScalar & | _z
| ) |  |
| inline

Definition at line 640 of file btVector3.h.

## ◆ setW()

void btVector3::setW | ( | btScalar | _w | ) |
| inline

Set the w value.

Definition at line 573 of file btVector3.h.

## ◆ setX()

void btVector3::setX | ( | btScalar | _x | ) |
| inline

Set the x value.

Definition at line 567 of file btVector3.h.

## ◆ setY()

void btVector3::setY | ( | btScalar | _y | ) |
| inline

Set the y value.

Definition at line 569 of file btVector3.h.

## ◆ setZ()

void btVector3::setZ | ( | btScalar | _z | ) |
| inline

Set the z value.

Definition at line 571 of file btVector3.h.

## ◆ setZero()

void btVector3::setZero | ( |  | ) |
| inline

Definition at line 671 of file btVector3.h.

## ◆ triple()

btScalar btVector3::triple | ( | const btVector3 & | v1,
|  | const btVector3 & | v2
| ) |  | const
| inline

Definition at line 419 of file btVector3.h.

## ◆ w()

const btScalar & btVector3::w | ( |  | ) | const
| inline

Return the w value.

Definition at line 581 of file btVector3.h.

## ◆ x()

const btScalar & btVector3::x | ( |  | ) | const
| inline

Return the x value.

Definition at line 575 of file btVector3.h.

## ◆ y()

const btScalar & btVector3::y | ( |  | ) | const
| inline

Return the y value.

Definition at line 577 of file btVector3.h.

## ◆ z()

const btScalar & btVector3::z | ( |  | ) | const
| inline

Return the z value.

Definition at line 579 of file btVector3.h.

## Member Data Documentation

## ◆ m_floats

btScalar btVector3::m_floats[4]

Definition at line 111 of file btVector3.h.

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

- btVector3.h