Ginger 1.1.5; VERSION ${PROJECT_VERSION}
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
ginger::Vector2Ref Class Reference

Vector2Ref. More...

#include <vector2_ref.hpp>

Public Member Functions

constexpr Vector2Ref () noexcept
 Construct a new Vector2Ref object.
 
constexpr Vector2Ref (double &x, double &y) noexcept
 Construct a new Vector2Ref object.
 
constexpr auto x () const noexcept -> const double &
 
constexpr auto y () const noexcept -> const double &
 
constexpr auto dot (const Vector2Ref &other) const -> double
 
constexpr auto cross (const Vector2Ref &other) const -> double
 
Arithmetic operators

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

CONSTEXPR14 auto operator+= (const Vector2< double, double > &other) -> Vector2Ref &
 
CONSTEXPR14 auto operator-= (const Vector2< double, double > &other) -> Vector2Ref &
 
CONSTEXPR14 auto operator*= (const double &alpha) -> Vector2Ref &
 
CONSTEXPR14 auto operator/= (const double &alpha) -> Vector2Ref &
 
CONSTEXPR14 auto operator* (const double &alpha) const -> Vector2< double, double >
 

Public Attributes

double & _x
 
double & _y
 

Friends

template<class Stream >
auto operator<< (Stream &out, const Vector2Ref &vec) -> Stream &
 

Detailed Description

Vector2Ref.

Constructor & Destructor Documentation

◆ Vector2Ref() [1/2]

constexpr ginger::Vector2Ref::Vector2Ref ( )
inlineconstexprnoexcept

Construct a new Vector2Ref object.

The default constructor binds both components to a shared dummy variable.

◆ Vector2Ref() [2/2]

constexpr ginger::Vector2Ref::Vector2Ref ( double &  x,
double &  y 
)
inlineconstexprnoexcept

Construct a new Vector2Ref object.

The function constructs a new Vector2Ref object with given x and y values.

Parameters
[in]xThe parameter x is of type double&&, 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]yThe parameter "y" is the y-coordinate of the Vector2Ref object. It represents the vertical position of the vector in a 2D coordinate system.

Member Function Documentation

◆ cross()

constexpr auto ginger::Vector2Ref::cross ( const Vector2Ref other) const -> double
inlineconstexpr

The cross product of two 2D vectors is calculated by multiplying their x and y components and subtracting the result.

\( u \times v = u_x v_y - u_y v_x \)

Parameters
[in]otherThe parameter "other" is a reference to an object of type Vector2Ref.
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.

◆ dot()

constexpr auto ginger::Vector2Ref::dot ( const Vector2Ref other) const -> double
inlineconstexpr

The dot function calculates the dot product of two 2D vectors.

\( u \cdot v = u_x v_x + u_y v_y \)

Parameters
[in]otherThe parameter "other" is a reference to an object of type Vector2Ref.
Returns
The dot function is returning the dot product of two vectors, which is a scalar value of type double.

◆ operator*()

CONSTEXPR14 auto ginger::Vector2Ref::operator* ( const double &  alpha) const -> Vector2<double, double>
inline

The function multiplies the components of this Vector2Ref by a scalar value.

Parameters
[in]alphaThe scalar value to multiply each component by.
Returns
a Vector2 object.

◆ operator*=()

CONSTEXPR14 auto ginger::Vector2Ref::operator*= ( const double &  alpha) -> Vector2Ref&
inline

The function multiplies the x and y components of a Vector2Ref object by a given value.

Template Parameters
R
Parameters
[in]alphaalpha is a constant reference to a variable of type R.
Returns
The operator*= function returns a reference to the modified Vector2Ref object.

◆ operator+=()

CONSTEXPR14 auto ginger::Vector2Ref::operator+= ( const Vector2< double, double > &  other) -> Vector2Ref&
inline

The function operator+= adds the components of another Vector2 object to the current Vector2Ref object and returns a reference to the updated object.

Parameters
[in]otherThe parameter "other" is a reference to an object of type Vector2<double, double>.
Returns
a reference to a Vector2Ref object.

◆ operator-=()

CONSTEXPR14 auto ginger::Vector2Ref::operator-= ( const Vector2< double, double > &  other) -> Vector2Ref&
inline

The function subtracts the x and y components of another Vector2 object from the current Vector2Ref object.

Parameters
[in]otherThe parameter "other" is a reference to an object of type Vector2<double, double>.
Returns
a reference to a Vector2Ref object.

◆ operator/=()

CONSTEXPR14 auto ginger::Vector2Ref::operator/= ( const double &  alpha) -> Vector2Ref&
inline

The function divides the x and y components of a Vector2Ref object by a given value.

Template Parameters
R
Parameters
[in]alphaThe parameter "alpha" is of type R, which is a template parameter. It represents the value by which the x and y components of the Vector2Ref object are divided.
Returns
a reference to the current instance of the Vector2Ref class.

◆ x()

constexpr auto ginger::Vector2Ref::x ( ) const -> const double&
inlineconstexprnoexcept

The function returns a reference to a constant value of type double.

Returns
a reference to a constant object of type double.

◆ y()

constexpr auto ginger::Vector2Ref::y ( ) const -> const double&
inlineconstexprnoexcept

The function y() returns a reference to a constant value of type double.

Returns
a reference to a constant object of type double.

Friends And Related Symbol Documentation

◆ operator<<

template<class Stream >
auto operator<< ( Stream &  out,
const Vector2Ref vec 
) -> Stream&
friend

The above function overloads the << operator to output a Vector2Ref object in the format "{x, y}".

Template Parameters
Stream
Parameters
[out]outThe parameter "out" is a reference to a Stream object. It is used to output the contents of the Vector2Ref object to the stream.
[in]vecThe parameter vec is a constant reference to an object of type Vector2Ref.
Returns
The return type of the operator<< function is Stream&.

Member Data Documentation

◆ _x

double& ginger::Vector2Ref::_x

◆ _y

double& ginger::Vector2Ref::_y

The documentation for this class was generated from the following file: