RML::Vector3D struct

A vector 3d.

Constructors, destructors, conversion operators

Vector3D()
Default constructor.
Vector3D(const float& x, const float& y, const float& z)
Constructor.

Public functions

auto getLength(Vector3D& vector) const -> float
Gets length of vector.
auto getLength() const -> float
Gets length of this vector.
auto getVector2D() -> Vector2D
Return a Vector2D containing the x and y values from this Vector3D respectively.
auto add(const Vector3D& other) -> Vector3D&
Adds other.
auto subtract(const Vector3D& other) -> Vector3D&
Subtracts the given other.
auto multiply(const Vector3D& other) -> Vector3D&
Multiplies the given other.
auto multiplyDot(const Vector3D& other) -> float
Multiplies the given other (Dot product).
auto multiplyCross(const Vector3D& other) -> Vector3D&
Multiplies the given other (Cross product).
auto multiplyFloat(const float& other) -> Vector3D&
Multiplies the given float with this (Scaling).
auto divide(const Vector3D& other) -> Vector3D&
Divides the given other. Returns [a/x , b/y , c/z] if [a , b , c] is divided by [x , y , z].
auto maxComponent() -> float
Return the maximum coordinate across all axes.
auto toUnitVector() -> Vector3D&
Convert this vector to a unit vector.
auto abs() -> Vector3D&
Take modulus of all coordinates.
auto operator==(const Vector3D& other) -> bool
Equality operator.
auto operator!=(const Vector3D& other) -> bool
Inequality operator.
auto operator+=(const Vector3D& other) -> Vector3D&
Addition assignment operator.
auto operator-=(const Vector3D& other) -> Vector3D&
Subtraction assignment operator.
auto operator*=(const Vector3D& other) -> Vector3D&
Multiplication assignment operator.
auto operator/=(const Vector3D& other) -> Vector3D&
Division assignment operator.

Public variables

float x
The x coordinate.
float y
The y coordinate.
float z
The z coordinate.

Friends

auto operator<<(std::ostream& stream, const Vector3D& vector) -> std::ostream&
Put to operator.
auto operator+(Vector3D left, const Vector3D& right) -> Vector3D&
Addition operator.
auto operator-(Vector3D left, const Vector3D& right) -> Vector3D&
Subtraction operator.
auto operator*(Vector3D left, const Vector3D& right) -> Vector3D&
Multiplication operator.
auto operator*(const Vector3D vector, const float& other) -> Vector3D&
Float multiplication operator. (Scaling)
auto operator/(Vector3D left, const Vector3D& right) -> Vector3D&
Division operator.
auto operator/(const Vector3D vector, const float& other) -> Vector3D&
Float division operator. (Down scaling)

Function documentation

RML::Vector3D::Vector3D(const float& x, const float& y, const float& z)

Constructor.

Parameters
x The x coordinate.
y The y coordinate.
z The z coordinate.

float RML::Vector3D::getLength(Vector3D& vector) const

Gets length of vector.

Parameters
vector in/out The vector.
Returns The length.

float RML::Vector3D::getLength() const

Gets length of this vector.

Returns The length.

Vector2D RML::Vector3D::getVector2D()

Return a Vector2D containing the x and y values from this Vector3D respectively.

Returns The length.

Vector3D& RML::Vector3D::add(const Vector3D& other)

Adds other.

Parameters
other The other to add.
Returns A reference to a Vector3D.

Vector3D& RML::Vector3D::subtract(const Vector3D& other)

Subtracts the given other.

Parameters
other The other.
Returns A reference to a Vector3D.

Vector3D& RML::Vector3D::multiply(const Vector3D& other)

Multiplies the given other.

Parameters
other The other.
Returns A reference to a Vector3D.

float RML::Vector3D::multiplyDot(const Vector3D& other)

Multiplies the given other (Dot product).

Parameters
other The other.
Returns A result of the operation.

Vector3D& RML::Vector3D::multiplyCross(const Vector3D& other)

Multiplies the given other (Cross product).

Parameters
other The other.
Returns A result of the operation.

Vector3D& RML::Vector3D::multiplyFloat(const float& other)

Multiplies the given float with this (Scaling).

Parameters
other The other.
Returns A result of the operation.

Vector3D& RML::Vector3D::divide(const Vector3D& other)

Divides the given other. Returns [a/x , b/y , c/z] if [a , b , c] is divided by [x , y , z].

Parameters
other The other.
Returns A reference to a Vector3D.

float RML::Vector3D::maxComponent()

Return the maximum coordinate across all axes.

Returns The maximum coordinate.

Vector3D& RML::Vector3D::toUnitVector()

Convert this vector to a unit vector.

Returns The unit vector.

Vector3D& RML::Vector3D::abs()

Take modulus of all coordinates.

Returns The abs vector.

bool RML::Vector3D::operator==(const Vector3D& other)

Equality operator.

Parameters
other The other.
Returns True if the parameters are considered equivalent.

Int equality operator.

bool RML::Vector3D::operator!=(const Vector3D& other)

Inequality operator.

Parameters
other The other.
Returns True if the parameters are not considered equivalent.

Vector3D& RML::Vector3D::operator+=(const Vector3D& other)

Addition assignment operator.

Parameters
other The other.
Returns The result of the operation.

Vector3D& RML::Vector3D::operator-=(const Vector3D& other)

Subtraction assignment operator.

Parameters
other The other.
Returns The result of the operation.

Vector3D& RML::Vector3D::operator*=(const Vector3D& other)

Multiplication assignment operator.

Parameters
other The other.
Returns The result of the operation.

Vector3D& RML::Vector3D::operator/=(const Vector3D& other)

Division assignment operator.

Parameters
other The other.
Returns The result of the operation.

std::ostream& operator<<(std::ostream& stream, const Vector3D& vector)

Put to operator.

Parameters
stream Reference to the stream to be put to.
vector Vector3D to be put to stream object.
Returns Reference to the stream been put to.

Vector3D& operator+(Vector3D left, const Vector3D& right)

Addition operator.

Parameters
left The left operand.
right The right operand.
Returns The result of the operation.

Vector3D& operator-(Vector3D left, const Vector3D& right)

Subtraction operator.

Parameters
left The left operand.
right The right operand.
Returns The result of the operation.

Vector3D& operator*(Vector3D left, const Vector3D& right)

Multiplication operator.

Parameters
left The left operand.
right The right operand.
Returns The result of the operation.

Vector3D& operator*(const Vector3D vector, const float& other)

Float multiplication operator. (Scaling)

Parameters
vector The vector.
other The float to multiply.
Returns The result of the operation.

Vector3D& operator/(Vector3D left, const Vector3D& right)

Division operator.

Parameters
left The left operand.
right The right operand.
Returns The result of the operation.

Vector3D& operator/(const Vector3D vector, const float& other)

Float division operator. (Down scaling)

Parameters
vector The vector operand.
other The float to divide with.
Returns The result of the operation.