Meteor2D  dev internal
Meteor is a lightweight 2D game engine.
Loading...
Searching...
No Matches
meteor::SVector2 Struct Reference

A structure representing a 2D Vector. More...

#include <vector2d.h>

Public Member Functions

void operator+= (SVector2 const &other)
 
void operator-= (SVector2 const &other)
 
SVector2 operator+ (SVector2 const &other)
 
SVector2 operator- (SVector2 const &other)
 
SVector2 operator* (int const &scalar)
 
SVector2 operator/ (int const &scalar)
 
SVector2 operator* (float const &scalar)
 
SVector2 operator/ (float const &scalar)
 
std::string toString ()
 

Static Public Member Functions

static SVector2 make (float x, float y)
 returns a vector2 using x and y. (similar to Vector(x,y) constructor)
 
static SVector2 one ()
 
static SVector2 zero ()
 
static SVector2 scale (SVector2 v1, SVector2 v2)
 Multiplies each component of v1 with their respective parts in v2.
 
static float dist (SVector2 v1, SVector2 v2)
 Computes the euclidian distance.
 
static bool parse (std::string str, SVector2 &out)
 Parses a string to a vector, serialized vector to be in the form '(x,y)'.
 

Public Attributes

float x = 0
 
float y = 0
 

Detailed Description

A structure representing a 2D Vector.

Member Function Documentation

◆ dist()

static float meteor::SVector2::dist ( SVector2 v1,
SVector2 v2 )
inlinestatic

Computes the euclidian distance.

Parameters
v1vector 1
v2vector 2
Returns
euclidian distance between the two vectors

◆ make()

static SVector2 meteor::SVector2::make ( float x,
float y )
inlinestatic

returns a vector2 using x and y. (similar to Vector(x,y) constructor)

Parameters
xvalue in x-axis
yvalue in y-axis
Returns
vector2 containing (x,y)

◆ one()

static SVector2 meteor::SVector2::one ( )
inlinestatic
Returns
(1,1)

◆ parse()

static bool meteor::SVector2::parse ( std::string str,
SVector2 & out )
inlinestatic

Parses a string to a vector, serialized vector to be in the form '(x,y)'.

Parameters
strserialised string containg vector2 data
outVector2 struct reference to update values.
Returns
true is de-serialization was successful.

◆ scale()

static SVector2 meteor::SVector2::scale ( SVector2 v1,
SVector2 v2 )
inlinestatic

Multiplies each component of v1 with their respective parts in v2.

Parameters
v1vector 1
v2vector 2
Returns
scaled vector

◆ zero()

static SVector2 meteor::SVector2::zero ( )
inlinestatic
Returns
(0,0)