A 2D vector class. More...
#include <vector2.h>
Public Member Functions | |
CVector2 () | |
Class constructor. More... | |
CVector2 (Real f_x, Real f_y) | |
Class constructor. More... | |
CVector2 (const std::array< Real, 2 > &arr_coordinates) | |
Class constructor. More... | |
CVector2 (Real f_length, const CRadians &f_angle) | |
Class constructor. More... | |
Real | GetX () const |
Returns the x coordinate of this vector. More... | |
void | SetX (Real f_x) |
Sets the x coordinate of this vector. More... | |
Real | GetY () const |
Returns the y coordinate of this vector. More... | |
void | SetY (Real f_y) |
Sets the y coordinate of this vector. More... | |
void | Set (Real f_x, Real f_y) |
Sets the vector contents from Cartesian coordinates. More... | |
void | Set (const std::array< Real, 2 > &arr_coordinates) |
Sets the vector contents from Cartesian coordinates. More... | |
void | FromPolarCoordinates (Real f_length, const CRadians &f_angle) |
Sets the vector contents from polar coordinates. More... | |
Real | SquareLength () const |
Returns the square length of this vector. More... | |
Real | Length () const |
Returns the length of this vector. More... | |
CVector2 & | Normalize () |
Normalizes this vector. More... | |
CRadians | Angle () const |
Returns the angle of this vector. More... | |
CVector2 & | Rotate (const CRadians &c_angle) |
Rotates this vector by the wanted angle. More... | |
Real | DotProduct (const CVector2 &c_vector2) const |
Returns the dot product between this vector and the passed one. More... | |
Real | CrossProduct (const CVector2 &c_vector2) const |
Returns the cross product between this vector and the passed one. More... | |
CVector2 & | Scale (Real f_scale_x, Real f_scale_y) |
Scales the vector by the wanted values. More... | |
CVector2 & | Perpendicularize () |
Transforms this vector into its ortogonal. More... | |
CVector2 & | Absolute () |
Applies Abs() to the coordinates of this vector. More... | |
bool | operator== (const CVector2 &c_vector2) const |
Returns true if this vector and the passed one are equal. More... | |
bool | operator!= (const CVector2 &c_vector2) const |
Returns true if this vector and the passed one are not equal. More... | |
CVector2 & | operator+= (const CVector2 &c_vector2) |
Sums the passed vector to this vector. More... | |
CVector2 & | operator-= (const CVector2 &c_vector2) |
Subtracts the passed vector from this vector. More... | |
CVector2 & | operator*= (Real f_value) |
Multiplies this vector by the given value. More... | |
CVector2 & | operator/= (Real f_value) |
Divides this vector by the given value. More... | |
CVector2 | operator+ (const CVector2 &c_vector2) const |
Returns a new vector containing the sum between this vector and the passed one. More... | |
CVector2 | operator- (const CVector2 &c_vector2) const |
Returns a new vector containing the subtraction between this vector and the passed one. More... | |
CVector2 | operator* (Real f_value) const |
Returns a new vector containing the multiplication between this vector and the passed value. More... | |
CVector2 | operator/ (Real f_value) const |
Returns a new vector containing the division between this vector and the passed value. More... | |
operator CMatrix< 1, 2 > () const | |
Implict conversion to a row matrix. More... | |
operator CMatrix< 2, 1 > () const | |
Implict conversion to a column matrix. More... | |
CVector2 | operator- () const |
Static Public Attributes | |
static const CVector2 | X |
The x axis. More... | |
static const CVector2 | Y |
The y axis. More... | |
static const CVector2 | ZERO |
The zero vector (0,0) More... | |
|
inline |
|
inline |
Class constructor.
It initializes the vector coordinates from polar coordinates.
f_length | the vector length. |
f_angle | the vector angle. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Scales the vector by the wanted values.
This method scales the vector by the wanted values. In practice, this means that it multiplies the x coordinate by f_scale_x and the y coordinate by f_scale_y.
f_scale_x | the scale factor for the x coordinate. |
f_scale_y | the scale factor for the y coordinate. |
|
inline |
|
inline |
|
inline |
|
inline |