#include <qafVector2D.h>
This class overloads several operators to make evaluating formulae easier.
The multiplication operator (*
) can be used with a scalar argument (i.e., a float
value), or with another vector, in which case it stands for the dot product.
Public Member Functions | |
Vector2D (float _x, float _y) | |
Vector2D (int _x, int _y) | |
Vector2D & | operator= (const Vector2D &v) |
float | length () const |
Returns the Euclidian norm of this vector. | |
float | dist (const Vector2D &that) const |
Returns the distance between the points denoted by this and that. | |
Vector2D | unit () const |
Returns a copy of the vector, with length equal to 1. | |
void | normalize () |
Resizes the vector so it will have length equal to 1. | |
Vector2D | project (const Vector2D &onto) const |
Returns the projection of this vector onto another. | |
Vector2D | reflect (const Vector2D &around) const |
Returns the reflection of this vector relative to around . | |
Vector2D | rotate (float radians) const |
Returns a rotated copy of this vector. | |
float | angle (const Vector2D &v) const |
Returns the angle between this vector and v . | |
Vector2D & | operator+= (const Vector2D &v) |
Vector2D & | operator-= (const Vector2D &v) |
Vector2D | operator+ (const Vector2D &v) const |
Vector2D | operator- (const Vector2D &v) const |
Vector2D | operator- () const |
Vector2D & | operator *= (float s) |
Vector2D | operator * (float s) const |
Vector2D & | operator/= (float s) |
Vector2D | operator/ (float s) const |
float | operator * (const Vector2D &v) const |
Returns the dot product of this vector and v . | |
Public Attributes | |
float | x |
float | y |
float qaf::Vector2D::length | ( | ) | const [inline] |
Returns the Euclidian norm of this vector.
float qaf::Vector2D::dist | ( | const Vector2D & | that | ) | const [inline] |
Returns the distance between the points denoted by this and that.
Vector2D qaf::Vector2D::unit | ( | ) | const [inline] |
Returns a copy of the vector, with length equal to 1.
void qaf::Vector2D::normalize | ( | ) | [inline] |
Resizes the vector so it will have length equal to 1.
Returns the projection of this vector onto another.
Returns the reflection of this vector relative to around
.
Vector2D qaf::Vector2D::rotate | ( | float | radians | ) | const [inline] |
Returns a rotated copy of this vector.
float qaf::Vector2D::angle | ( | const Vector2D & | v | ) | const [inline] |
Returns the angle between this vector and v
.
float qaf::Vector2D::operator * | ( | const Vector2D & | v | ) | const [inline] |
Returns the dot product of this vector and v
.