StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
StevEngine::Utilities::Vector2 Class Reference

2D vector class More...

#include <utilities/Vector2.hpp>

Public Member Functions

 Vector2 (double x, double y)
 Create vector from components.
 
 Vector2 (const Vector2 &from)
 Copy constructor.
 
 Vector2 (std::string str)
 Create vector from string.
 
 Vector2 ()
 Create zero vector.
 
Vector2 Get () const
 Get copy of this vector.
 
double Magnitude () const
 Get vector length.
 
Vector2Normalize ()
 Normalize this vector.
 
Vector2 Normalized () const
 Get normalized copy.
 
Vector2 operator+ (const Vector2 &other) const
 Addition.
 
Vector2 operator- (const Vector2 &other) const
 Subtraction.
 
Vector2operator+= (const Vector2 &other)
 Add-assign.
 
Vector2operator-= (const Vector2 &other)
 Subtract-assign.
 
Vector2 operator* (const double &other) const
 Scalar multiplication.
 
Vector2 operator/ (const double &other) const
 Scalar division.
 
bool operator== (const Vector2 &other) const
 Equality comparison.
 
 operator Vector3 () const
 Convert to Vector3.
 
 operator std::string () const
 Convert to string.
 
const float * data () const
 Get raw float array.
 

Static Public Member Functions

static double Distance (const Vector2 &a, const Vector2 &b)
 Calculate distance between vectors.
 
static double Dot (const Vector2 &a, const Vector2 &b)
 Calculate dot product.
 

Public Attributes

double X
 
double Y
 Vector components.
 

Static Public Attributes

static Vector2 up = Vector2(0,1)
 Up vector (0,1)
 
static Vector2 right = Vector2(1,0)
 Right vector (1,0)
 

Detailed Description

2D vector class

Represents a point or direction in 2D space. Provides common vector operations and utilities.

Constructor & Destructor Documentation

◆ Vector2() [1/3]

StevEngine::Utilities::Vector2::Vector2 ( double x,
double y )

Create vector from components.

Parameters
xX component
yY component

◆ Vector2() [2/3]

StevEngine::Utilities::Vector2::Vector2 ( const Vector2 & from)

Copy constructor.

Parameters
fromVector to copy

◆ Vector2() [3/3]

StevEngine::Utilities::Vector2::Vector2 ( std::string str)

Create vector from string.

Parameters
strString representation

Member Function Documentation

◆ Distance()

double StevEngine::Utilities::Vector2::Distance ( const Vector2 & a,
const Vector2 & b )
static

Calculate distance between vectors.

Parameters
aFirst vector
bSecond vector
Returns
Distance between points

◆ Dot()

double StevEngine::Utilities::Vector2::Dot ( const Vector2 & a,
const Vector2 & b )
static

Calculate dot product.

Parameters
aFirst vector
bSecond vector
Returns
Dot product

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