math¶
-
class Vec2¶
A 2D vector.
Public Functions
-
double getLength() const¶
Get the length of the vector.
- Returns:
The length of the vector if no overflow happens, otherwise -1.0
-
bool normalize()¶
Normalize the vector in-place.
Fails if an overflow occurs or the vector is the zero vector
-
double distanceTo(const Vec2 &other) const¶
Get the distance to another vector.
- Parameters:
other – The other vector.
- Returns:
The distance to another vector if no overflow happens, otherwise -1.0
-
Vec2 operator+(const Vec2 &other) const¶
Adds two vectors.
- Parameters:
other – the other vector
- Returns:
a vector sum of the other two, or the zero vector on overflow
-
Vec2 operator-(const Vec2 &other) const¶
Subtracts two vectors.
- Parameters:
other – the subtracted vector
- Returns:
a vector difference of the other two, or the zero vector on overflow
-
Vec2 &operator+=(const Vec2 &other)¶
in-place addition of another vector to this
- Parameters:
other – the other vector
- Returns:
reference to *this
-
double getLength() const¶