Generalized two-element cartesian coordinate vector. More...
#include <sifteo/math.h>
Public Member Functions | |
template<typename R > | |
Vector2< R > | cast () const |
Explicitly cast this vector to another vector type, using default C++ truncation or extension rules. | |
Vector2< T > | cmul (Vector2< T > u) const |
Complex multiplication. More... | |
T | len () const |
Calculate the scalar length (magnitude) of this vector. | |
T | len2 () const |
Calculate the scalar length (magnitude) of this vector, squared. More... | |
T | lenManhattan () const |
Calculate the manhattan (city block) distance of this vector. | |
Vector2< T > | normalize () const |
Return a normalized version of this vector. More... | |
Vector2< T > | rotate (float angle) const |
Rotate this vector about the origin counterclockwise by 'angle' radians. | |
Vector2< T > | rotateI (int angle) const |
Rotate this vector about the origin counterclockwise by an integer multiple of 90 degrees. More... | |
Vector2< int > | round () const |
Round a floating point vector to the nearest integer. | |
void | set (T _x, T _y) |
Modify this vector's value in-place. | |
void | setPolar (float angle, float magnitude) |
Set this vector to a new cartesian value, given a value in polar coordinates. | |
Vector2< double > | toDouble () const |
Explicit cast to double. | |
Vector2< float > | toFloat () const |
Explicit cast to float. | |
Vector2< int > | toInt () const |
Explicit cast to int. | |
Static Public Member Functions | |
static Vector2< T > | unit (int side) |
Create a unit vector corresponding to the given integer 'side'. More... | |
Public Attributes | |
T | x |
Vector component X. | |
T | y |
Vector component Y. | |
Generalized two-element cartesian coordinate vector.
|
inline |
Complex multiplication.
Treat this vector as a complex number, and multiply it with another vector equivalently interpreted.
|
inline |
Calculate the scalar length (magnitude) of this vector, squared.
This avoids the costly square root calculation.
|
inline |
Return a normalized version of this vector.
The returned vector will have a magnitude of 1.0.
|
inline |
Rotate this vector about the origin counterclockwise by an integer multiple of 90 degrees.
The angle must be 0, 1, 2, or 3. If you must pass larger angles, you can use umod(a, 4) to fold them into this range.
|
inlinestatic |
Create a unit vector corresponding to the given integer 'side'.
0 = -Y (Up) 1 = -X (Left) 2 = +Y (Down) 3 = +X (Right)
Sifteo SDK v1.1.0 (see all versions)
Last updated Tue Dec 23 2014, by Doxygen