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

#include <Vector.hpp>

Public Member Functions

 Vector2D ()
 Vector2D (float x, float y)
void Add (float x, float y)
void AddX (float val)
void AddY (float val)
float Cross (const Vector2D &other) const
float Dot (const Vector2D &other) const
float GetX () const
float GetY () const
float Magnitude () const
void Normalize ()
Vector2D Normalized () const
bool operator!= (const Vector2D &other) const
Vector2D operator* (float scalar) const
Vector2D operator+ (const Vector2D &other) const
Vector2Doperator+= (const Vector2D &other)
Vector2D operator- (const Vector2D &other) const
Vector2Doperator-= (const Vector2D &other)
Vector2D operator/ (float scalar) const
bool operator== (const Vector2D &other) const
void Set (float x, float y)
void SetX (float val)
void SetY (float val)
float * ToArray ()
std::string ToString () const
std::string ToString (uint8_t precision) const

Friends

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

Detailed Description

Two-component float vector, used for UVs, screen positions, and min/max ranges such as a camera controller's pitch limits.

Wraps Vector<float, 2> with named accessors and the usual operators. Components are read with GetX()/GetY(), written with SetX()/SetY() or Set(), and accumulated with AddX()/AddY().

Sleak::Math::Vector2D tiling(2.0f, 2.0f);
material->SetTiling(tiling);
// Pitch clamp expressed as a min/max pair
controller->SetPitchRange(Sleak::Math::Vector2D(-89.0f, 89.0f));
See also
Vector3D, Vector4D, Vector

Definition at line 209 of file Vector.hpp.

Constructor & Destructor Documentation

◆ Vector2D() [1/2]

Sleak::Math::Vector2D::Vector2D ( )
inline

Definition at line 212 of file Vector.hpp.

◆ Vector2D() [2/2]

Sleak::Math::Vector2D::Vector2D ( float x,
float y )
inline

Definition at line 213 of file Vector.hpp.

Member Function Documentation

◆ Add()

void Sleak::Math::Vector2D::Add ( float x,
float y )
inline

Definition at line 226 of file Vector.hpp.

◆ AddX()

void Sleak::Math::Vector2D::AddX ( float val)
inline

Definition at line 224 of file Vector.hpp.

◆ AddY()

void Sleak::Math::Vector2D::AddY ( float val)
inline

Definition at line 225 of file Vector.hpp.

◆ Cross()

float Sleak::Math::Vector2D::Cross ( const Vector2D & other) const
inline

Definition at line 264 of file Vector.hpp.

◆ Dot()

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

Definition at line 260 of file Vector.hpp.

◆ GetX()

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

Definition at line 216 of file Vector.hpp.

◆ GetY()

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

Definition at line 217 of file Vector.hpp.

◆ Magnitude()

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

Definition at line 269 of file Vector.hpp.

◆ Normalize()

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

Definition at line 273 of file Vector.hpp.

◆ Normalized()

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

Definition at line 280 of file Vector.hpp.

◆ operator!=()

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

Definition at line 292 of file Vector.hpp.

◆ operator*()

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

Definition at line 250 of file Vector.hpp.

◆ operator+()

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

Definition at line 229 of file Vector.hpp.

◆ operator+=()

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

Definition at line 237 of file Vector.hpp.

◆ operator-()

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

Definition at line 233 of file Vector.hpp.

◆ operator-=()

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

Definition at line 243 of file Vector.hpp.

◆ operator/()

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

Definition at line 254 of file Vector.hpp.

◆ operator==()

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

Definition at line 287 of file Vector.hpp.

◆ Set()

void Sleak::Math::Vector2D::Set ( float x,
float y )
inline

Definition at line 222 of file Vector.hpp.

◆ SetX()

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

Definition at line 220 of file Vector.hpp.

◆ SetY()

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

Definition at line 221 of file Vector.hpp.

◆ ToArray()

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

Definition at line 312 of file Vector.hpp.

◆ ToString() [1/2]

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

Definition at line 301 of file Vector.hpp.

◆ ToString() [2/2]

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

Definition at line 305 of file Vector.hpp.

◆ operator<<

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

Definition at line 296 of file Vector.hpp.