|
Euphoria
|
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) | |
| float * | get_data_ptr () |
| Returns an array to the data. | |
| const float * | get_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< n2 > | get_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 |
|
default |
| 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.
| v2 eu::v2::get_flipped_y | ( | ) | const |
Returns a new vector where the sign of the y component is flipped.
| float eu::v2::get_length | ( | ) | const |
Returns the length of the vector.
| 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()
| 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
Assumes the vector is a point and returns it if it was rotated around (0,0)
| 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
| v2 eu::v2::operator- | ( | ) | const |