ASL
|
A Vec2 represents a vector in 2D space.
This class allows operating with vectors as with primitive types via operators.
The angle between two vectors can be computed with:
#include <Vec2.h>
Public Member Functions | |
Vec2_ (T x, T y) | |
Constructs a vector with the given (x, y) coordinates. | |
Vec2_ | perpend () const |
Returns this vector rotated 90 degrees counterclockwise. | |
Vec2_ | rotate (T a) const |
Returns this vector rotated an angle a . | |
Vec2_ | normalized () const |
Returns this vector normalized. | |
T | angle () const |
Returns the angle between this vector and the +X axis in the [-PI, PI] range. | |
T | angle (const Vec2_ &b) const |
Returns the angle between this vector and b | |
T | operator! () const |
Returns the length of this vector. | |
T | length () const |
Returns the length of this vector. | |
T | length2 () const |
Returns the length of this vector squared. | |
Vec2_ | operator+ (const Vec2_ &b) const |
Returns this vector plus b | |
Vec2_ | operator- (const Vec2_ &b) const |
Returns this vector minus b | |
T | operator* (const Vec2_ &b) const |
Returns the dot product of this vector and b | |
Vec2_ | operator* (T r) const |
Returns this vector multiplied by scalar r | |
T | operator^ (const Vec2_ &b) const |
Returns the z-component of the cross product of this vector and b | |
Vec2_ | operator/ (T r) const |
Returns this vector divided by scalar r | |
Vec2_ | operator% (const Vec2_ &b) const |
Returns a vector that is a component-wise product of this vector and b | |
bool | operator== (const Vec2_ &b) const |
Compares this vector and b (warning: test equality of floats with care) | |
bool | operator!= (const Vec2_ &b) const |
Compares this vector and b (warning: test equality of floats with care) | |
void | operator+= (const Vec2_ &b) |
Adds b to this vector. | |
void | operator-= (const Vec2_ &b) |
Subtracts b from this vector. | |
void | operator*= (T r) |
Multiplies this vector by scalar r | |
void | operator/= (T r) |
Divides this vector by scalar r | |
void | operator%= (const Vec2_ &b) |
Multiplies this vector by another, component-wise. | |
Vec2_ | operator- () const |
Returns this vector negated. | |
Static Public Member Functions | |
static Vec2_ | polar (T r, T a) |
Returns a vector constructed from polar coordinates. | |
Friends | |
Vec2_ | operator* (T r, const Vec2_ &b) |
Returns vector b multiplied by scalar r | |