Golias Engine
A C++ 20 'game engine' built with SDL3 with wide platform support.
Public Member Functions | Static Public Attributes | List of all members
Vector2 Class Reference

#include <vector2.h>

Inheritance diagram for Vector2:

Public Member Functions

 Vector2 ()
 
 Vector2 (float x, float y)
 
 Vector2 (float v)
 
 Vector2 (const glm::vec2 &v)
 
float & operator[] (int index)
 
const float & operator[] (int index) const
 
float length () const
 
Vector2 normalized () const
 
void normalize ()
 
float dot (const Vector2 &other) const
 
float distance_to (const Vector2 &other) const
 
Vector2 lerp (const Vector2 &other, float t) const
 
Vector2 reflect (const Vector2 &normal) const
 
Vector2 refract (const Vector2 &normal, float eta) const
 
Vector2 abs () const
 
Vector2 sign () const
 
Vector2 floor () const
 
Vector2 ceil () const
 
Vector2 round () const
 
float angle () const
 
float angle_to (const Vector2 &other) const
 
Vector2 rotated (float angle) const
 
bool is_zero_approx () const
 

Static Public Attributes

static const Vector2 ZERO = Vector2(0.0f, 0.0f)
 
static const Vector2 ONE = Vector2(1.0f, 1.0f)
 
static const Vector2 LEFT = Vector2(-1.0f, 0.0f)
 
static const Vector2 RIGHT = Vector2(1.0f, 0.0f)
 
static const Vector2 UP = Vector2(0.0f, -1.0f)
 
static const Vector2 DOWN = Vector2(0.0f, 1.0f)
 

Constructor & Destructor Documentation

◆ Vector2() [1/4]

Vector2::Vector2 ( )

◆ Vector2() [2/4]

Vector2::Vector2 ( float  x,
float  y 
)

◆ Vector2() [3/4]

Vector2::Vector2 ( float  v)

◆ Vector2() [4/4]

Vector2::Vector2 ( const glm::vec2 &  v)

Member Function Documentation

◆ abs()

Vector2 Vector2::abs ( ) const

◆ angle()

float Vector2::angle ( ) const

◆ angle_to()

float Vector2::angle_to ( const Vector2 other) const

◆ ceil()

Vector2 Vector2::ceil ( ) const

◆ distance_to()

float Vector2::distance_to ( const Vector2 other) const

◆ dot()

float Vector2::dot ( const Vector2 other) const

◆ floor()

Vector2 Vector2::floor ( ) const

◆ is_zero_approx()

bool Vector2::is_zero_approx ( ) const

◆ length()

float Vector2::length ( ) const

◆ lerp()

Vector2 Vector2::lerp ( const Vector2 other,
float  t 
) const

◆ normalize()

void Vector2::normalize ( )

◆ normalized()

Vector2 Vector2::normalized ( ) const

◆ operator[]() [1/2]

float & Vector2::operator[] ( int  index)

◆ operator[]() [2/2]

const float & Vector2::operator[] ( int  index) const

◆ reflect()

Vector2 Vector2::reflect ( const Vector2 normal) const

◆ refract()

Vector2 Vector2::refract ( const Vector2 normal,
float  eta 
) const

◆ rotated()

Vector2 Vector2::rotated ( float  angle) const

◆ round()

Vector2 Vector2::round ( ) const

◆ sign()

Vector2 Vector2::sign ( ) const

Member Data Documentation

◆ DOWN

const Vector2 Vector2::DOWN = Vector2(0.0f, 1.0f)
static

◆ LEFT

const Vector2 Vector2::LEFT = Vector2(-1.0f, 0.0f)
static

◆ ONE

const Vector2 Vector2::ONE = Vector2(1.0f, 1.0f)
static

◆ RIGHT

const Vector2 Vector2::RIGHT = Vector2(1.0f, 0.0f)
static

◆ UP

const Vector2 Vector2::UP = Vector2(0.0f, -1.0f)
static

◆ ZERO

const Vector2 Vector2::ZERO = Vector2(0.0f, 0.0f)
static

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