Euphoria
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eu::v2 Struct Reference

a 2d vector More...

Public Member Functions

 v2 ()=default
 
constexpr v2 (float ax, float ay)
 
 v2 (const std::tuple< float, float > &a)
 
 v2 (const n2 &u)
 
bool normalize ()
 Changes the length to 1.
 
v2 get_rotated (const An &a) const
 Assumes the vector is a point and returns it if it was rotated around (0,0)
 
floatget_data_ptr ()
 Returns an array to the data.
 
const floatget_data_ptr () const
 Returns an array to the data.
 
v2 get_flipped_y () const
 Returns a new vector where the sign of the y component is flipped.
 
float get_length_squared () const
 Returns the squared length of the vector.
 
float get_length () const
 Returns the length of the vector.
 
std::optional< n2get_normalized () const
 Changes the length to 1.
 
void operator+= (const v2 &rhs)
 
void operator-= (const v2 &rhs)
 
v2 operator- () const
 
void operator/= (float rhs)
 
void operator*= (float rhs)
 

Static Public Member Functions

static v2 from_to (const v2 &from, const v2 &to)
 
static v2 from (const n2 &n)
 

Public Attributes

float x
 
float y
 

Detailed Description

a 2d vector

Definition at line 16 of file vec2.h.

Constructor & Destructor Documentation

◆ v2() [1/4]

eu::v2::v2 ( )
default

◆ v2() [2/4]

constexpr eu::v2::v2 ( float  ax,
float  ay 
)
inlineconstexpr

Definition at line 22 of file vec2.h.

◆ v2() [3/4]

eu::v2::v2 ( const std::tuple< float, float > &  a)
explicit

◆ v2() [4/4]

eu::v2::v2 ( const n2 u)
explicit

Member Function Documentation

◆ from()

static v2 eu::v2::from ( const n2 n)
static

◆ from_to()

static v2 eu::v2::from_to ( const v2 from,
const v2 to 
)
static

◆ get_data_ptr() [1/2]

float * eu::v2::get_data_ptr ( )

Returns an array to the data.

non const so it's useful for letting an API tweak the members.

◆ get_data_ptr() [2/2]

const float * eu::v2::get_data_ptr ( ) const

Returns an array to the data.

◆ get_flipped_y()

v2 eu::v2::get_flipped_y ( ) const

Returns a new vector where the sign of the y component is flipped.

◆ get_length()

float eu::v2::get_length ( ) const

Returns the length of the vector.

◆ get_length_squared()

float eu::v2::get_length_squared ( ) const

Returns the squared length of the vector.

This is useful if you want to compare to zero, sort by length or similar, otherwise see get_length()

◆ get_normalized()

std::optional< n2 > eu::v2::get_normalized ( ) const

Changes the length to 1.

If the calculated length is zero, the vector is changed to a known value and false is returned

◆ get_rotated()

v2 eu::v2::get_rotated ( const An a) const

Assumes the vector is a point and returns it if it was rotated around (0,0)

◆ normalize()

bool eu::v2::normalize ( )

Changes the length to 1.

If the calculated length is zero, the vector is changed to a known value and false is returned

◆ operator*=()

void eu::v2::operator*= ( float  rhs)

◆ operator+=()

void eu::v2::operator+= ( const v2 rhs)

◆ operator-()

v2 eu::v2::operator- ( ) const

◆ operator-=()

void eu::v2::operator-= ( const v2 rhs)

◆ operator/=()

void eu::v2::operator/= ( float  rhs)

Member Data Documentation

◆ x

float eu::v2::x

Definition at line 18 of file vec2.h.

◆ y

float eu::v2::y

Definition at line 19 of file vec2.h.


The documentation for this struct was generated from the following file: