physics::Vector3D Class Reference
#include <vector.h>
List of all members.
|
Public Member Functions |
| Vector3D () |
| Vector3D (float px, float py) |
| Vector3D (float px, float py, float pz) |
| Vector3D (float px, float py, float pz, float pw) |
| Vector3D (float *pf) |
float | length () const |
float | lengthSquared () const |
float | distance (const Vector3D &v) const |
float | distanceSquared (const Vector3D &v) const |
Vector3D | normalise () const |
const float * | getArray () const |
void | fillArray (float *a) |
void | fromArray (const float *a) |
Vector3D | operator- () const |
Vector3D | operator+ (const Vector3D &v) const |
Vector3D | operator- (const Vector3D &v) const |
Vector3D | operator* (float scale) const |
Vector3D | operator/ (float scale) const |
Vector3D | operator* (const Vector3D &v) const |
Static Public Member Functions |
static float | distance (const Vector3D &a, const Vector3D &b) |
static float | distanceSquared (const Vector3D &a, const Vector3D &b) |
static void | fastScale (Vector3D &result, const Vector3D &a, float scale) |
static float | dotProduct (const Vector3D &a, const Vector3D &b) |
static Vector3D | crossProduct (const Vector3D &a, const Vector3D &b) |
static Vector3D | lerp (const Vector3D &a, const Vector3D &b, float t) |
static Vector3D | makeNormal (const Vector3D &a, const Vector3D &b, const Vector3D &c) |
Detailed Description
A three dimensional floating point vector. It actually contains a fourth dimension so that it can be used with the Matrix class. All common vector operators can be performed, mostly by using the overloaded operators.
Constructor & Destructor Documentation
physics::Vector3D::Vector3D |
( |
|
) |
[inline] |
physics::Vector3D::Vector3D |
( |
float |
px, |
|
|
float |
py | |
|
) |
| | [inline] |
2D constructor, z defaults to 0.0. This is used for 2D games when specifying position of sprites etc. In a 2D game the values correspond to pixels.
- Parameters:
-
| px | X-Coordinate. |
| py | Y-Coordinate. |
physics::Vector3D::Vector3D |
( |
float |
px, |
|
|
float |
py, |
|
|
float |
pz | |
|
) |
| | [inline] |
XYZ constructor. The W-Coordinate defaults to 1.0.
- Parameters:
-
| px | X-Coordinate. |
| py | Y-Coordinate. |
| pz | Z-Coordinate. |
physics::Vector3D::Vector3D |
( |
float |
px, |
|
|
float |
py, |
|
|
float |
pz, |
|
|
float |
pw | |
|
) |
| | [inline] |
XYZW constructor. You will not usually need this, use XYZ instead.
- Parameters:
-
| px | X-Coordinate. |
| py | Y-Coordinate. |
| pz | Z-Coordinate. |
| pw | W-Coordinate. |
physics::Vector3D::Vector3D |
( |
float * |
pf |
) |
[inline] |
Construct from a 3 float array.
- Parameters:
-
Member Function Documentation
float physics::Vector3D::length |
( |
|
) |
const [inline] |
Calculate the vectors length. Note that this uses square root and may be slow.
- Returns:
- Length of vector.
float physics::Vector3D::lengthSquared |
( |
|
) |
const [inline] |
Calculate the squared length of this vector. This avoids the square root so is faster.
- Returns:
- Squared length of vector
float physics::Vector3D::distance |
( |
const Vector3D & |
v |
) |
const [inline] |
Calculate the distance to a vector
- Returns:
- Distance to the other vector.
float physics::Vector3D::distanceSquared |
( |
const Vector3D & |
v |
) |
const [inline] |
Calculate the distance to a vector
- Returns:
- Distance to the other vector.
static float physics::Vector3D::distance |
( |
const Vector3D & |
a, |
|
|
const Vector3D & |
b | |
|
) |
| | [inline, static] |
Calculate the distance between two vectors.
- Returns:
- Distance between vectors.
static float physics::Vector3D::distanceSquared |
( |
const Vector3D & |
a, |
|
|
const Vector3D & |
b | |
|
) |
| | [inline, static] |
Calculate the distance squared between two vectors.
- Returns:
- Distance squared between vectors.
Vector3D physics::Vector3D::normalise |
( |
|
) |
const [inline] |
Normalise the vector. This will make it have a length of 1.
const float* physics::Vector3D::getArray |
( |
|
) |
const [inline] |
Get this vector as an array of floats. Note that this is read-only.
- Returns:
- Pointer to 3 (or 4) floats.
void physics::Vector3D::fillArray |
( |
float * |
a |
) |
[inline] |
Put this vector into a specified array. Similar to getArray. This will only fill the array with XYZ not W.
- Parameters:
-
| a | Pointer to 3 float array. |
void physics::Vector3D::fromArray |
( |
const float * |
a |
) |
[inline] |
Make this vector from a float array. Useful if you want to reuse a vector instead of making a new one.
- Parameters:
-
Vector3D physics::Vector3D::operator- |
( |
|
) |
const [inline] |
Subtract a vector from another.
Vector3D physics::Vector3D::operator* |
( |
float |
scale |
) |
const [inline] |
Vector3D physics::Vector3D::operator/ |
( |
float |
scale |
) |
const [inline] |
static void physics::Vector3D::fastScale |
( |
Vector3D & |
result, |
|
|
const Vector3D & |
a, |
|
|
float |
scale | |
|
) |
| | [inline, static] |
Scale a vector. This is faster as fewer vector temporaries are created.
- Parameters:
-
| result | Scaled result goes here. |
| a | Vector to scale. |
| b | Scale factor. |
static float physics::Vector3D::dotProduct |
( |
const Vector3D & |
a, |
|
|
const Vector3D & |
b | |
|
) |
| | [inline, static] |
Calculate the dot product of two vectors. This corresponds to the angle between them.
- Parameters:
-
| a | First vector. |
| b | Second vector. |
- Returns:
- Dot product of a.b.
Cross product of two vectors a and b.
- Parameters:
-
| a | First vector. |
| b | Second vector. |
- Returns:
- Cross product of a and b.
Linear interpolation between two vectors.
- Parameters:
-
| a | Start vector. |
| b | End vector. |
| t | Interpolation coeficient. |
- Returns:
- The interpolated vector.
Get normal from 3 vectors. Useful if you have a triangle and need to find its normal.
- Parameters:
-
| a | Vector A |
| b | Vector B |
| c | Vector C |
- Returns:
- Normal to plane described by A B and C.
Member Data Documentation
The documentation for this class was generated from the following file:
- torquetome/trunk/physics/src/lib/vector.h