RML::Vector4D struct

A vector in 4d.

Constructors, destructors, conversion operators

Vector4D() defaulted
Default constructor.
Vector4D(const float& x, const float& y, const float& z, const float& w)
Constructor.

Public functions

auto getLength(Vector4D& vector) const -> float
Gets length of vector.
auto toUnitVector() -> Vector4D&
Returns this vector as a modified unit vector.
auto normaliseToRGBA() -> Vector4D
Normalise color values to OpenGL supporting RGBA. Eg. (128, 128, 128, 255) => (0.5f, 0.5f, 0.5f, 1.0f)
auto add(const Vector4D& other) -> Vector4D&
Adds other.
auto subtract(const Vector4D& other) -> Vector4D&
Subtracts the given other.
auto multiply(const Vector4D& other) -> Vector4D&
Multiplies the given other.
auto divide(const Vector4D& other) -> Vector4D&
Divides the given other. Returns [a/x , b/y , c/z , d/w] if [a , b , c , d] is divided by [x , y , z , w].
auto operator==(const Vector4D& other) -> bool
Equality operator.
auto operator!=(const Vector4D& other) -> bool
Inequality operator.
auto operator+=(const Vector4D& other) -> Vector4D&
Addition assignment operator.
auto operator-=(const Vector4D& other) -> Vector4D&
Subtraction assignment operator.
auto operator*=(const Vector4D& other) -> Vector4D&
Multiplication assignment operator.
auto operator/=(const Vector4D& other) -> Vector4D&
Division assignment operator.

Public variables

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

Friends

auto operator<<(std::ostream& stream, const Vector4D& vector) -> std::ostream&
Put to operator.
auto operator+(Vector4D left, const Vector4D& right) -> Vector4D&
Addition operator.
auto operator-(Vector4D left, const Vector4D& right) -> Vector4D&
Subtraction operator.
auto operator*(Vector4D left, const Vector4D& right) -> Vector4D&
Multiplication operator.
auto operator/(Vector4D left, const Vector4D& right) -> Vector4D&
Division operator.

Function documentation

RML::Vector4D::Vector4D(const float& x, const float& y, const float& z, const float& w)

Constructor.

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

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

Gets length of vector.

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

Vector4D& RML::Vector4D::toUnitVector()

Returns this vector as a modified unit vector.

Returns Unit vector pointing in the direction of this vector.

Vector4D RML::Vector4D::normaliseToRGBA()

Normalise color values to OpenGL supporting RGBA. Eg. (128, 128, 128, 255) => (0.5f, 0.5f, 0.5f, 1.0f)

Returns Color Vector4D with normalised values

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

Adds other.

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

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

Subtracts the given other.

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

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

Multiplies the given other.

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

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

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

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

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

Equality operator.

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

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

Inequality operator.

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

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

Addition assignment operator.

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

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

Subtraction assignment operator.

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

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

Multiplication assignment operator.

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

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

Division assignment operator.

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

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

Put to operator.

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

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

Addition operator.

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

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

Subtraction operator.

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

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

Multiplication operator.

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

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

Division operator.

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