Clutter Engine 0.0.1
|
Linearly interpolates between two vectors. More...
#include <Vector2.h>
Public Member Functions | |
Vector2 () | |
Default constructor initializing the vector to (0,0). | |
Vector2 (float pX, float pY) | |
Constructor initializing the vector to (pX, pY). | |
Vector2 (int pX, int pY) | |
Vector2 (GLuint pX, GLuint pY) | |
Vector2 (float pXY) | |
void | operator+= (Vector2 right) |
Adds the components of another vector to this vector. | |
void | operator+= (float length) |
Adds a scalar to both components of the vector. | |
void | operator-= (Vector2 right) |
Subtracts the components of another vector from this vector. | |
void | operator-= (float length) |
Subtracts a scalar from both components of the vector. | |
void | operator*= (Vector2 multiplyer) |
Multiplies the components of this vector by another vector. | |
void | operator*= (float length) |
Multiplies both components of the vector by a scalar. | |
void | operator/= (Vector2 divider) |
Divides the components of this vector by another vector. | |
void | operator/= (float length) |
Divides both components of the vector by a scalar. | |
void | operator= (Vector2 newVec) |
Assigns the components of another vector to this vector. | |
Vector2 | operator- () const |
Negates the vector. | |
float | Length () const |
Calculates the length of the vector. | |
bool | Equal (Vector2 right, double acceptance) const |
Checks if two vectors are equal within an acceptance range. | |
Vector2 | Normalized () |
Normalizes the vector to a unit vector. | |
float | LengthSquared () const |
Calculates the squared length of the vector. | |
float | Cross (const Vector2 &other) const |
Calculates the cross product of two vectors. | |
void | Clamp (float minValue, float maxValue) |
Clamps the vector components to the given range. | |
std::string | ToString () |
Converts the vector to a string representation. | |
glm::vec2 | ToGlm () |
Converts the vector to a glm::vec2. | |
Static Public Member Functions | |
static float | DistanceSquared (const Vector2 &left, const Vector2 &right) |
Calculates the squared distance between two vectors. | |
static Vector2 | Lerp (const Vector2 &start, const Vector2 &end, float t) |
Linearly interpolates between two vectors. | |
static float | Dot (const Vector2 &left, const Vector2 &right) |
Calculates the dot product of two vectors. | |
static Vector2 | VInterp (const Vector2 ¤t, const Vector2 &target, float deltaTime, float interpSpeed) |
Linearly interpolates between two vectors. | |
Public Attributes | |
float | x = 0 |
The x-coordinate of the vector. | |
float | y = 0 |
The y-coordinate of the vector. | |
Static Public Attributes | |
static const Vector2 | Zero { 0 , 0 } |
A vector with both coordinates set to zero. | |
static const Vector2 | One { 1 , 1 } |
A vector with both coordinates set to one. | |
Friends | |
bool | operator== (Vector2 left, Vector2 right) |
Checks if two vectors are equal. | |
bool | operator!= (Vector2 left, Vector2 right) |
Checks if two vectors are not equal. | |
Vector2 | operator- (Vector2 left, Vector2 right) |
Subtracts two vectors. | |
Vector2 | operator- (Vector2 left, float right) |
Subtracts a scalar from a vector. | |
Vector2 | operator+ (Vector2 left, Vector2 right) |
Adds two vectors. | |
Vector2 | operator+ (Vector2 left, float right) |
Adds a scalar to a vector. | |
Vector2 | operator* (float scalar, Vector2 right) |
Multiplies a vector by a scalar. | |
Vector2 | operator* (Vector2 left, float scalar) |
Multiplies a vector by a scalar. | |
Vector2 | operator* (Vector2 left, Vector2 right) |
Multiplies two vectors component-wise. | |
Vector2 | operator/ (float scalar, Vector2 right) |
Divides a scalar by a vector. | |
Vector2 | operator/ (Vector2 left, float scalar) |
Divides a vector by a scalar. | |
Vector2 | operator/ (Vector2 left, Vector2 right) |
Divides two vectors component-wise. | |
Vector2 | Clamp (Vector2 temp, float minValue, float maxValue) |
Clamps the vector components to the given range. | |
Linearly interpolates between two vectors.
current | The current vector. |
target | The target vector. |
deltaTime | The time step. |
interpSpeed | The interpolation speed. |
A 2D vector structure.
|
inline |
Constructor initializing the vector to (pX, pY).
pX | The x-coordinate. |
pY | The y-coordinate. |
|
inline |
Clamps the vector components to the given range.
minValue | The minimum value. |
maxValue | The maximum value. |
|
inline |
Calculates the cross product of two vectors.
/**
other | The other vector. |
Calculates the squared distance between two vectors.
left | The left vector. |
right | The right vector. |
Calculates the dot product of two vectors.
left | The left vector. |
right | The right vector. |
|
inline |
Checks if two vectors are equal within an acceptance range.
right | The vector to compare to. |
acceptance | The acceptance range. |
|
inline |
Calculates the length of the vector.
|
inline |
Calculates the squared length of the vector.
Linearly interpolates between two vectors.
start | The start vector. |
end | The end vector. |
t | The interpolation factor (0.0 to 1.0). |
|
inline |
Normalizes the vector to a unit vector.
|
inline |
Multiplies both components of the vector by a scalar.
length | The scalar to multiply by. |
|
inline |
Multiplies the components of this vector by another vector.
multiplier | The vector to multiply by. |
|
inline |
Adds a scalar to both components of the vector.
length | The scalar to add. |
|
inline |
Adds the components of another vector to this vector.
right | The vector to add. |
|
inline |
Negates the vector.
|
inline |
Subtracts a scalar from both components of the vector.
length | The scalar to subtract. |
|
inline |
Subtracts the components of another vector from this vector.
right | The vector to subtract. |
|
inline |
Divides both components of the vector by a scalar.
length | The scalar to divide by. |
|
inline |
Divides the components of this vector by another vector.
divider | The vector to divide by. |
|
inline |
Assigns the components of another vector to this vector.
newVec | The vector to assign. |
|
inline |
|
inline |
Converts the vector to a string representation.
|
inlinestatic |
Linearly interpolates between two vectors.
current | The current vector. |
target | The target vector. |
deltaTime | The time step. |
interpSpeed | The interpolation speed. |
Clamps the vector components to the given range.
temp | The vector to clamp. |
minValue | The minimum value. |
maxValue | The maximum value. |
Checks if two vectors are not equal.
left | The left vector. |
right | The right vector. |
Multiplies a vector by a scalar.
scalar | The scalar. |
right | The vector. |
Multiplies a vector by a scalar.
left | The vector. |
scalar | The scalar. |
Multiplies two vectors component-wise.
left | The left vector. |
right | The right vector. |
Adds a scalar to a vector.
left | The vector. |
right | The scalar. |
Adds two vectors.
left | The left vector. |
right | The right vector. |
Subtracts a scalar from a vector.
left | The vector. |
right | The scalar. |
Subtracts two vectors.
left | The left vector. |
right | The right vector. |
Divides a scalar by a vector.
scalar | The scalar. |
right | The vector. |
Divides a vector by a scalar.
left | The vector. |
scalar | The scalar. |
Divides two vectors component-wise.
left | The left vector. |
right | The right vector. |
Checks if two vectors are equal.
left | The left vector. |
right | The right vector. |