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

#include <Vector3.hpp>

Public Member Functions

constexpr Vector3 (float x=0, float y=0, float z=0)
 Creates a vector with the specified values. If no values are provided, it creates a zero vector.
constexpr Vector3 (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.
Vector3 & Normalize ()
 Normalizes this vector in-place.
Vector3 & operator+= (const Vector3 &v)
 Adds another vector to this vector in-place.
Vector3 operator+ (const Vector3 &v) const
 Adds another vector to this vector and returns the result.
Vector3 & operator-= (const Vector3 &v)
 Subtracts another vector from this vector in-place.
Vector3 operator- (const Vector3 &v) const
 Subtracts another vector from this vector and returns the result.
Vector3 & operator- ()
 Negates this vector in-place.
Vector3 operator- () const
 Returns the negated form of this vector.
Vector3 & operator*= (float s)
 Multiplies this vector by a scalar in-place.
Vector3 operator* (float s) const
 Multiplies this vector by a scalar and returns the result.
Vector3 & operator/= (float s)
 Divides this vector by a scalar in-place.
Vector3 operator/ (float s) const
 Divides this vector by a scalar and returns the result.
Vector3 & Cross (const Vector3 &v)
 Computes the cross product of this vector with another vector in-place.
float Dot (const Vector3 &v) const
 Computes the dot product of this vector with another vector.
Vector3 & Transform (const Quaternion &q)
 Transforms this vector in-place by the specified quaternion rotation.
Vector3 & Transform (const Matrix4x4 &m)
 Transforms this vector in-place by the specified matrix.
Vector3 & Hadamard (const Vector3 &v)
Vector2 XX () const noexcept
 Returns a vector with the components swizzled to (X, X).
Vector2 XY () const noexcept
 Returns a vector with the components swizzled to (X, Y).
Vector2 XZ () const noexcept
 Returns a vector with the components swizzled to (X, Z).
Vector2 YX () const noexcept
 Returns a vector with the components swizzled to (Y, X).
Vector2 YY () const noexcept
 Returns a vector with the components swizzled to (Y, Y).
Vector2 YZ () const noexcept
 Returns a vector with the components swizzled to (Y, Z).
Vector2 ZX () const noexcept
 Returns a vector with the components swizzled to (Z, X).
Vector2 ZY () const noexcept
 Returns a vector with the components swizzled to (Z, Y).
Vector2 ZZ () const noexcept
 Returns a vector with the components swizzled to (Z, Z).
auto operator<=> (const Vector3 &v) const =default
 Compares this vector with another vector for equality.

Static Public Member Functions

static Vector3 Zero ()
 Returns a zero vector (0, 0, 0).
static Vector3 UnitX ()
 Returns the unit vector along the X-axis (1, 0, 0).
static Vector3 UnitY ()
 Returns the unit vector along the Y-axis (0, 1, 0).
static Vector3 UnitZ ()
 Returns the unit vector along the Z-axis (0, 0, 1).
static Vector3 One ()
 Returns a vector with all components set to 1 (1, 1, 1).
static Vector3 Up ()
 Returns the up direction unit vector.
static Vector3 Down ()
 Returns the down direction unit vector.
static Vector3 Forward ()
 Returns the forward direction unit vector.
static Vector3 Backward ()
 Returns the backward direction unit vector.
static Vector3 Left ()
 Returns the left direction unit vector.
static Vector3 Right ()
 Returns the right direction unit vector.
static Vector3 Normalize (const Vector3 &v)
 Returns the normalized form of the specified vector.
static Vector3 Cross (const Vector3 &v1, const Vector3 &v2)
 Computes the cross product of two vectors.
static float Dot (const Vector3 &a, const Vector3 &b)
 Computes the dot product of two vectors.
static Vector3 Transform (const Vector3 &v, const Quaternion &q)
 Transforms the specified vector by the given quaternion rotation.
static Vector3 Transform (const Vector3 &v, const Matrix4x4 &m)
 Transforms the specified vector by the given matrix.
static Vector3 Hadamard (const Vector3 &a, const Vector3 &b)

Public Attributes

float X
 X component of the vector.
float Y
 Y component of the vector.
float Z
 Z component of the vector.

Constructor & Destructor Documentation

◆ Vector3() [1/2]

Engine3DRadSpace.Math::Vector3::Vector3 ( float x = 0,
float y = 0,
float z = 0 )
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.

◆ Vector3() [2/2]

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

Creates a vector from an initializer list of floats.

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

Member Function Documentation

◆ Backward()

Vector3 Vector3::Backward ( )
static

Returns the backward direction unit vector.

Returns
The backward direction vector.

◆ Cross() [1/2]

Vector3 & Vector3::Cross ( const Vector3 & v)

Computes the cross product of this vector with another vector in-place.

Parameters
vThe other vector.
Returns
A reference to this vector after the cross product.

◆ Cross() [2/2]

Vector3 Vector3::Cross ( const Vector3 & v1,
const Vector3 & v2 )
static

Computes the cross product of two vectors.

Parameters
v1The first vector.
v2The second vector.
Returns
The resulting cross product vector.

◆ Dot() [1/2]

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

Computes the dot product of two vectors.

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

◆ Dot() [2/2]

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

Computes the dot product of this vector with another vector.

Parameters
vThe other vector.
Returns
The dot product.

◆ Down()

Vector3 Vector3::Down ( )
static

Returns the down direction unit vector.

Returns
The down direction vector.

◆ Forward()

Vector3 Vector3::Forward ( )
static

Returns the forward direction unit vector.

Returns
The forward direction vector.

◆ Hadamard() [1/2]

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

◆ Hadamard() [2/2]

Vector3 & Vector3::Hadamard ( const Vector3 & v)

◆ Left()

Vector3 Vector3::Left ( )
static

Returns the left direction unit vector.

Returns
The left direction vector.

◆ Length()

float Vector3::Length ( ) const

Returns the length (magnitude) of this vector.

Returns
The length of the vector.

◆ LengthSquared()

float Vector3::LengthSquared ( ) const

Returns the squared length of this vector.

Returns
The squared length of the vector.

◆ Normalize() [1/2]

Vector3 & Vector3::Normalize ( )

Normalizes this vector in-place.

Returns
A reference to this vector after normalization.

◆ Normalize() [2/2]

Vector3 Vector3::Normalize ( const Vector3 & v)
static

Returns the normalized form of the specified vector.

Parameters
vThe vector to normalize.
Returns
The normalized vector.

◆ One()

Vector3 Vector3::One ( )
static

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

Returns
The one vector.

◆ operator*()

Vector3 Vector3::operator* ( float s) const

Multiplies this vector by a scalar and returns the result.

Parameters
sThe scalar value.
Returns
The resulting scaled vector.

◆ operator*=()

Vector3 & Vector3::operator*= ( float s)

Multiplies this vector by a scalar in-place.

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

◆ operator+()

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

Adds another vector to this vector and returns the result.

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

◆ operator+=()

Vector3 & Vector3::operator+= ( const Vector3 & 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]

Vector3 & Vector3::operator- ( )

Negates this vector in-place.

Returns
A reference to this vector after negation.

◆ operator-() [2/3]

Vector3 Vector3::operator- ( ) const

Returns the negated form of this vector.

Returns
The negated vector.

◆ operator-() [3/3]

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

Subtracts another vector from this vector and returns the result.

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

◆ operator-=()

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

Subtracts another vector from this vector in-place.

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

◆ operator/()

Vector3 Vector3::operator/ ( float s) const

Divides this vector by a scalar and returns the result.

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

◆ operator/=()

Vector3 & Vector3::operator/= ( float s)

Divides this vector by a scalar in-place.

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

◆ operator<=>()

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

Compares this vector with another vector for equality.

Parameters
vThe vector to compare with.
Returns
default ordering

◆ Right()

Vector3 Vector3::Right ( )
static

Returns the right direction unit vector.

Returns
The right direction vector.

◆ Transform() [1/4]

Vector3 & Vector3::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/4]

Vector3 & Vector3::Transform ( const Quaternion & q)

Transforms this vector in-place by the specified quaternion rotation.

Parameters
qThe quaternion to transform by.
Returns
A reference to this vector after transformation.

◆ Transform() [3/4]

Vector3 Vector3::Transform ( const Vector3 & 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.

◆ Transform() [4/4]

Vector3 Vector3::Transform ( const Vector3 & v,
const Quaternion & q )
static

Transforms the specified vector by the given quaternion rotation.

Parameters
vThe vector to transform.
qThe quaternion to transform by.
Returns
The resulting transformed vector.

◆ UnitX()

Vector3 Vector3::UnitX ( )
static

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

Returns
The unit X vector.

◆ UnitY()

Vector3 Vector3::UnitY ( )
static

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

Returns
The unit Y vector.

◆ UnitZ()

Vector3 Vector3::UnitZ ( )
static

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

Returns
The unit Z vector.

◆ Up()

Vector3 Vector3::Up ( )
static

Returns the up direction unit vector.

Returns
The up direction vector.

◆ XX()

Vector2 Vector3::XX ( ) const
noexcept

Returns a vector with the components swizzled to (X, X).

Returns
The swizzled vector.

◆ XY()

Vector2 Vector3::XY ( ) const
noexcept

Returns a vector with the components swizzled to (X, Y).

Returns
The swizzled vector.

◆ XZ()

Vector2 Vector3::XZ ( ) const
noexcept

Returns a vector with the components swizzled to (X, Z).

Returns
The swizzled vector.

◆ YX()

Vector2 Vector3::YX ( ) const
noexcept

Returns a vector with the components swizzled to (Y, X).

Returns
The swizzled vector.

◆ YY()

Vector2 Vector3::YY ( ) const
noexcept

Returns a vector with the components swizzled to (Y, Y).

Returns
The swizzled vector.

◆ YZ()

Vector2 Vector3::YZ ( ) const
noexcept

Returns a vector with the components swizzled to (Y, Z).

Returns
The swizzled vector.

◆ Zero()

Vector3 Vector3::Zero ( )
static

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

Returns
The zero vector.

◆ ZX()

Vector2 Vector3::ZX ( ) const
noexcept

Returns a vector with the components swizzled to (Z, X).

Returns
The swizzled vector.

◆ ZY()

Vector2 Vector3::ZY ( ) const
noexcept

Returns a vector with the components swizzled to (Z, Y).

Returns
The swizzled vector.

◆ ZZ()

Vector2 Vector3::ZZ ( ) const
noexcept

Returns a vector with the components swizzled to (Z, Z).

Returns
The swizzled vector.

Member Data Documentation

◆ X

float Engine3DRadSpace.Math::Vector3::X

X component of the vector.

◆ Y

float Engine3DRadSpace.Math::Vector3::Y

Y component of the vector.

◆ Z

float Engine3DRadSpace.Math::Vector3::Z

Z component of the vector.


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