Vector3 is a 3D vector utility class used for position, direction, and math operations in 3D space.
More...
#include <Vector3.h>
|
static Vector3 | Normalize (const Vector3 &vec) |
| Static method to normalize a vector.
|
|
static float | Dot (const Vector3 &left, const Vector3 &right) |
| Computes the dot product between two vectors.
|
|
static float | Distance (Vector3 &a, Vector3 &b) |
| Computes the distance between two vectors.
|
|
static Vector3 | Cross (const Vector3 &left, const Vector3 &right) |
| Computes the cross product with another vector.
|
|
static Vector3 | Lerp (const Vector3 &a, const Vector3 &b, float f) |
| Linearly interpolates between two vectors.
|
|
static Vector3 | Reflect (const Vector3 &v, const Vector3 &n) |
| Reflects a vector across a normal.
|
|
static Vector3 | Transform (Vector3 &vec, class Matrix4 &mat4, float w=1.0f) |
| Transforms the vector by a 4x4 matrix (ignores perspective divide).
|
|
static Vector3 | TransformWithPerspDiv (Vector3 &vec, class Matrix4 &mat4, float w=1.0f) |
| Transforms the vector by a matrix and applies perspective divide.
|
|
static Vector3 | Transform (const Vector3 &v, const class Quaternion &q) |
| Transforms the vector by a quaternion rotation.
|
|
|
float | x = 0 |
|
float | y = 0 |
|
float | z = 0 |
|
Vector3 is a 3D vector utility class used for position, direction, and math operations in 3D space.
◆ Vector3() [1/4]
Default constructor, initializes to (0,0,0).
◆ Vector3() [2/4]
Vector3::Vector3 |
( |
float | x | ) |
|
Initializes all components to the same scalar value.
- Parameters
-
x | Scalar value to assign to x, y, and z. |
◆ Vector3() [3/4]
Vector3::Vector3 |
( |
float | x, |
|
|
float | y, |
|
|
float | z ) |
Initializes vector with individual float components.
- Parameters
-
x | X component. |
y | Y component. |
z | Z component. |
◆ Vector3() [4/4]
Constructs a Vector3 from a Vector2, setting z to 0.
- Parameters
-
vec2 | 2D vector to use for x and y. |
◆ Cross() [1/2]
Computes the cross product with another vector.
- Parameters
-
- Returns
- Result of the cross product.
◆ Cross() [2/2]
Computes the cross product between two vectors.
- Parameters
-
left | First vector. |
right | Second vector. |
- Returns
- Cross product result.
◆ Distance()
Computes the distance between two vectors.
- Parameters
-
a | First point. |
b | Second point. |
- Returns
- Euclidean distance between a and b.
◆ Dot()
Computes the dot product between two vectors.
- Parameters
-
left | First vector. |
right | Second vector. |
- Returns
- Dot product result.
◆ GetAsFloatPtr()
const float * Vector3::GetAsFloatPtr |
( |
| ) |
const |
Gets a pointer to the vector's float data.
- Returns
- Pointer to x (useful for OpenGL).
◆ Lerp()
Linearly interpolates between two vectors.
- Parameters
-
a | Starting vector. |
b | Ending vector. |
f | Interpolation factor (0.0 to 1.0). |
- Returns
- Interpolated vector.
◆ Magnitude()
float Vector3::Magnitude |
( |
| ) |
const |
Computes the magnitude (length) of the vector.
- Returns
- Length of the vector.
◆ Magnitude2D()
float Vector3::Magnitude2D |
( |
| ) |
const |
Computes 2D magnitude using x and z components only.
- Returns
- Length in the XZ plane.
◆ Magnitude2DSqr()
float Vector3::Magnitude2DSqr |
( |
| ) |
const |
Computes squared 2D magnitude using x and z components.
- Returns
- Squared length in the XZ plane.
◆ MagnitudeSqr()
float Vector3::MagnitudeSqr |
( |
| ) |
const |
Computes the squared magnitude.
- Returns
- Squared length of the vector.
◆ Normalize() [1/2]
void Vector3::Normalize |
( |
| ) |
|
Normalizes the vector to unit length.
◆ Normalize() [2/2]
Static method to normalize a vector.
- Parameters
-
- Returns
- Normalized vector.
◆ Normalize2D()
void Vector3::Normalize2D |
( |
| ) |
|
Normalizes x and z components to unit length (2D).
◆ Normalized()
Returns a normalized copy of the vector.
- Returns
- Unit-length vector in same direction.
◆ Normalized2D()
Returns a copy normalized in the XZ plane.
- Returns
- 2D-normalized vector (y = 0).
◆ operator*=()
void Vector3::operator*= |
( |
const float | value | ) |
|
◆ operator+=()
void Vector3::operator+= |
( |
const Vector3 & | vector | ) |
|
◆ operator-()
Vector3 Vector3::operator- |
( |
| ) |
const |
◆ operator-=()
void Vector3::operator-= |
( |
const Vector3 & | vector | ) |
|
◆ operator/=()
void Vector3::operator/= |
( |
const float | value | ) |
|
◆ Reflect()
Reflects a vector across a normal.
- Parameters
-
v | Incoming vector. |
n | Normal vector (should be normalized). |
- Returns
- Reflected vector.
◆ ToString()
std::string Vector3::ToString |
( |
| ) |
const |
Converts the vector to a string representation.
- Returns
- String in format (x , y , z).
◆ Transform() [1/2]
Transforms the vector by a quaternion rotation.
- Parameters
-
- Returns
- Rotated vector.
◆ Transform() [2/2]
Transforms the vector by a 4x4 matrix (ignores perspective divide).
- Parameters
-
vec | Vector to transform. |
mat4 | Matrix to use. |
w | Homogeneous coordinate (default: 1.0f). |
- Returns
- Transformed vector.
◆ TransformWithPerspDiv()
Transforms the vector by a matrix and applies perspective divide.
- Parameters
-
vec | Vector to transform. |
mat4 | Matrix to use. |
w | Homogeneous coordinate (default: 1.0f). |
- Returns
- Transformed and perspective-divided vector.
◆ operator* [1/3]
◆ operator* [2/3]
◆ operator* [3/3]
◆ operator+
◆ operator-
◆ operator/
◆ operator==
◆ Backward
◆ Down
◆ Forward
◆ Infinity
◆ Left
◆ MinusInfinity
const Vector3 Vector3::MinusInfinity |
|
static |
◆ One
◆ Right
◆ Up
◆ Zero
The documentation for this class was generated from the following files: