SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::Math::Vector4D Class Reference

#include <Vector.hpp>

Public Member Functions

 Vector4D ()
 Vector4D (float x, float y, float z, float w)
float Dot (const Vector4D &other) const
float GetW () const
float GetX () const
float GetY () const
float GetZ () const
float Magnitude () const
void Normalize ()
Vector4D Normalized () const
bool operator!= (const Vector4D &other) const
Vector4D operator* (float scalar) const
Vector4D operator+ (const Vector4D &other) const
Vector4Doperator+= (const Vector4D &other)
Vector4D operator- (const Vector4D &other) const
Vector4Doperator-= (const Vector4D &other)
Vector4D operator/ (float scalar) const
bool operator== (const Vector4D &other) const
void Set (float x, float y, float z, float w)
void SetW (float val)
void SetX (float val)
void SetY (float val)
void SetZ (float val)
float * ToArray ()
std::string ToString () const
std::string ToString (uint8_t precision) const

Friends

std::ostream & operator<< (std::ostream &os, const Vector4D &vec)

Detailed Description

Four-component float vector for homogeneous coordinates, RGBA values, and shader constant payloads.

Wraps Vector<float, 4> with the same accessor pattern as Vector2D and Vector3D, adding a W component. Reach for it when a value has to survive a Matrix4 transform with its translation intact (w = 1 for points, w = 0 for directions), or when you are packing four floats for the GPU.

Vector4D point(1.0f, 2.0f, 3.0f, 1.0f); // a position
Vector4D direction(0.0f, 1.0f, 0.0f, 0.0f); // a direction
Vector4D tint(1.0f, 0.95f, 0.85f, 1.0f); // RGBA
float alpha = tint.GetW();
See also
Vector2D, Vector3D, Vector, Matrix4, Color

Definition at line 529 of file Vector.hpp.

Constructor & Destructor Documentation

◆ Vector4D() [1/2]

Sleak::Math::Vector4D::Vector4D ( )
inline

Definition at line 532 of file Vector.hpp.

◆ Vector4D() [2/2]

Sleak::Math::Vector4D::Vector4D ( float x,
float y,
float z,
float w )
inline

Definition at line 533 of file Vector.hpp.

Member Function Documentation

◆ Dot()

float Sleak::Math::Vector4D::Dot ( const Vector4D & other) const
inline

Definition at line 586 of file Vector.hpp.

◆ GetW()

float Sleak::Math::Vector4D::GetW ( ) const
inline

Definition at line 539 of file Vector.hpp.

◆ GetX()

float Sleak::Math::Vector4D::GetX ( ) const
inline

Definition at line 536 of file Vector.hpp.

◆ GetY()

float Sleak::Math::Vector4D::GetY ( ) const
inline

Definition at line 537 of file Vector.hpp.

◆ GetZ()

float Sleak::Math::Vector4D::GetZ ( ) const
inline

Definition at line 538 of file Vector.hpp.

◆ Magnitude()

float Sleak::Math::Vector4D::Magnitude ( ) const
inline

Definition at line 591 of file Vector.hpp.

◆ Normalize()

void Sleak::Math::Vector4D::Normalize ( )
inline

Definition at line 595 of file Vector.hpp.

◆ Normalized()

Vector4D Sleak::Math::Vector4D::Normalized ( ) const
inline

Definition at line 604 of file Vector.hpp.

◆ operator!=()

bool Sleak::Math::Vector4D::operator!= ( const Vector4D & other) const
inline

Definition at line 618 of file Vector.hpp.

◆ operator*()

Vector4D Sleak::Math::Vector4D::operator* ( float scalar) const
inline

Definition at line 576 of file Vector.hpp.

◆ operator+()

Vector4D Sleak::Math::Vector4D::operator+ ( const Vector4D & other) const
inline

Definition at line 551 of file Vector.hpp.

◆ operator+=()

Vector4D & Sleak::Math::Vector4D::operator+= ( const Vector4D & other)
inline

Definition at line 559 of file Vector.hpp.

◆ operator-()

Vector4D Sleak::Math::Vector4D::operator- ( const Vector4D & other) const
inline

Definition at line 555 of file Vector.hpp.

◆ operator-=()

Vector4D & Sleak::Math::Vector4D::operator-= ( const Vector4D & other)
inline

Definition at line 567 of file Vector.hpp.

◆ operator/()

Vector4D Sleak::Math::Vector4D::operator/ ( float scalar) const
inline

Definition at line 580 of file Vector.hpp.

◆ operator==()

bool Sleak::Math::Vector4D::operator== ( const Vector4D & other) const
inline

Definition at line 611 of file Vector.hpp.

◆ Set()

void Sleak::Math::Vector4D::Set ( float x,
float y,
float z,
float w )
inline

Definition at line 546 of file Vector.hpp.

◆ SetW()

void Sleak::Math::Vector4D::SetW ( float val)
inline

Definition at line 545 of file Vector.hpp.

◆ SetX()

void Sleak::Math::Vector4D::SetX ( float val)
inline

Definition at line 542 of file Vector.hpp.

◆ SetY()

void Sleak::Math::Vector4D::SetY ( float val)
inline

Definition at line 543 of file Vector.hpp.

◆ SetZ()

void Sleak::Math::Vector4D::SetZ ( float val)
inline

Definition at line 544 of file Vector.hpp.

◆ ToArray()

float * Sleak::Math::Vector4D::ToArray ( )
inline

Definition at line 638 of file Vector.hpp.

◆ ToString() [1/2]

std::string Sleak::Math::Vector4D::ToString ( ) const
inline

Definition at line 627 of file Vector.hpp.

◆ ToString() [2/2]

std::string Sleak::Math::Vector4D::ToString ( uint8_t precision) const
inline

Definition at line 631 of file Vector.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Vector4D & vec )
friend

Definition at line 622 of file Vector.hpp.