cangine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cangine::Vector2 Struct Reference

Two-component floating-point vector. More...

#include <vector2.hpp>

Public Member Functions

constexpr Vector2 () noexcept=default
 Constructs a zero vector (x = y = 0).
 
constexpr Vector2 (float _x, float _y) noexcept
 Constructs a vector from explicit components.
 
constexpr Vector2 & operator+= (const Vector2 &rhs) noexcept
 Adds another vector component-wise.
 
constexpr Vector2 & operator-= (const Vector2 &rhs) noexcept
 Subtracts another vector component-wise.
 
constexpr Vector2 & operator*= (const Vector2 &rhs) noexcept
 Multiplies by another vector component-wise.
 
constexpr Vector2 & operator/= (const Vector2 &rhs) noexcept
 Divides by another vector component-wise.
 
constexpr Vector2 & operator+= (float rhs) noexcept
 Adds a scalar to both components.
 
constexpr Vector2 & operator-= (float rhs) noexcept
 Subtracts a scalar from both components.
 
constexpr Vector2 & operator*= (float rhs) noexcept
 Multiplies both components by a scalar.
 
constexpr Vector2 & operator/= (float rhs) noexcept
 Divides both components by a scalar.
 

Public Attributes

float x {}
 
float y {}
 Vector components.
 

Detailed Description

Two-component floating-point vector.

Provides component-wise arithmetic against both other vectors and scalars. All operations are constexpr and noexcept so the type can be used in compile-time contexts.

Constructor & Destructor Documentation

◆ Vector2() [1/2]

constexpr cangine::Vector2::Vector2 ( )
constexprdefaultnoexcept

Constructs a zero vector (x = y = 0).

◆ Vector2() [2/2]

constexpr cangine::Vector2::Vector2 ( float  _x,
float  _y 
)
inlineconstexprnoexcept

Constructs a vector from explicit components.

Parameters
_xValue for the x component.
_yValue for the y component.

Member Function Documentation

◆ operator*=() [1/2]

constexpr Vector2 & cangine::Vector2::operator*= ( const Vector2 &  rhs)
inlineconstexprnoexcept

Multiplies by another vector component-wise.

Parameters
rhsVector to multiply by.
Returns
Reference to this vector after multiplication.

◆ operator*=() [2/2]

constexpr Vector2 & cangine::Vector2::operator*= ( float  rhs)
inlineconstexprnoexcept

Multiplies both components by a scalar.

Parameters
rhsScalar to multiply by.
Returns
Reference to this vector after multiplication.

◆ operator+=() [1/2]

constexpr Vector2 & cangine::Vector2::operator+= ( const Vector2 &  rhs)
inlineconstexprnoexcept

Adds another vector component-wise.

Parameters
rhsVector to add.
Returns
Reference to this vector after addition.

◆ operator+=() [2/2]

constexpr Vector2 & cangine::Vector2::operator+= ( float  rhs)
inlineconstexprnoexcept

Adds a scalar to both components.

Parameters
rhsScalar to add.
Returns
Reference to this vector after addition.

◆ operator-=() [1/2]

constexpr Vector2 & cangine::Vector2::operator-= ( const Vector2 &  rhs)
inlineconstexprnoexcept

Subtracts another vector component-wise.

Parameters
rhsVector to subtract.
Returns
Reference to this vector after subtraction.

◆ operator-=() [2/2]

constexpr Vector2 & cangine::Vector2::operator-= ( float  rhs)
inlineconstexprnoexcept

Subtracts a scalar from both components.

Parameters
rhsScalar to subtract.
Returns
Reference to this vector after subtraction.

◆ operator/=() [1/2]

constexpr Vector2 & cangine::Vector2::operator/= ( const Vector2 &  rhs)
inlineconstexprnoexcept

Divides by another vector component-wise.

Parameters
rhsVector to divide by.
Returns
Reference to this vector after division.

◆ operator/=() [2/2]

constexpr Vector2 & cangine::Vector2::operator/= ( float  rhs)
inlineconstexprnoexcept

Divides both components by a scalar.

Parameters
rhsScalar to divide by.
Returns
Reference to this vector after division.

Member Data Documentation

◆ x

float cangine::Vector2::x {}

◆ y

float cangine::Vector2::y {}

Vector components.


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