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

Three-component floating-point vector. More...

#include <vector3.hpp>

Public Member Functions

constexpr Vector3 () noexcept=default
 Constructs a zero vector (x = y = z = 0).
 
constexpr Vector3 (float _x, float _y, float _z) noexcept
 Constructs a vector from explicit components.
 
constexpr Vector3 (const Vector2 &xy, float _z) noexcept
 Constructs a vector from a 2D vector and an explicit z.
 
constexpr Vector3 (const Vector2 &xy) noexcept
 Constructs a vector from a 2D vector with z defaulting to 0.
 
constexpr Vector3 & operator+= (const Vector3 &rhs) noexcept
 Adds another vector component-wise.
 
constexpr Vector3 & operator-= (const Vector3 &rhs) noexcept
 Subtracts another vector component-wise.
 
constexpr Vector3 & operator*= (const Vector3 &rhs) noexcept
 Multiplies by another vector component-wise.
 
constexpr Vector3 & operator/= (const Vector3 &rhs) noexcept
 Divides by another vector component-wise.
 
constexpr Vector3 & operator+= (float rhs) noexcept
 Adds a scalar to all components.
 
constexpr Vector3 & operator-= (float rhs) noexcept
 Subtracts a scalar from all components.
 
constexpr Vector3 & operator*= (float rhs) noexcept
 Multiplies all components by a scalar.
 
constexpr Vector3 & operator/= (float rhs) noexcept
 Divides all components by a scalar.
 

Public Attributes

float x {}
 
float y {}
 
float z {}
 Vector components.
 

Detailed Description

Three-component floating-point vector.

Provides component-wise arithmetic against both other vectors and scalars, plus implicit construction from a Vector2. All operations are constexpr and noexcept.

Constructor & Destructor Documentation

◆ Vector3() [1/4]

constexpr cangine::Vector3::Vector3 ( )
constexprdefaultnoexcept

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

◆ Vector3() [2/4]

constexpr cangine::Vector3::Vector3 ( float  _x,
float  _y,
float  _z 
)
inlineconstexprnoexcept

Constructs a vector from explicit components.

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

◆ Vector3() [3/4]

constexpr cangine::Vector3::Vector3 ( const Vector2 &  xy,
float  _z 
)
inlineconstexprnoexcept

Constructs a vector from a 2D vector and an explicit z.

Parameters
xySource for the x and y components.
_zValue for the z component.

◆ Vector3() [4/4]

constexpr cangine::Vector3::Vector3 ( const Vector2 &  xy)
inlineconstexprnoexcept

Constructs a vector from a 2D vector with z defaulting to 0.

Parameters
xySource for the x and y components.

Member Function Documentation

◆ operator*=() [1/2]

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

Multiplies by another vector component-wise.

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

◆ operator*=() [2/2]

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

Multiplies all components by a scalar.

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

◆ operator+=() [1/2]

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

Adds another vector component-wise.

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

◆ operator+=() [2/2]

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

Adds a scalar to all components.

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

◆ operator-=() [1/2]

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

Subtracts another vector component-wise.

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

◆ operator-=() [2/2]

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

Subtracts a scalar from all components.

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

◆ operator/=() [1/2]

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

Divides by another vector component-wise.

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

◆ operator/=() [2/2]

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

Divides all components by a scalar.

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

Member Data Documentation

◆ x

float cangine::Vector3::x {}

◆ y

float cangine::Vector3::y {}

◆ z

float cangine::Vector3::z {}

Vector components.


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