Clutter Engine 0.0.1
Loading...
Searching...
No Matches
Vector4 Struct Reference

4D vector structure for mathematical operations. More...

#include <Vector4.h>

Public Member Functions

 Vector4 ()
 Default constructor. Initializes all components to 0.0f.
 
 Vector4 (float inX, float inY, float inZ, float inW)
 Constructor with component values.
 
float LengthSqr () const
 Returns the squared length of the vector.
 
float Length () const
 Returns the length (magnitude) of the vector.
 
void Normalize ()
 Normalizes the vector in place.
 
const float * GetAsFloatPtr () const
 Returns a pointer to the first component as a float array.
 
void Set (float inX, float inY, float inZ, float inW)
 Sets all four components of the vector.
 
float & operator[] (int i)
 Accesses a component by index.
 
Vector4operator*= (float scalar)
 Multiplies the vector by a scalar in place.
 
Vector4operator+= (const Vector4 &right)
 Adds another vector to this vector in place.
 
Vector4operator-= (const Vector4 &right)
 Subtracts another vector from this vector in place.
 

Static Public Member Functions

static Vector4 Normalize (const Vector4 &vec)
 Returns a normalized copy of the provided vector.
 
static float Dot (const Vector4 &a, const Vector4 &b)
 Computes the dot product of two vectors.
 
static Vector4 Cross (const Vector4 &a, const Vector4 &b)
 Computes the cross product of two vectors.
 
static Vector4 Lerp (const Vector4 &a, const Vector4 &b, float f)
 Linearly interpolates between two vectors.
 
static Vector4 Reflect (const Vector4 &v, const Vector4 &n)
 Reflects a vector about a normal.
 

Public Attributes

float x
 X component.
 
float y
 Y component.
 
float z
 Z component.
 
float w
 W component.
 

Friends

Vector4 operator+ (const Vector4 &a, const Vector4 &b)
 Vector addition.
 
Vector4 operator- (const Vector4 &a, const Vector4 &b)
 Vector subtraction.
 
Vector4 operator* (const Vector4 &left, const Vector4 &right)
 Component-wise multiplication.
 
Vector4 operator* (const Vector4 &vec, float scalar)
 Scalar multiplication.
 
Vector4 operator* (float scalar, const Vector4 &vec)
 Scalar multiplication.
 

Detailed Description

4D vector structure for mathematical operations.

Constructor & Destructor Documentation

◆ Vector4()

Vector4::Vector4 ( float inX,
float inY,
float inZ,
float inW )
inline

Constructor with component values.

Parameters
inXX component
inYY component
inZZ component
inWW component

Member Function Documentation

◆ Cross()

static Vector4 Vector4::Cross ( const Vector4 & a,
const Vector4 & b )
inlinestatic

Computes the cross product of two vectors.

Parameters
aFirst vector
bSecond vector
Returns
Cross product vector
Note
The w component is not set by this operation.

◆ Dot()

static float Vector4::Dot ( const Vector4 & a,
const Vector4 & b )
inlinestatic

Computes the dot product of two vectors.

Parameters
aFirst vector
bSecond vector
Returns
Dot product (a.x * b.x + a.y * b.y + a.z * b.z)

◆ GetAsFloatPtr()

const float * Vector4::GetAsFloatPtr ( ) const
inline

Returns a pointer to the first component as a float array.

Returns
Pointer to the float array of components

◆ Length()

float Vector4::Length ( ) const

Returns the length (magnitude) of the vector.

Returns
Length of the vector

◆ LengthSqr()

float Vector4::LengthSqr ( ) const

Returns the squared length of the vector.

Returns
Squared length (x^2 + y^2 + z^2 + w^2)

◆ Lerp()

static Vector4 Vector4::Lerp ( const Vector4 & a,
const Vector4 & b,
float f )
inlinestatic

Linearly interpolates between two vectors.

Parameters
aStart vector
bEnd vector
fInterpolation factor [0, 1]
Returns
Interpolated vector

◆ Normalize()

static Vector4 Vector4::Normalize ( const Vector4 & vec)
inlinestatic

Returns a normalized copy of the provided vector.

Parameters
vecVector to normalize
Returns
Normalized vector

◆ operator*=()

Vector4 & Vector4::operator*= ( float scalar)
inline

Multiplies the vector by a scalar in place.

Parameters
scalarScalar value
Returns
Reference to this vector

◆ operator+=()

Vector4 & Vector4::operator+= ( const Vector4 & right)
inline

Adds another vector to this vector in place.

Parameters
rightVector to add
Returns
Reference to this vector

◆ operator-=()

Vector4 & Vector4::operator-= ( const Vector4 & right)
inline

Subtracts another vector from this vector in place.

Parameters
rightVector to subtract
Returns
Reference to this vector

◆ operator[]()

float & Vector4::operator[] ( int i)
inline

Accesses a component by index.

Parameters
iIndex (0=x, 1=y, 2=z, 3=w)
Returns
Reference to the component

◆ Reflect()

static Vector4 Vector4::Reflect ( const Vector4 & v,
const Vector4 & n )
inlinestatic

Reflects a vector about a normal.

Parameters
vVector to reflect
nNormal vector (should be normalized)
Returns
Reflected vector

◆ Set()

void Vector4::Set ( float inX,
float inY,
float inZ,
float inW )
inline

Sets all four components of the vector.

Parameters
inXX component
inYY component
inZZ component
inWW component

Friends And Related Symbol Documentation

◆ operator* [1/3]

Vector4 operator* ( const Vector4 & left,
const Vector4 & right )
friend

Component-wise multiplication.

Parameters
leftLeft vector
rightRight vector
Returns
Result of left * right

◆ operator* [2/3]

Vector4 operator* ( const Vector4 & vec,
float scalar )
friend

Scalar multiplication.

Parameters
vecVector
scalarScalar value
Returns
Result of vec * scalar

◆ operator* [3/3]

Vector4 operator* ( float scalar,
const Vector4 & vec )
friend

Scalar multiplication.

Parameters
scalarScalar value
vecVector
Returns
Result of scalar * vec

◆ operator+

Vector4 operator+ ( const Vector4 & a,
const Vector4 & b )
friend

Vector addition.

Parameters
aFirst vector
bSecond vector
Returns
Result of a + b

◆ operator-

Vector4 operator- ( const Vector4 & a,
const Vector4 & b )
friend

Vector subtraction.

Parameters
aFirst vector
bSecond vector
Returns
Result of a - b

The documentation for this struct was generated from the following files: