|
| constexpr | Vector2 (T1 vec_x, T2 vec_y) noexcept |
| | Construct a new Vector2 object.
|
| |
| template<typename U1 , typename U2 > |
| constexpr | Vector2 (const Vector2< U1, U2 > &other_vector) |
| | Construct a new Vector2 object.
|
| |
| constexpr auto | x () const noexcept -> const T1 & |
| | Returns a const reference to the x-coordinate of the vector.
|
| |
| constexpr auto | y () const noexcept -> const T2 & |
| | Returns a const reference to the y-coordinate of the vector.
|
| |
| template<typename U1 , typename U2 > |
| constexpr auto | cross (const Vector2< U1, U2 > &other_vector) const |
| | Calculates the cross product of two Vector2 objects.
|
| |
|
definie ==, !=, <, >, <=, >=.
|
| template<typename U1 , typename U2 > |
| constexpr auto | operator== (const Vector2< U1, U2 > &other_vector) const -> bool |
| | Compares two Vector2 objects for equality.
|
| |
| template<typename U1 , typename U2 > |
| constexpr auto | operator!= (const Vector2< U1, U2 > &other_vector) const -> bool |
| | Compares two Vector2 objects for inequality.
|
| |
|
definie +, -, *, /, +=, -=, *=, /=, etc.
|
| constexpr auto | operator- () const -> Vector2 |
| | Negate the vector, returning a new vector with the negated components.
|
| |
| template<typename U1 , typename U2 > |
| CONSTEXPR14 auto | operator+= (const Vector2< U1, U2 > &other_vector) -> Vector2 & |
| | Add the components of the given vector to this vector.
|
| |
| template<typename U1 , typename U2 > |
| CONSTEXPR14 auto | operator-= (const Vector2< U1, U2 > &other_vector) -> Vector2 & |
| | Subtract the components of the given vector from this vector.
|
| |
| template<typename R > |
| CONSTEXPR14 auto | operator*= (const R &scalar) -> Vector2 & |
| | Multiply the components of this vector by the given scalar.
|
| |
| template<typename R > |
| CONSTEXPR14 auto | operator/= (const R &scalar) -> Vector2 & |
| | Divide the components of this vector by the given scalar.
|
| |
| template<typename U1 , typename U2 > |
| constexpr auto | operator+ (Vector2 right_vector, const Vector2< U1, U2 > &left_vector) -> Vector2 |
| | Add the components of the given vector to this vector.
|
| |
| template<typename U1 , typename U2 > |
| constexpr auto | operator- (Vector2 right_vector, const Vector2< U1, U2 > &left_vector) -> Vector2 |
| | Subtract the components of the given vector from this vector.
|
| |
| template<typename R > |
| constexpr auto | operator* (Vector2 right_vector, const R &scalar) -> Vector2 |
| | Multiply the components of this vector by the given scalar.
|
| |
| template<typename R > |
| constexpr auto | operator* (const R &scalar, Vector2 left_vector) -> Vector2 |
| | Multiply the components of the given vector by the scalar.
|
| |
| template<typename R > |
| constexpr auto | operator/ (Vector2 right_vector, const R &scalar) -> Vector2 |
| | Divide the components of this vector by the given scalar.
|
| |
template<typename T1, typename T2 = T1>
class recti::Vector2< T1, T2 >
2D vector template class.
Represents a 2-dimensional vector with x and y components. Supports arithmetic operations (addition, subtraction, scaling, cross product) and comparison operators.
- Template Parameters
-
| T1 | Type of the x-component. |
| T2 | Type of the y-component (defaults to T1). |
template<typename T1 , typename T2 = T1>
Construct a new Vector2 object.
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.
- Parameters
-
| [in] | vec_x | The x-coordinate of the vector. |
| [in] | vec_y | The y-coordinate of the vector. |
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
Construct a new Vector2 object.
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 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
-
| [in] | other_vector | The other Vector2 object to copy from. |
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
Calculates the cross product of two Vector2 objects.
This function computes the cross product of the current Vector2 object and the provided Vector2 object other_vector. 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 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
-
| [in] | other_vector | The other Vector2 object to compute the cross product with. |
- Returns
- constexpr auto The cross product of the two
Vector2 objects.
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
| constexpr auto recti::Vector2< T1, T2 >::operator!= |
( |
const Vector2< U1, U2 > & |
other_vector | ) |
const -> bool |
|
inlineconstexpr |
Compares two Vector2 objects for inequality.
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_vector. The comparison is done using std::tie to compare the individual coordinates.
- 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
-
| [in] | other_vector | The other Vector2 object to compare against. |
- Returns
- true If the two
Vector2 objects have different x or y coordinates.
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
| constexpr auto recti::Vector2< T1, T2 >::operator== |
( |
const Vector2< U1, U2 > & |
other_vector | ) |
const -> bool |
|
inlineconstexpr |
Compares two Vector2 objects for equality.
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_vector. The comparison is done using std::tie to compare the individual coordinates.
- 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
-
| [in] | other_vector | The other Vector2 object to compare against. |
- Returns
- true If the two
Vector2 objects have the same x and y coordinates.