#include <Vector2.h>
Public Member Functions | |
Vector2 () | |
Default constructor. Initialises data to 0.0f. | |
Vector2 (const float vx, const float vy) | |
Constructor that builds the vector data from floats given through arguments. | |
Vector2 (const Vector2 &v) | |
Copy Constructor. | |
float | Magnitude () |
Returns the magnitude of a vector. Primarily used for normalizing vectors. | |
float | Magnitude2 () |
Returns the squared magnitude of a vector. | |
bool | IsZero () |
Is the vector equal to (0, 0) ? | |
void | Normalize () |
Normalises a given vector. In clear words, changes the vector so that its "length" is 1. | |
void | Rotate (float angle) |
rotates a vector around the X axis by a given angle, in radians | |
float | Distance (const Vector2 &v) |
returns the distance between two Vector2's used as vertices | |
float | VectorAngle (const Vector2 &v) |
returns the angle between two Vector2's used as vertices | |
std::string | ToString () |
Returns a string that represents the actual object. | |
Vector2 & | operator= (const Vector2 &v) |
Affectation operator. | |
float & | operator[] (unsigned int i) |
Indexing operator. | |
const float & | operator[] (unsigned int i) const |
Indexing operator. | |
Vector2 & | operator+= (const Vector2 &v) |
Adds a Vector2 to this one. | |
Vector2 & | operator-= (const Vector2 &v) |
Subtracts a Vector2 from this one. | |
Vector2 & | operator *= (float f) |
Multiplies this Vector2 by a float. | |
Vector2 & | operator/= (float f) |
Divides the Vector2 by a float. | |
Static Public Member Functions | |
static float | DotProduct (const Vector2 &v1, const Vector2 &v2) |
Returns the dot product of 2 vectors. v1.v2 == |v1|*|v2|*cos(v1,v2). So this gives the cosine of the angle between 2 vectors. | |
static Vector2 | Average (const Vector2 &v1, const Vector2 &v2) |
averages 2 vectors | |
Public Attributes | |
float | x |
Accessors. | |
float | y |
Friends | |
bool | operator== (const Vector2 &v1, const Vector2 &v2) |
Comparison Operator. | |
bool | operator!= (const Vector2 &v1, const Vector2 &v2) |
Difference Operator. | |
Vector2 | operator- (const Vector2 &v) |
Negates this vector. | |
Vector2 | operator+ (const Vector2 &v1, const Vector2 &v2) |
Adds 2 Vector2. | |
Vector2 | operator- (const Vector2 &v1, const Vector2 &v2) |
Subtracts one Vector2 from another. | |
Vector2 | operator * (const Vector2 &v, float f) |
Multiplies a Vector2 by a float. | |
Vector2 | operator * (float f, const Vector2 &v) |
Multiplies a Vector2 by a float. | |
Vector2 | operator/ (const Vector2 &v, float f) |
Divides a Vector2 by a float. |
|
Default constructor. Initialises data to 0.0f.
|
|
Constructor that builds the vector data from floats given through arguments.
|
|
Copy Constructor.
|
|
averages 2 vectors
|
|
returns the distance between two Vector2's used as vertices
|
|
Returns the dot product of 2 vectors. v1.v2 == |v1|*|v2|*cos(v1,v2). So this gives the cosine of the angle between 2 vectors.
|
|
Is the vector equal to (0, 0) ?
|
|
Returns the magnitude of a vector. Primarily used for normalizing vectors.
|
|
Returns the squared magnitude of a vector.
|
|
Normalises a given vector. In clear words, changes the vector so that its "length" is 1.
|
|
Multiplies this Vector2 by a float.
|
|
Adds a Vector2 to this one.
|
|
Subtracts a Vector2 from this one.
|
|
Divides the Vector2 by a float.
|
|
Affectation operator.
|
|
Indexing operator.
|
|
Indexing operator.
|
|
rotates a vector around the X axis by a given angle, in radians
|
|
Returns a string that represents the actual object.
|
|
returns the angle between two Vector2's used as vertices
|
|
Multiplies a Vector2 by a float.
|
|
Multiplies a Vector2 by a float.
|
|
Difference Operator.
|
|
Adds 2 Vector2.
|
|
Subtracts one Vector2 from another.
|
|
Negates this vector.
|
|
Divides a Vector2 by a float.
|
|
Comparison Operator.
|
|
Accessors.
|
|
|