Source code for a 2D vector library (.lib and .dll).
- Navigate to the Vector2 folder.
- Navigate to the x64 folder.
- Navigate to the release folder.
- Extract the .dll and .lib file.
- Return to the Vector2 folder.
- Navigate to the next Vector2 folder.
- Extract Vector2.h file.
Vector2() : x(0), y(0)
The Default constructor initialises the x and y variables to the value of 0.
Vector2(T vx, T vy) : x(vx), y(vy)
This overload constructor allows you to individually assign values to the x and y variables.
Vector2(const Vector2& v) : x(v.x), y(v.y)
This overload constructor allows you to assign the variables to an existing Vector2 object.
Vector2& operator=(const Vector2& v)
This operator takes the x and y values of the Vector2 parameter and assigns it to the x and y values of
this Vector2 object.
Vector2 operator+(const Vector2& r)
This operator adds the x and y values of two Vector2 objects and returns a new Vector2 object.
Vector2 operator-(const Vector2& r)
This operator subtracts the values of 'r' from the Vector2 object on the left.
Vector2 operator/(const Vector2& r)
This operator divides the vector on the left by the vector on the right and returns a new Vector2
object.
Vector2 operator*(const Vector2& r)
This operator multiplies the vector on the left by the vector on the right and returns a new Vector2
object.
Vector2 operator*(const float r)
This operator multiplies the x and y values of a vector by r, a floating point number and returns
a new Vector2 object.
Vector2 operator+=(const Vector2& r)
This operator adds the vector on the right to the vector on the left and assigns the vector on the left
the new values.
Vector2& operator-=(const Vector2& r)
This operator subtracts the vector on the right from the vector on the left and assigns the vector
on the left the new values.
Vector2& operator/=(const Vector2& r)
This operator divides the vector on the right from the vector on the right and assigns the vector
on the left the new values.
Vector2& operator*=(const Vector2& r)
This operator multiples the vector on the left by the vector on the right and assigns the vector
on the left the new values.
Vector2& operator*=(const float r)
This operator multiplies the x and y values of a vector by r, a floating point number and assigns
the vector the new values.
bool operator==(const Vector2& r)
This operator compares the left vector to the right vector and returns a bool statement, true if
they are equal or false if they are not equal.
bool operator!=(const Vector2& r)
This operator compares the left vector to the right vector and returns a bool statement, true if
they are not equal or false if they are equal.
Vector2& Normalise()
This function normalises the vector and sets its values to the normalised values.
float Magnitude()
This function calculates the size of vector and returns a floating point number.
Vector2 object that stores the x and y variables as integers.
Vector2 object that stores the x and y variables as floating point numbers.
Vector2 object that stores the x and y variables as doubles.