|
| constexpr | Vector2 () |
| | Construct a new Vector2 object.
|
| |
| constexpr | Vector2 (T1 x, T2 y) noexcept |
| | Construct a new Vector2 object.
|
| |
| template<typename U1 , typename U2 > |
| constexpr | Vector2 (const Vector2< U1, U2 > &other) |
| | Construct a new Vector2 object.
|
| |
| constexpr auto | x () const noexcept -> const T1 & |
| |
| constexpr auto | y () const noexcept -> const T2 & |
| |
| template<typename U1 , typename U2 > |
| constexpr auto | dot (const Vector2< U1, U2 > &other) const -> double |
| |
| template<typename U1 , typename U2 > |
| constexpr auto | cross (const Vector2< U1, U2 > &other) const -> double |
| |
|
definie +, -, *, /, +=, -=, *=, /=, etc.
|
| constexpr auto | operator- () const -> Vector2< T1, T2 > |
| |
| template<typename U1 , typename U2 > |
| auto | operator+= (const Vector2< U1, U2 > &other) -> Vector2< T1, T2 > & |
| |
| template<typename U1 , typename U2 > |
| auto | operator-= (const Vector2< U1, U2 > &other) -> Vector2< T1, T2 > & |
| |
| template<typename R > |
| auto | operator*= (const R &alpha) -> Vector2< T1, T2 > & |
| |
| template<typename R > |
| auto | operator/= (const R &alpha) -> Vector2< T1, T2 > & |
| |
| template<typename U1 , typename U2 > |
| constexpr auto | operator+ (Vector2< T1, T2 > x, const Vector2< U1, U2 > &y) -> Vector2< T1, T2 > |
| |
| template<typename U1 , typename U2 > |
| constexpr auto | operator- (Vector2< T1, T2 > x, const Vector2< U1, U2 > &y) -> Vector2< T1, T2 > |
| |
| template<typename R > |
| constexpr auto | operator* (Vector2< T1, T2 > x, const R &alpha) -> Vector2< T1, T2 > |
| |
| template<typename R > |
| constexpr auto | operator* (const R &alpha, Vector2< T1, T2 > x) -> Vector2< T1, T2 > |
| |
| template<typename R > |
| constexpr auto | operator/ (Vector2< T1, T2 > x, const R &alpha) -> Vector2< T1, T2 > |
| |
template<typename T1, typename T2 = T1>
class ginger::Vector2< T1, T2 >
Vector2.
A template class representing a 2D vector with x and y components.
- Template Parameters
-
| T1 | The type of the x component |
| T2 | The type of the y component (defaults to T1) |
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
Construct a new Vector2 object.
The function constructs a new Vector2 object with given x and y values.
- Parameters
-
| [in] | x | The parameter x is of type T1&&, which means it is a forwarding reference. It can accept any type, and it is passed as an rvalue reference. This allows the constructor to efficiently move or forward the value of x into the _x member variable. |
| [in] | y | The parameter "y" is the y-coordinate of the Vector2 object. It represents the vertical position of the vector in a 2D coordinate system. |
Construct a new Vector2 object This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
| [in] | other | The parameter "other" is a reference to another Vector2 object. |
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
The cross product of two 2D vectors (scalar, z-component):
\[
u \times v = u_x v_y - u_y v_x
\]
- Template Parameters
-
- Parameters
-
| [in] | other | The parameter "other" is a reference to an object of type Vector2<U1, U2>. |
- Returns
- The function
cross returns the result of the cross product between the current vector and the other vector. The result is of type double.
template<typename T1 , typename T2 = T1>
template<typename U1 , typename U2 >
The dot function calculates the dot product of two 2D vectors:
\[
u \cdot v = u_x v_x + u_y v_y
\]
- Template Parameters
-
- Parameters
-
| [in] | other | The parameter "other" is a reference to an object of type Vector2<U1, U2>. |
- Returns
- The
dot function is returning the dot product of two vectors, which is a scalar value of type double.