3DRadSpace 0.1.0Alpha
3DRadSpace is a free, simple to use, rapid application development game engine.
Loading...
Searching...
No Matches
Engine3DRadSpace.Math::Vector4 Struct Reference

#include <Vector4.hpp>

Public Member Functions

constexpr Vector4 (float x=0.0f, float y=0.0f, float z=0.0f, float w=0.0f)
 Creates a vector with the specified values. If no values are provided, it creates a zero vector.
constexpr Vector4 (Vector3 v, float w=1.0f)
 Creates a vector from a Vector3, setting W to 1.
constexpr Vector4 (std::initializer_list< float > lst)
 Creates a vector from an initializer list of floats.
float Length () const
 Returns the length (magnitude) of this vector.
float LengthSquared () const
 Returns the squared length of this vector.
Vector4 & Normalize ()
 Normalizes this vector in-place.
float Dot (const Vector4 &v) const
 Computes the dot product of this vector with another vector.
Vector4 & Hadamard (const Vector4 &v)
 Element-wise (Hadamard) multiplication of this vector with another vector.
Vector4 operator+ (const Vector4 &v) const
 Adds another vector to this vector and returns the result.
Vector4 & operator+= (const Vector4 &v)
 Adds another vector to this vector in-place.
Vector4 & operator- ()
 Negates this vector in-place.
Vector4 operator- () const
 Returns the negated form of this vector.
Vector4 operator- (const Vector4 &v) const
 Subtracts another vector from this vector and returns the result.
Vector4 & operator-= (const Vector4 &v)
 Subtracts another vector from this vector in-place.
Vector4 operator* (float scalar) const
 Multiplies this vector by a scalar and returns the result.
Vector4 & operator*= (float scalar)
 Multiplies this vector by a scalar in-place.
Vector4 operator/ (float f) const
 Divides this vector by a scalar and returns the result.
Vector4 & operator/= (float f)
 Divides this vector by a scalar in-place.
Vector4 & Transform (const Matrix4x4 &m)
 Transforms this vector in-place by the specified matrix.
auto operator<=> (const Vector4 &v) const =default
 Compares this vector with another vector for equality.

Static Public Member Functions

static Vector4 Zero ()
 Returns a zero vector (0, 0, 0, 0).
static Vector4 UnitX ()
 Returns the unit vector along the X-axis (1, 0, 0, 0).
static Vector4 UnitY ()
 Returns the unit vector along the Y-axis (0, 1, 0, 0).
static Vector4 UnitZ ()
 Returns the unit vector along the Z-axis (0, 0, 1, 0).
static Vector4 UnitW ()
 Returns the unit vector along the W-axis (0, 0, 0, 1).
static Vector4 One ()
 Returns a vector with all components set to 1 (1, 1, 1, 1).
static float Dot (const Vector4 &a, const Vector4 &b)
 Computes the dot product of two vectors.
static Vector4 Hadamard (const Vector4 &a, const Vector4 &b)
 Element-wise (Hadamard) product of two vectors.
static Vector4 Transform (const Vector4 &v, const Matrix4x4 &m)
 Transforms the specified vector by the given matrix.

Public Attributes

float X
 X, Y, Z, W components of the vector.
float Y
float Z
float W

Constructor & Destructor Documentation

◆ Vector4() [1/3]

Engine3DRadSpace.Math::Vector4::Vector4 ( float x = 0.0f,
float y = 0.0f,
float z = 0.0f,
float w = 0.0f )
inlineexplicitconstexpr

Creates a vector with the specified values. If no values are provided, it creates a zero vector.

Parameters
xThe X component.
yThe Y component.
zThe Z component.
wThe W component.

◆ Vector4() [2/3]

Engine3DRadSpace.Math::Vector4::Vector4 ( Vector3 v,
float w = 1.0f )
inlineexplicitconstexpr

Creates a vector from a Vector3, setting W to 1.

Parameters
vThe source Vector3.

◆ Vector4() [3/3]

Engine3DRadSpace.Math::Vector4::Vector4 ( std::initializer_list< float > lst)
inlineexplicitconstexpr

Creates a vector from an initializer list of floats.

Parameters
lstThe initializer list containing up to 4 values (X, Y, Z, W).

Member Function Documentation

◆ Dot() [1/2]

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

Computes the dot product of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The dot product.

◆ Dot() [2/2]

float Vector4::Dot ( const Vector4 & v) const

Computes the dot product of this vector with another vector.

Parameters
vThe other vector.
Returns
The dot product.

◆ Hadamard() [1/2]

Vector4 Vector4::Hadamard ( const Vector4 & a,
const Vector4 & b )
static

Element-wise (Hadamard) product of two vectors.

Parameters
aThe first vector.
bThe second vector.
Returns
The resulting vector after Hadamard multiplication.

◆ Hadamard() [2/2]

Vector4 & Vector4::Hadamard ( const Vector4 & v)

Element-wise (Hadamard) multiplication of this vector with another vector.

Parameters
vThe vector to multiply with.
Returns
A reference to this vector after Hadamard multiplication.

◆ Length()

float Vector4::Length ( ) const

Returns the length (magnitude) of this vector.

Returns
The length of the vector.

◆ LengthSquared()

float Vector4::LengthSquared ( ) const

Returns the squared length of this vector.

Returns
The squared length of the vector.

◆ Normalize()

Vector4 & Engine3DRadSpace.Math::Vector4::Normalize ( )

Normalizes this vector in-place.

Returns
A reference to this vector after normalization.

◆ One()

Vector4 Vector4::One ( )
static

Returns a vector with all components set to 1 (1, 1, 1, 1).

Returns
The one vector.

◆ operator*()

Vector4 Vector4::operator* ( float scalar) const

Multiplies this vector by a scalar and returns the result.

Parameters
scalarThe scalar value.
Returns
The resulting scaled vector.

◆ operator*=()

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

Multiplies this vector by a scalar in-place.

Parameters
scalarThe scalar value.
Returns
A reference to this vector after scaling.

◆ operator+()

Vector4 Vector4::operator+ ( const Vector4 & v) const

Adds another vector to this vector and returns the result.

Parameters
vThe vector to add.
Returns
The resulting vector after addition.

◆ operator+=()

Vector4 & Vector4::operator+= ( const Vector4 & v)

Adds another vector to this vector in-place.

Parameters
vThe vector to add.
Returns
A reference to this vector after addition.

◆ operator-() [1/3]

Vector4 & Engine3DRadSpace.Math::Vector4::operator- ( )

Negates this vector in-place.

Returns
A reference to this vector after negation.

◆ operator-() [2/3]

Vector4 Vector4::operator- ( ) const

Returns the negated form of this vector.

Returns
The negated vector.

◆ operator-() [3/3]

Vector4 Vector4::operator- ( const Vector4 & v) const

Subtracts another vector from this vector and returns the result.

Parameters
vThe vector to subtract.
Returns
The resulting vector after subtraction.

◆ operator-=()

Vector4 & Vector4::operator-= ( const Vector4 & v)

Subtracts another vector from this vector in-place.

Parameters
vThe vector to subtract.
Returns
A reference to this vector after subtraction.

◆ operator/()

Vector4 Vector4::operator/ ( float f) const

Divides this vector by a scalar and returns the result.

Parameters
fThe scalar value.
Returns
The resulting vector after division.

◆ operator/=()

Vector4 & Vector4::operator/= ( float f)

Divides this vector by a scalar in-place.

Parameters
fThe scalar value.
Returns
A reference to this vector after division.

◆ operator<=>()

auto Engine3DRadSpace.Math::Vector4::operator<=> ( const Vector4 & v) const
default

Compares this vector with another vector for equality.

Parameters
vThe vector to compare with.
Returns
default ordering

◆ Transform() [1/2]

Vector4 & Vector4::Transform ( const Matrix4x4 & m)

Transforms this vector in-place by the specified matrix.

Parameters
mThe matrix to transform by.
Returns
A reference to this vector after transformation.

◆ Transform() [2/2]

Vector4 Vector4::Transform ( const Vector4 & v,
const Matrix4x4 & m )
static

Transforms the specified vector by the given matrix.

Parameters
vThe vector to transform.
mThe matrix to transform by.
Returns
The resulting transformed vector.

◆ UnitW()

Vector4 Vector4::UnitW ( )
static

Returns the unit vector along the W-axis (0, 0, 0, 1).

Returns
The unit W vector.

◆ UnitX()

Vector4 Vector4::UnitX ( )
static

Returns the unit vector along the X-axis (1, 0, 0, 0).

Returns
The unit X vector.

◆ UnitY()

Vector4 Vector4::UnitY ( )
static

Returns the unit vector along the Y-axis (0, 1, 0, 0).

Returns
The unit Y vector.

◆ UnitZ()

Vector4 Vector4::UnitZ ( )
static

Returns the unit vector along the Z-axis (0, 0, 1, 0).

Returns
The unit Z vector.

◆ Zero()

Vector4 Vector4::Zero ( )
static

Returns a zero vector (0, 0, 0, 0).

Returns
The zero vector.

Member Data Documentation

◆ W

float Engine3DRadSpace.Math::Vector4::W

◆ X

float Engine3DRadSpace.Math::Vector4::X

X, Y, Z, W components of the vector.

◆ Y

float Engine3DRadSpace.Math::Vector4::Y

◆ Z

float Engine3DRadSpace.Math::Vector4::Z

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