A class representing a point in 2D space.
More...
#include <OficinaTypes.hpp>
|
static vec2 | Zero () |
| Returns a vec2 with both coordinates having the value 0.0f. More...
|
|
static vec2 | One () |
| Returns a vec2 with both coordinates having the value 1.0f. More...
|
|
static vec2 | Up () |
| Returns a vec2 with coordinates indicating the Up direction. More...
|
|
static vec2 | Down () |
| Returns a vec2 with coordinates indicating the Down direction. More...
|
|
static vec2 | Left () |
| Returns a vec2 with coordinates indicating the Left direction. More...
|
|
static vec2 | Right () |
| Returns a vec2 with coordinates indicating the Right direction. More...
|
|
static float | distance (vec2 first, vec2 second) |
| Calculates the distance between two vectors. More...
|
|
static float | squareDistance (vec2 first, vec2 second) |
| Calculates the square distance between two vectors. Useful if you don't want the Square Root operation to be executed on the value for performance reasons. More...
|
|
|
union { |
struct { |
float x |
| X coordinate of point. More...
|
|
float y |
| Y coordinate of point. More...
|
|
} | |
|
struct { |
float v [2] |
| Array of coordinates of the point. More...
|
|
} | |
|
}; | |
|
A class representing a point in 2D space.
◆ vec2() [1/3]
Constructs class with null values.
◆ vec2() [2/3]
Constructs class with two equal values.
- Parameters
-
n | Value to be given to coordinates. |
◆ vec2() [3/3]
vec2::vec2 |
( |
float |
X, |
|
|
float |
Y |
|
) |
| |
Constructs class with two values.
- Parameters
-
X | Value to be given to x coordinate. |
Y | Value to be given to y coordinate. |
◆ clamp()
void vec2::clamp |
( |
vec2 |
origin, |
|
|
vec2 |
end |
|
) |
| |
Encloses this vector inside a box, with its edges described by two other vectors.
- Parameters
-
origin | Minimum values for the vector. |
end | Maximum values for the vector. |
- Warning
- In case a single coordinate of origin is bigger than end's, the vector will not be clamped on that coordinate.
◆ distance()
static float vec2::distance |
( |
vec2 |
first, |
|
|
vec2 |
second |
|
) |
| |
|
static |
Calculates the distance between two vectors.
- Parameters
-
first | First vector. |
second | Second vector. |
- Returns
- Distance value between the two desired points.
◆ Down()
static vec2 vec2::Down |
( |
| ) |
|
|
static |
Returns a vec2 with coordinates indicating the Down direction.
- Returns
- A down-facing vec2.
◆ getNormalized()
vec2 vec2::getNormalized |
( |
| ) |
|
Gets a normalized version of this vector.
- Returns
- A normalized vector.
◆ getTruncated()
vec2 vec2::getTruncated |
( |
| ) |
|
Returns a copy of this vec2 truncated to the nearest integer.
- Returns
- The truncated vec2 of this.
◆ Left()
static vec2 vec2::Left |
( |
| ) |
|
|
static |
Returns a vec2 with coordinates indicating the Left direction.
- Returns
- A left-facing vec2.
◆ length()
Gets the magnitude (length) of this vector.
- Returns
- The magnitude of this vector.
◆ normalize()
◆ One()
static vec2 vec2::One |
( |
| ) |
|
|
static |
Returns a vec2 with both coordinates having the value 1.0f.
- Returns
- An unitary-value vec2.
◆ operator!=() [1/2]
bool vec2::operator!= |
( |
const vec2 |
| ) |
|
◆ operator!=() [2/2]
bool vec2::operator!= |
( |
const float |
| ) |
|
◆ operator*() [1/2]
const vec2 vec2::operator* |
( |
const vec2 |
| ) |
|
◆ operator*() [2/2]
const vec2 vec2::operator* |
( |
const float |
| ) |
|
◆ operator*=() [1/2]
◆ operator*=() [2/2]
vec2& vec2::operator*= |
( |
const float |
| ) |
|
◆ operator+() [1/2]
const vec2 vec2::operator+ |
( |
const vec2 |
| ) |
|
◆ operator+() [2/2]
const vec2 vec2::operator+ |
( |
const float |
| ) |
|
◆ operator+=() [1/2]
◆ operator+=() [2/2]
vec2& vec2::operator+= |
( |
const float |
| ) |
|
◆ operator-() [1/2]
const vec2 vec2::operator- |
( |
const vec2 |
| ) |
|
◆ operator-() [2/2]
const vec2 vec2::operator- |
( |
const float |
| ) |
|
◆ operator-=() [1/2]
◆ operator-=() [2/2]
vec2& vec2::operator-= |
( |
const float |
| ) |
|
◆ operator/() [1/2]
const vec2 vec2::operator/ |
( |
const vec2 |
| ) |
|
◆ operator/() [2/2]
const vec2 vec2::operator/ |
( |
const float |
| ) |
|
◆ operator/=() [1/2]
◆ operator/=() [2/2]
vec2& vec2::operator/= |
( |
const float |
| ) |
|
◆ operator<() [1/2]
bool vec2::operator< |
( |
const vec2 |
| ) |
|
◆ operator<() [2/2]
bool vec2::operator< |
( |
const float |
| ) |
|
◆ operator<=() [1/2]
bool vec2::operator<= |
( |
const vec2 |
| ) |
|
◆ operator<=() [2/2]
bool vec2::operator<= |
( |
const float |
| ) |
|
◆ operator=() [1/2]
◆ operator=() [2/2]
vec2& vec2::operator= |
( |
const float |
| ) |
|
◆ operator==() [1/2]
bool vec2::operator== |
( |
const vec2 |
| ) |
|
◆ operator==() [2/2]
bool vec2::operator== |
( |
const float |
| ) |
|
◆ operator>() [1/2]
bool vec2::operator> |
( |
const vec2 |
| ) |
|
◆ operator>() [2/2]
bool vec2::operator> |
( |
const float |
| ) |
|
◆ operator>=() [1/2]
bool vec2::operator>= |
( |
const vec2 |
| ) |
|
◆ operator>=() [2/2]
bool vec2::operator>= |
( |
const float |
| ) |
|
◆ Right()
static vec2 vec2::Right |
( |
| ) |
|
|
static |
Returns a vec2 with coordinates indicating the Right direction.
- Returns
- A right-facing vec2.
◆ squareDistance()
static float vec2::squareDistance |
( |
vec2 |
first, |
|
|
vec2 |
second |
|
) |
| |
|
static |
Calculates the square distance between two vectors. Useful if you don't want the Square Root operation to be executed on the value for performance reasons.
- Parameters
-
first | First vector. |
second | Second vector. |
- Returns
- Square distance value between the two desired points.
◆ toString()
std::string vec2::toString |
( |
| ) |
|
Getsa string with the vec2 values.
- Returns
- Values inside vec2, in format {x, y}.
◆ truncate()
Truncates the coordinates of this.
◆ Up()
Returns a vec2 with coordinates indicating the Up direction.
- Returns
- An up-facing vec2.
◆ Zero()
static vec2 vec2::Zero |
( |
| ) |
|
|
static |
Returns a vec2 with both coordinates having the value 0.0f.
- Returns
- A null-values vec2.
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
oss, |
|
|
const vec2 & |
v |
|
) |
| |
|
friend |
◆ @1
Array of coordinates of the point.
The documentation for this class was generated from the following file: