struct
Vector2DA vector in 2D.
Contents
Constructors, destructors, conversion operators
Public functions
- auto roundTo(const float& pivotX, const float& errorX, const float& pivotY, const float& errorY) -> Vector2D&
- Rounds the coordinates to the pivot values for X and Y within the ranges of the error values.
- auto getLength(Vector2D& vector) const -> float
- Gets length of vector.
- auto getLength() const -> float
- Gets length of this vector.
- auto toUnitVector() -> Vector2D
- Convert this to a unit vector.
- auto maxVector(const Vector2D& other) -> Vector2D
- Returns a Vector2D with only the maximum coordinates on each axes as compared to the given other.
- auto abs() -> Vector2D&
- Take modulus of all coordinates.
- auto multiplyCross(const Vector2D& other) -> float
- Multiplies the given other (Cross product).
- auto add(const Vector2D& other) -> Vector2D&
- Adds other.
- auto subtract(const Vector2D& other) -> Vector2D
- Subtracts the given other.
- auto multiply(const Vector2D& other) -> Vector2D&
- Multiplies the given other.
- auto multiplyDot(const Vector2D& other) -> float
- Multiplies the given other vector (Dot product)
- auto multiplyFloat(const float& other) -> Vector2D&
- Scale all values of this vector by a float.
- auto divide(const Vector2D& other) -> Vector2D&
- Divides each element of this vector one by one by the corresponding vector of the other vector. Returns [a/x , b/y] if [a , b] is divided by [x , y].
- auto operator==(const Vector2D& other) -> bool
- Equality operator.
- auto operator!=(const Vector2D& other) -> bool
- Inequality operator.
- auto operator+=(const Vector2D& other) -> Vector2D&
- Addition assignment operator.
- auto operator-=(const Vector2D& other) -> Vector2D
- Subtraction assignment operator.
- auto operator*=(const Vector2D& other) -> Vector2D&
- Multiplication assignment operator.
- auto operator/=(const Vector2D& other) -> Vector2D&
- Division assignment operator.
Public variables
Friends
- auto operator<<(std::ostream& stream, const Vector2D& vector) -> std::ostream&
- Put to operator.
- auto operator+(Vector2D left, const Vector2D& right) -> Vector2D&
- Addition operator.
- auto operator-(Vector2D left, const Vector2D& right) -> Vector2D
- Subtraction operator.
- auto operator*(Vector2D left, const Vector2D& right) -> Vector2D&
- Multiplication operator.
- auto operator*(Vector2D left, const float& right) -> Vector2D&
- Float multiplication operator.
- auto operator*(Vector2D& left, const Vector2D& right) -> float
- Dot multiplication operator.
- auto operator/(Vector2D left, const Vector2D& right) -> Vector2D&
- Division operator.
Function documentation
RML:: Vector2D:: Vector2D(const float& x,
const float& y)
Constructor.
Parameters | |
---|---|
x | The x coordinate. |
y | The y coordinate. |
Vector2D& RML:: Vector2D:: roundTo(const float& pivotX,
const float& errorX,
const float& pivotY,
const float& errorY)
Rounds the coordinates to the pivot values for X and Y within the ranges of the error values.
Parameters | |
---|---|
pivotX | The X pivot. |
errorX | The X error for pivot. |
pivotY | The Y pivot. |
errorY | The Y error for pivot. |
Vector2D RML:: Vector2D:: toUnitVector()
Convert this to a unit vector.
Returns | The normalised vector. |
---|
float RML:: Vector2D:: multiplyCross(const Vector2D& other)
Multiplies the given other (Cross product).
Parameters | |
---|---|
other | The other. |
Returns | A result of the operation. |
float RML:: Vector2D:: multiplyDot(const Vector2D& other)
Multiplies the given other vector (Dot product)
Parameters | |
---|---|
other | The other. |
Returns | A dot product result. |
Vector2D& RML:: Vector2D:: multiplyFloat(const float& other)
Scale all values of this vector by a float.
Parameters | |
---|---|
other | The other. |
Returns | Scaled version of this vector. |
bool RML:: Vector2D:: operator==(const Vector2D& other)
Equality operator.
Parameters | |
---|---|
other | The other. |
Returns | True if the parameters are considered equivalent. |
bool RML:: Vector2D:: operator!=(const Vector2D& other)
Inequality operator.
Parameters | |
---|---|
other | The other. |
Returns | True if the parameters are not considered equivalent. |
Vector2D& RML:: Vector2D:: operator+=(const Vector2D& other)
Addition assignment operator.
Parameters | |
---|---|
other | The other. |
Returns | The result of the operation. |
Vector2D RML:: Vector2D:: operator-=(const Vector2D& other)
Subtraction assignment operator.
Parameters | |
---|---|
other | The other. |
Returns | The result of the operation. |
Vector2D& RML:: Vector2D:: operator*=(const Vector2D& other)
Multiplication assignment operator.
Parameters | |
---|---|
other | The other. |
Returns | The result of the operation. |
Vector2D& RML:: Vector2D:: operator/=(const Vector2D& other)
Division assignment operator.
Parameters | |
---|---|
other | The other. |
Returns | The result of the operation. |
std::ostream& operator<<(std::ostream& stream, const Vector2D& vector)
Put to operator.
Parameters | |
---|---|
stream | The output stream. |
vector | The vector to be put to stream. |
Returns | The result of the operation. |