#include <tb_vector.h>
Public Member Functions | |
Vector2 (const SkipInitialization &fastAndStupid) | |
Vector2 (void) | |
Vector2 (const float valueX, const float valueY) | |
Vector2 (const Vector2 &other) | |
~Vector2 (void) | |
Vector2 & | operator= (const Vector2 &other) |
bool | operator== (const Vector2 &other) const |
bool | operator!= (const Vector2 &other) const |
operator const float * (void) const | |
operator float * (void) | |
const float & | operator[] (const size_t index) const |
float & | operator[] (const size_t index) |
Vector2 | operator+ (const Vector2 &rightSide) const |
Vector2 & | operator+= (const Vector2 &rightSide) |
Vector2 | operator- (const Vector2 &rightSide) const |
Vector2 & | operator-= (const Vector2 &rightSide) |
Vector2 | operator* (float scalar) const |
Vector2 & | operator*= (float scalar) |
Vector2 | operator/ (float scalar) const |
Vector2 & | operator/= (float scalar) |
Vector2 | operator- (void) const |
float | operator* (const Vector2 &rhs) const |
float | Magnitude (void) const |
float | MagnitudeSquared (void) const |
Vector2 | GetNormalized (void) const |
float | Normalize (void) |
void | Scale (float scalar) |
void | SetLength (float length) |
Static Public Member Functions | |
static Vector2 | Zero (void) |
Public Attributes | |
union { | |
float mComponents [2] | |
struct { | |
float x | |
float y | |
} | |
}; | |
Friends | |
Vector2 | operator* (float scalar, const Vector2 &rightSide) |
The Vector2 object is a two component mathematical vector of floats packed together with some functionality to perform basic vector math.
|
inlineexplicit |
Constructs a Vector2 object leaving the members uninitialized and must be initialized manually before the object is used.
|
inline |
Constructs a default Vector2 object with all components set to 0.0f.
|
inline |
Constructs a Vector2 object with each component initialized with the values provided.
valueX | The value to initialize the x component as. |
valueY | The value to initialize the y component as. |
|
inline |
|
inline |
Nothing needs to happen to destroy a Vector2 object.
|
inline |
Computes the magnitude and returns a unit length vector in the same direction. Since this could result in a divide-by-zero, if the magnitude is zero, the zero vector is returned.
|
inline |
Computes the length / magnitude of the Vector object which involves a square root, then returns the resulting scalar value.
|
inline |
Computes the length / magnitude of the Vector object left squared so the square root is not taken, then returns the resulting scalar value.
|
inline |
Computes the magnitude of the Vector object and modifies it to represent the unit length vector in the same direction. If the magnitude is zero, the vector remains unmodified... After modifying the object the old magnitude is returned.
|
inline |
Returns a const float array of the Vector2 components.
|
inline |
Returns a float array of the Vector2 components. If modified the internal components will also be modified as well.
|
inline |
Inequality operator, returns the opposite of the equality operator, which compares each value in one Vector2 object to another using IsEqual to compare the floating point component values.
|
inline |
|
inline |
Perform a dot product on two Vector2 objects, returning the scalar result.
|
inline |
Adds each component of a Vector2 object to the component values of the left side object modifying it and returning the result.
|
inline |
Returns a Vector2 object with each component being the negative of the object used.
Subtracts two Vector2 objects (this -= rightSide) and modifies this object and returns the result.
|
inline |
Performs a scalar division operation on each component of the Vector2 object returning the result.
|
inline |
|
inline |
Equality operator, compares each component of the Vector2 object to the values of another Vector2 returning true if all components are equal, or false if any of the components are not equal.
other | The Vector2 object to compare against. |
|
inline |
Returns a reference to one of the Vector2 components by an index provided by the VectorComponent enum.
|
inline |
Returns a reference to one of the Vector2 components by an index provided by the VectorComponent enum. If the reference returned is modified, the internal components will also be modified as well.
|
inline |
Performs scalar multiplication on the Vector object, exactly the same as *= with a scalar.
|
inline |
This is a convenience function that will normalize then scale the Vector object, setting the length as desired.
length | The desired length of the vector in the same direction. 1.0 is the unit vector and has the same vector as if you had just normalized. |
|
inlinestatic |
Creates and returns a Vector2 object representing 0, 0.