#include <sgVector2.h>
Public Member Functions | |
sgVector2 (float x_=0.0f, float y_=0.0f) | |
sgVector2 (const sgVector2 &other) | |
bool | operator== (const sgVector2 &other) |
bool | operator!= (const sgVector2 &other) |
sgVector2 & | operator= (const sgVector2 &other) |
sgVector2 & | operator= (const float &other) |
sgVector2 & | operator+= (const sgVector2 &other) |
sgVector2 & | operator-= (const sgVector2 &other) |
sgVector2 & | operator*= (const sgVector2 &other) |
sgVector2 & | operator/= (const sgVector2 &other) |
sgVector2 | operator+ (const sgVector2 &other) |
sgVector2 | operator- (const sgVector2 &other) |
sgVector2 | operator* (const sgVector2 &other) |
sgVector2 | operator/ (const sgVector2 &other) |
sgVector2 & | operator+= (const float &other) |
sgVector2 & | operator-= (const float &other) |
sgVector2 & | operator*= (const float &other) |
sgVector2 & | operator/= (const float &other) |
sgVector2 | operator+ (const float &other) |
sgVector2 | operator- (const float &other) |
sgVector2 | operator* (const float &other) |
sgVector2 | operator/ (const float &other) |
float | length () |
void | makeIdentity () |
void | normalize () |
float | dot (sgVector2 &other) |
float | dist (sgVector2 &other) |
Public Attributes | |
float | x |
float | y |
2D vector class. Stores a vector with two elements and provides functionality for it.
sgVector2::sgVector2 | ( | float | x_ = 0.0f , |
|
float | y_ = 0.0f | |||
) |
Constructor. Initializes a new instance.
x_ | the x value | |
y_ | the y value |
sgVector2::sgVector2 | ( | const sgVector2 & | other | ) |
Constructor. Initializes a new instance.
other | vector to copy the values from |
float sgVector2::dist | ( | sgVector2 & | other | ) |
Distance. The distance of the vector with the other one.
other | another vector |
float sgVector2::dot | ( | sgVector2 & | other | ) |
Dot product. The dot product of the vector with the other one.
other | another vector |
float sgVector2::length | ( | ) |
Length. Get the length of the vector.
void sgVector2::makeIdentity | ( | ) |
Make identity. Sets the vectors components to 0.
void sgVector2::normalize | ( | ) |
Normalize. Keeps the vectors direction, but sets its length to 1.
bool sgVector2::operator!= | ( | const sgVector2 & | other | ) |
Not equal. Checks if two instances do not equal each other.
sgVector2 sgVector2::operator* | ( | const float & | other | ) |
Multiply. Multiply the scalar to each component of the vector.
Multiply. Multiply the two vectors component wise.
sgVector2 & sgVector2::operator*= | ( | const float & | other | ) |
Multiply. Multiply the scalar to each component of the vector.
Multiply. Multiply the two vectors component wise.
sgVector2 sgVector2::operator+ | ( | const float & | other | ) |
Add. Add the scalar to each component of the vector.
sgVector2 & sgVector2::operator+= | ( | const float & | other | ) |
Add. Add the scalar to each component of the vector.
Add. Add the two vectors component wise.
sgVector2 sgVector2::operator- | ( | const float & | other | ) |
Substract. Substract the scalar from each component of the vector.
Substract. Substract the two vectors component wise.
sgVector2 & sgVector2::operator-= | ( | const float & | other | ) |
Substract. Substract the scalar from each component of the vector.
Substract. Substract the two vectors component wise.
sgVector2 sgVector2::operator/ | ( | const float & | other | ) |
Divide. Divide each component of the vector by the scalar.
Divide. Divide the two vectors component wise.
sgVector2 & sgVector2::operator/= | ( | const float & | other | ) |
Divide. Divide each component of the vector by the scalar.
Divide. Divide the two vectors component wise.
sgVector2 & sgVector2::operator= | ( | const float & | other | ) |
Copy. Sets all components to the value of the scalar.
Copy. Copy the values of one instance to the other.
bool sgVector2::operator== | ( | const sgVector2 & | other | ) |
Equal. Checks if two instances equal each other.
float sgVector2::x |
X. The vectors x component.
float sgVector2::y |
Y. The vectors y component.