2D vector More...
#include <Vector2.h>
Public Member Functions | |
Vector2 () | |
Default constructor. More... | |
Vector2 (T X, T Y) | |
Construct the vector from its coordinates. More... | |
template<typename U > | |
Vector2 (const Vector2< U > &vector) | |
Construct the vector from another type of vector. More... | |
float | magnitude () const |
Get the magnitude/length of the vector. More... | |
float | dot (const Vector2< T > &otherVec) const |
Get the scalar product of this vector and another vector. More... | |
T | cross (const Vector2< T > &otherVec) const |
Get the cross product of this vector and anther vector. More... | |
float | distanceTo (const Vector2< T > &otherVec) const |
Get the distance between this vector and another vector. More... | |
float | angle () const |
Get the angle between the vector and the positive x-axis, in degrees. More... | |
float | angleTo (const Vector2< T > &otherVec) const |
Get the angle between this vector and another vector, in degrees. More... | |
Vector2< float > | asUnitVector () const |
Get the unit vector of this vector. More... | |
Public Attributes | |
T | x |
X coordinate of the vector. More... | |
T | y |
Y coordinate of the vector. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
Vector2< T > | operator- (const Vector2< T > &right) |
Overload of unary operator -. More... | |
template<typename T > | |
Vector2< T > & | operator+= (Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator +=. More... | |
template<typename T > | |
Vector2< T > & | operator-= (Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator -=. More... | |
template<typename T > | |
Vector2< T > | operator+ (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator +. More... | |
template<typename T > | |
Vector2< T > | operator- (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator -. More... | |
template<typename T > | |
Vector2< T > | operator* (const Vector2< T > &left, T right) |
Overload of binary operator *. More... | |
template<typename T > | |
Vector2< T > | operator/ (const Vector2< T > &left, T right) |
Overload of binary operator /. More... | |
template<typename T > | |
Vector2< T > & | operator/= (Vector2< T > &left, T right) |
Overload of binary operator /=. More... | |
template<typename T > | |
bool | operator== (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator ==. More... | |
template<typename T > | |
bool | operator!= (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator !=. More... | |
template<typename T > | |
bool | operator< (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator <. More... | |
template<typename T > | |
bool | operator> (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator > More... | |
template<typename T > | |
bool | operator<= (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator <=. More... | |
template<typename T > | |
bool | operator>= (const Vector2< T > &left, const Vector2< T > &right) |
Overload of binary operator >=. More... | |
ime::Vector2< T >::Vector2 | ( | ) |
Default constructor.
Creates a Vector2(0, 0)
ime::Vector2< T >::Vector2 | ( | T | X, |
T | Y | ||
) |
Construct the vector from its coordinates.
X | X coordinate |
Y | Y coordinate |
|
explicit |
Construct the vector from another type of vector.
vector | Vector to convert |
This constructor doesn't replace the copy constructor, it's called only when U != T. A call to this constructor will fail to compile if U is not convertible to T
float ime::Vector2< T >::angle | ( | ) | const |
Get the angle between the vector and the positive x-axis, in degrees.
float ime::Vector2< T >::angleTo | ( | const Vector2< T > & | otherVec | ) | const |
Get the angle between this vector and another vector, in degrees.
otherVec | The vector to get the angle to |
Vector2< float > ime::Vector2< T >::asUnitVector | ( | ) | const |
Get the unit vector of this vector.
T ime::Vector2< T >::cross | ( | const Vector2< T > & | otherVec | ) | const |
Get the cross product of this vector and anther vector.
otherVec | The vector to cross with this vector |
float ime::Vector2< T >::distanceTo | ( | const Vector2< T > & | otherVec | ) | const |
Get the distance between this vector and another vector.
otherVec | The vector to get the distance to |
float ime::Vector2< T >::dot | ( | const Vector2< T > & | otherVec | ) | const |
Get the scalar product of this vector and another vector.
otherVec | The vector to dot with this vector |
float ime::Vector2< T >::magnitude | ( | ) | const |
Get the magnitude/length of the vector.
|
related |
Overload of binary operator !=.
left | Left operand (a vector) |
right | Right operand (a vector) |
This operator compares strict difference between two vectors
Overload of binary operator *.
left | Left operand (a vector) |
right | Right operand (a scalar value) |
|
related |
Overload of binary operator +.
left | Left operand (a vector) |
right | Right operand (a vector) |
|
related |
Overload of binary operator +=.
left | Left operand (a vector) |
right | Right operand (a vector) |
This operator performs a memberwise addition of both vectors, and assigns the result to left.
|
related |
Overload of binary operator -.
left | Left operand (a vector) |
right | Right operand (a vector) |
Overload of unary operator -.
right | Vector to negate |
|
related |
Overload of binary operator -=.
left | Left operand (a vector) |
right | Right operand (a vector) |
This operator performs a memberwise subtraction of both vectors, and assigns the result to left.
Overload of binary operator /.
left | Left operand (a vector) |
right | Right operand (a scalar value) |
Overload of binary operator /=.
left | Left operand (a vector) |
right | Right operand (a scalar value) |
This operator performs a memberwise division by right, and assigns the result to left.
|
related |
Overload of binary operator <.
left | Left operand (a vector) |
right | Right operand (a vector) |
This function returns true if the x member of left is less than the x member of right AND the y member of left is less than the y member of right, otherwise it returns false
|
related |
Overload of binary operator <=.
left | Left operand (a vector) |
right | Right operand (a vector) |
This function returns true if the x member of left is less than or equal to the x member of right AND the y member of left is less than or equal to the y member of right, otherwise it returns false
|
related |
Overload of binary operator ==.
left | Left operand (a vector) |
right | Right operand (a vector) |
This operator compares strict equality between two vectors
|
related |
Overload of binary operator >
left | Left operand (a vector) |
right | Right operand (a vector) |
This function returns true if the x member of left is greater than the x member of right AND the y member of left is greater than the y member of right, otherwise it returns false
|
related |
Overload of binary operator >=.
left | Left operand (a vector) |
right | Right operand (a vector) |
This function returns true if the x member of left is greater than or equal to the x member of right AND the y member of left is greater than or equal to the y member of right, otherwise it returns false Define the most common types
T ime::Vector2< T >::x |
T ime::Vector2< T >::y |