A 2D vector struct used in many steering calculations. More...
#include <Vector2.hpp>
Public Member Functions | |
Vector2 () | |
Default constructor. | |
Vector2 (double a, double b) | |
void | Zero () |
Set both x and y values to zero. | |
bool | isZero () const |
Returns true if both x and y values are zero. | |
double | Length () const |
Returns the length of the vector. | |
double | LengthSq () const |
Returns the squared length of the vector (thereby avoiding sqrt). | |
void | Normalize () |
Normalizes the vector. | |
double | Dot (const Vector2 &v2) const |
Returns the dot product of the vector. | |
int | Sign (const Vector2 &v2) const |
Returns positive if v2 is clockwise of this vector, negative if anticlockwise (assuming y-axis is pointing down and x-axis is pointing right). | |
Vector2 | Perp () const |
Returns the vector that is perpendicular to this vector. | |
void | Truncate (double max) |
double | Distance (const Vector2 &v2) const |
double | DistanceSq (const Vector2 &v2) const |
void | Reflect (const Vector2 &norm) |
Vector2 | GetReverse () const |
const Vector2 & | operator+= (const Vector2 &rhs) |
const Vector2 & | operator-= (const Vector2 &rhs) |
const Vector2 & | operator*= (const double &rhs) |
const Vector2 & | operator/= (const double &rhs) |
bool | operator== (const Vector2 &rhs) const |
bool | operator!= (const Vector2 &rhs) const |
Public Attributes | |
double | x |
double | y |
A 2D vector struct used in many steering calculations.