Vector Math
[Math]
Functions for working with three-dimensional vectors (VectorF/Point3F).
More...
Functions |
| VectorF | VectorAdd (VectorF a, VectorF b) |
| | Add two vectors.
|
| VectorF | VectorCross (VectorF a, VectorF b) |
| | Calculcate the cross product of two vectors.
|
| float | VectorDist (VectorF a, VectorF b) |
| | Compute the distance between two vectors.
|
| float | VectorDot (VectorF a, VectorF b) |
| | Compute the dot product of two vectors.
|
| float | VectorLen (VectorF v) |
| | Calculate the magnitude of the given vector.
|
| VectorF | VectorLerp (VectorF a, VectorF b, float t) |
| | Linearly interpolate between two vectors by t.
|
| VectorF | VectorNormalize (VectorF v) |
| | Brings a vector into its unit form, i.e. such that it has the magnitute 1.
|
| MatrixF | VectorOrthoBasis (AngAxisF aa) |
| | Create an orthogonal basis from the given vector.
|
| VectorF | VectorScale (VectorF a, float scalar) |
| | Scales a vector by a scalar.
|
| VectorF | VectorSub (VectorF a, VectorF b) |
| | Subtract two vectors.
|
Detailed Description
Functions for working with three-dimensional vectors (VectorF/Point3F).
Function Documentation
| VectorF VectorAdd |
( |
VectorF |
a, |
|
|
VectorF |
b | |
|
) |
| | |
Add two vectors.
- Parameters:
-
| a | The first vector. |
| b | The second vector. |
- Returns:
- The vector a + b.
- Example:
%a = "1 0 0";
%b = "0 1 0";
%r = VectorAdd( %a, %b );
| VectorF VectorCross |
( |
VectorF |
a, |
|
|
VectorF |
b | |
|
) |
| | |
Calculcate the cross product of two vectors.
- Parameters:
-
| a | The first vector. |
| b | The second vector. |
- Returns:
- The cross product x b.
- Example:
%a = "1 1 0";
%b = "2 0 1";
%r = VectorCross( %a, %b );
| float VectorDist |
( |
VectorF |
a, |
|
|
VectorF |
b | |
|
) |
| | |
Compute the distance between two vectors.
- Parameters:
-
| a | The first vector. |
| b | The second vector. |
- Returns:
- The length( b - a ).
- Example:
%a = "1 1 0";
%b = "2 0 1";
%r = VectorDist( %a, %b );
| float VectorDot |
( |
VectorF |
a, |
|
|
VectorF |
b | |
|
) |
| | |
Compute the dot product of two vectors.
- Parameters:
-
| a | The first vector. |
| b | The second vector. |
- Returns:
- The dot product a * b.
- Example:
%a = "1 1 0";
%b = "2 0 1";
%r = VectorDot( %a, %b );
| float VectorLen |
( |
VectorF |
v |
) |
|
Calculate the magnitude of the given vector.
- Parameters:
-
- Returns:
- The length of vector v.
- Example:
-
| VectorF VectorLerp |
( |
VectorF |
a, |
|
|
VectorF |
b, |
|
|
float |
t | |
|
) |
| | |
Linearly interpolate between two vectors by t.
- Parameters:
-
| a | Vector to start interpolation from. |
| b | Vector to interpolate to. |
| t | Interpolation factor (0-1). At zero, a is returned and at one, b is returned. In between, an interpolated vector between a and b is returned. |
- Returns:
- An interpolated vector between a and b.
- Example:
%a = "1 1 0";
%b = "2 0 1";
%v = "0.25";
%r = VectorLerp( %a, %b );
| VectorF VectorNormalize |
( |
VectorF |
v |
) |
|
Brings a vector into its unit form, i.e. such that it has the magnitute 1.
- Parameters:
-
| v | The vector to normalize. |
- Returns:
- The vector v scaled to length 1.
- Example:
-
| MatrixF VectorOrthoBasis |
( |
AngAxisF |
aa |
) |
|
Create an orthogonal basis from the given vector.
- Parameters:
-
| aaf | The vector to create the orthogonal basis from. |
- Returns:
- A matrix representing the orthogonal basis.
| VectorF VectorScale |
( |
VectorF |
a, |
|
|
float |
scalar | |
|
) |
| | |
Scales a vector by a scalar.
- Parameters:
-
| a | The vector to scale. |
| scalar | The scale factor. |
- Returns:
- The vector a * scalar.
- Example:
-
| VectorF VectorSub |
( |
VectorF |
a, |
|
|
VectorF |
b | |
|
) |
| | |
Subtract two vectors.
- Parameters:
-
| a | The first vector. |
| b | The second vector. |
- Returns:
- The vector a - b.
- Example:
%a = "1 0 0";
%b = "0 1 0";
%r = VectorSub( %a, %b );