A 2D Vector with floating point coordinates, used for storing 2D translations, mouse movements, and screen-space vectors.
Definition at line 28 of file vector2.h.
|
| Vector2 () |
| Default constructor to create zero vector. More...
|
|
| Vector2 (float x, float y) |
| Constructs a vector (x,y,0), where the 0 comes from the use of homogeneous coordinates in computer graphics. More...
|
|
| Vector2 (float *v) |
| Constructs a vector given a pointer to x,y,z data. More...
|
|
| Vector2 (const Vector2 &v) |
| Copy constructor for vector. More...
|
|
virtual | ~Vector2 () |
| Vector destructor. More...
|
|
bool | operator== (const Vector2 &v) const |
| Check for "equality", taking floating point imprecision into account. More...
|
|
bool | operator!= (const Vector2 &v) const |
| Check for "inequality", taking floating point imprecision into account. More...
|
|
Vector2 & | operator= (const Vector2 &v) |
| Vector assignment operator. More...
|
|
float | operator[] (const int i) const |
| Read only access to the ith coordinate of the vector. More...
|
|
float & | operator[] (const int i) |
| Returns a reference to the ith coordinate of the vector. Use this accessor if you wish to set the coordinate rather than just request its value. Example: More...
|
|
float | x () const |
| Read only access to the x coordinate. Can also use my_vector[0]. Use the my_vector[0] = 1.0; form if you need to set the value. More...
|
|
float | y () const |
| Read only access to the y coordinate. Can also use my_vector[1]. Use the my_vector[1] = 1.0; form if you need to set the value. More...
|
|
float | w () const |
| In homogeneous coordinates, the w coordinate for all vectors is 0.0. More...
|
|
float | Dot (const Vector2 &v) const |
| Returns "this dot v". More...
|
|
float | Length () const |
| Returns the length of the vector. More...
|
|
void | Normalize () |
| Normalizes the vector by making it unit length. More...
|
|
Vector2 | ToUnit () const |
| Returns a normalized (i.e., unit length) version of the vector without modifying the original ('this') vector. More...
|
|
Vector2 | Lerp (const Vector2 &b, float alpha) const |
| Linear interpolation between this vector and another. Alpha=0.0 returns this vector, and alpha=1.0 returns the other vector, other values blend between the two. More...
|
|
const float * | value_ptr () const |
| Returns a const pointer to the raw data array. More...
|
|
|
static Vector2 | Normalize (const Vector2 &v) |
| Returns a new vector that is the unit version of v. More...
|
|
static float | Dot (const Vector2 &v1, const Vector2 &v2) |
| Returns v1 dot v2. More...
|
|
static const Vector2 & | Zero () |
| (0,0) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector2 & | One () |
| (1,1) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector2 & | UnitX () |
| (1,0) - a shortcut for a special vector that is frequently needed More...
|
|
static const Vector2 & | UnitY () |
| (0,1) - a shortcut for a special vector that is frequently needed More...
|
|
static Vector2 | Lerp (const Vector2 &a, const Vector2 &b, float alpha) |
| Linear interpolation between two vectors. Alpha=0.0 returns 'a' and alpha=1.0 returns 'b', other values blend between the two. More...
|
|