template<typename T1, typename T2 = T1>
recti::Vector2 class

vector2

Constructors, destructors, conversion operators

Vector2(T1&& vec_x, T2&& vec_y) constexpr noexcept
Construct a new Vector2 object.
Vector2(const T1& vec_x, const T2& vec_y) constexpr
Construct a new Vector2 object.
template<typename U1, typename U2>
Vector2(const Vector2<U1, U2>& other) explicit constexpr
Construct a new Vector2 object.

Public functions

auto x() const noexcept -> const T1 & -> auto constexpr
Returns a const reference to the x-coordinate of the vector.
auto y() const noexcept -> const T2 & -> auto constexpr
Returns a const reference to the y-coordinate of the vector.
template<typename U1, typename U2>
auto cross(const Vector2<U1, U2>& other) const -> auto constexpr
Calculates the cross product of two Vector2 objects.

Comparison operators

definie ==, !=, <, >, <=, >=.

template<typename U1, typename U2>
auto operator==(const Vector2<U1, U2>& other) const -> bool -> auto constexpr
Compares two Vector2 objects for equality.
template<typename U1, typename U2>
auto operator!=(const Vector2<U1, U2>& other) const -> bool -> auto constexpr
Compares two Vector2 objects for inequality.

Arithmetic operators

definie +, -, *, /, +=, -=, *=, /=, etc.

auto operator-() const -> Vector2 -> auto constexpr
Negate the vector, returning a new vector with the negated components.
template<typename U1, typename U2>
auto operator+=(const Vector2<U1, U2>& other) -> Vector2 & -> CONSTEXPR14 auto
Add the components of the given vector to this vector.
template<typename U1, typename U2>
auto operator-=(const Vector2<U1, U2>& other) -> Vector2 & -> CONSTEXPR14 auto
Subtract the components of the given vector from this vector.
template<typename R>
auto operator*=(const R& alpha) -> Vector2 & -> CONSTEXPR14 auto
Multiply the components of this vector by the given scalar.
template<typename R>
auto operator/=(const R& alpha) -> Vector2 & -> CONSTEXPR14 auto
Divide the components of this vector by the given scalar.
template<typename U1, typename U2>
auto operator+(Vector2 rhs, const Vector2<U1, U2>& lhs) -> Vector2 -> friend auto constexpr
Add the components of the given vector to this vector.
template<typename U1, typename U2>
auto operator-(Vector2 rhs, const Vector2<U1, U2>& lhs) -> Vector2 -> friend auto constexpr
Subtract the components of the given vector from this vector.
template<typename R>
auto operator*(Vector2 rhs, const R& alpha) -> Vector2 -> friend auto constexpr
Multiply the components of this vector by the given scalar.
template<typename R>
auto operator*(const R& alpha, Vector2 lhs) -> Vector2 -> friend auto constexpr
Multiply the components of the given vector by the scalar.
template<typename R>
auto operator/(Vector2 rhs, const R& alpha) -> Vector2 -> friend auto constexpr
Divide the components of this vector by the given scalar.

Friends

template<class Stream>
auto operator<<(Stream& out, const Vector2& vec2) -> Stream & -> auto
Overload the stream insertion operator to print a Vector2 object.

Function documentation

template<typename T1, typename T2>
recti::Vector2<T1, T2>::Vector2(T1&& vec_x, T2&& vec_y) constexpr noexcept

Construct a new Vector2 object.

Parameters
vec_x in The x-coordinate of the vector.
vec_y in The y-coordinate of the vector.

This is a constructor for the Vector2 class. It takes two parameters vec_x and vec_y, both of which are rvalue references (T1&& and T2&&). The constructor is marked as constexpr, meaning it can be evaluated at compile-time. The constructor is also marked as noexcept, indicating that it does not throw any exceptions.

template<typename T1, typename T2>
recti::Vector2<T1, T2>::Vector2(const T1& vec_x, const T2& vec_y) constexpr

Construct a new Vector2 object.

Parameters
vec_x in The x-coordinate of the vector.
vec_y in The y-coordinate of the vector.

This is a constructor for the Vector2 class. It takes two parameters vec_x and vec_y, both of which are const references (const T1& and const T2&). The constructor is marked as constexpr, meaning it can be evaluated at compile-time.

template<typename T1, typename T2> template<typename U1, typename U2>
recti::Vector2<T1, T2>::Vector2(const Vector2<U1, U2>& other) explicit constexpr

Construct a new Vector2 object.

Template parameters
U1 The type of the x-coordinate of the other Vector2 object.
U2 The type of the y-coordinate of the other Vector2 object.
Parameters
other in The other Vector2 object to copy from.

This is a constructor for the Vector2 class. It takes a Vector2 object of a different type (U1 and U2) and initializes the current Vector2 object with the x and y coordinates of the other Vector2 object. This constructor is marked as constexpr, meaning it can be evaluated at compile-time.

template<typename T1, typename T2>
auto recti::Vector2<T1, T2>::x() const noexcept -> const T1 & constexpr

Returns a const reference to the x-coordinate of the vector.

Returns constexpr const T1& A const reference to the x-coordinate of the vector.

This function provides read-only access to the x-coordinate of the Vector2 object.

template<typename T1, typename T2>
auto recti::Vector2<T1, T2>::y() const noexcept -> const T2 & constexpr

Returns a const reference to the y-coordinate of the vector.

Returns constexpr const T1& A const reference to the y-coordinate of the vector.

This function provides read-only access to the y-coordinate of the Vector2 object.

template<typename T1, typename T2> template<typename U1, typename U2>
auto recti::Vector2<T1, T2>::cross(const Vector2<U1, U2>& other) const constexpr

Calculates the cross product of two Vector2 objects.

Template parameters
U1 The type of the x-coordinate of the other Vector2 object.
U2 The type of the y-coordinate of the other Vector2 object.
Parameters
other in The other Vector2 object to compute the cross product with.
Returns constexpr auto The cross product of the two Vector2 objects.

This function computes the cross product of the current Vector2 object and the provided Vector2 object other. The cross product of two 2D vectors is a scalar value that represents the signed area of the parallelogram formed by the two vectors.

template<typename T1, typename T2> template<typename U1, typename U2>
auto recti::Vector2<T1, T2>::operator==(const Vector2<U1, U2>& other) const -> bool constexpr

Compares two Vector2 objects for equality.

Template parameters
U1 The type of the x-coordinate of the other Vector2 object.
U2 The type of the y-coordinate of the other Vector2 object.
Parameters
other in The other Vector2 object to compare against.
Returns true If the two Vector2 objects have the same x and y coordinates.

This operator compares the x and y coordinates of the current Vector2 object with the x and y coordinates of the provided Vector2 object other. The comparison is done using std::tie to compare the individual coordinates.

template<typename T1, typename T2> template<typename U1, typename U2>
auto recti::Vector2<T1, T2>::operator!=(const Vector2<U1, U2>& other) const -> bool constexpr

Compares two Vector2 objects for inequality.

Template parameters
U1 The type of the x-coordinate of the other Vector2 object.
U2 The type of the y-coordinate of the other Vector2 object.
Parameters
other in The other Vector2 object to compare against.
Returns true If the two Vector2 objects have different x or y coordinates.

This operator compares the x and y coordinates of the current Vector2 object with the x and y coordinates of the provided Vector2 object other. The comparison is done using std::tie to compare the individual coordinates.

template<typename T1, typename T2>
auto recti::Vector2<T1, T2>::operator-() const -> Vector2 constexpr

Negate the vector, returning a new vector with the negated components.

Returns A new vector with the negated x and y components.

template<typename T1, typename T2> template<typename U1, typename U2>
CONSTEXPR14 auto recti::Vector2<T1, T2>::operator+=(const Vector2<U1, U2>& other) -> Vector2 &

Add the components of the given vector to this vector.

Template parameters
U1 The type of the x component of the other vector.
U2 The type of the y component of the other vector.
Parameters
other in The vector to add to this vector.
Returns A reference to this vector, after the addition.

template<typename T1, typename T2> template<typename U1, typename U2>
CONSTEXPR14 auto recti::Vector2<T1, T2>::operator-=(const Vector2<U1, U2>& other) -> Vector2 &

Subtract the components of the given vector from this vector.

Template parameters
U1 The type of the x component of the other vector.
U2 The type of the y component of the other vector.
Parameters
other in The vector to subtract from this vector.
Returns A reference to this vector, after the subtraction.

template<typename T1, typename T2> template<typename R>
CONSTEXPR14 auto recti::Vector2<T1, T2>::operator*=(const R& alpha) -> Vector2 &

Multiply the components of this vector by the given scalar.

Template parameters
R The type of the scalar to multiply by.
Parameters
alpha in The scalar to multiply the vector components by.
Returns A reference to this vector, after the multiplication.

template<typename T1, typename T2> template<typename R>
CONSTEXPR14 auto recti::Vector2<T1, T2>::operator/=(const R& alpha) -> Vector2 &

Divide the components of this vector by the given scalar.

Template parameters
R The type of the scalar to divide by.
Parameters
alpha in The scalar to divide the vector components by.
Returns A reference to this vector, after the division.

template<typename T1, typename T2> template<typename U1, typename U2>
friend auto recti::Vector2<T1, T2>::operator+(Vector2 rhs, const Vector2<U1, U2>& lhs) -> Vector2 constexpr

Add the components of the given vector to this vector.

Template parameters
U1 The type of the x component of the other vector.
U2 The type of the y component of the other vector.
Parameters
rhs in The vector to add to this vector.
lhs in The vector to add to the right-hand side vector.
Returns A new vector that is the sum of the two input vectors.

template<typename T1, typename T2> template<typename U1, typename U2>
friend auto recti::Vector2<T1, T2>::operator-(Vector2 rhs, const Vector2<U1, U2>& lhs) -> Vector2 constexpr

Subtract the components of the given vector from this vector.

Template parameters
U1 The type of the x component of the other vector.
U2 The type of the y component of the other vector.
Parameters
rhs in The vector to subtract from this vector.
lhs in The vector to subtract the right-hand side vector from.
Returns A new vector that is the difference of the two input vectors.

template<typename T1, typename T2> template<typename R>
friend auto recti::Vector2<T1, T2>::operator*(Vector2 rhs, const R& alpha) -> Vector2 constexpr

Multiply the components of this vector by the given scalar.

Template parameters
R The type of the scalar to multiply by.
Parameters
rhs in The vector to multiply.
alpha in The scalar to multiply the vector components by.
Returns A new vector that is the result of multiplying the input vector by the scalar.

template<typename T1, typename T2> template<typename R>
friend auto recti::Vector2<T1, T2>::operator*(const R& alpha, Vector2 lhs) -> Vector2 constexpr

Multiply the components of the given vector by the scalar.

Template parameters
R The type of the scalar to multiply by.
Parameters
alpha in The scalar to multiply the vector components by.
lhs in The vector to multiply.
Returns A new vector that is the result of multiplying the input vector by the scalar.

template<typename T1, typename T2> template<typename R>
friend auto recti::Vector2<T1, T2>::operator/(Vector2 rhs, const R& alpha) -> Vector2 constexpr

Divide the components of this vector by the given scalar.

Template parameters
R The type of the scalar to divide by.
Parameters
rhs in The vector to divide.
alpha in The scalar to divide the vector components by.
Returns A new vector that is the result of dividing the input vector by the scalar.

template<typename T1, typename T2> template<class Stream>
auto operator<<(Stream& out, const Vector2& vec2) -> Stream &

Overload the stream insertion operator to print a Vector2 object.

Template parameters
Stream The stream type to insert the Vector2 into.
Parameters
out out The output stream to insert the Vector2 into.
vec2 in The Vector2 object to insert into the stream.
Returns Stream& The modified output stream.