DirectZ
Loading...
Searching...
No Matches
dz::color_vec< T, N > Struct Template Reference

#include <math.hpp>

Inheritance diagram for dz::color_vec< T, N >:
dz::vec< T, N >

Public Types

using Base = vec<T, N>

Public Member Functions

template<typename... Args>
 color_vec (Args &&... args)
template<typename OT, size_t ON>
 color_vec (const vec< OT, ON > &other)
 color_vec ()=default
 color_vec (const color_vec &)=default
color_vecoperator= (const color_vec &)=default
 color_vec (color_vec &&) noexcept=default
color_vecoperator= (color_vec &&) noexcept=default
vecoperator= (const vec &other)
 Assignment operator for component-wise copy.
template<typename O>
vecoperator+= (const O &other)
 Compound addition-assignment operator.
template<typename O>
vecoperator-= (const O &other)
 Compound subtraction-assignment operator.
template<typename O>
vecoperator*= (const O &other)
 Compound multiplication-assignment operator.
template<typename O>
vecoperator/= (const O &other)
 Compound division-assignment operator.
template<typename O>
vec operator+ (const O &other) const
 Addition operator returning a new vector.
template<typename O>
vec operator- (const O &other) const
 Subtraction operator returning a new vector.
vec operator- () const
 Unary negation operator.
template<typename O>
vec operator* (const O &other) const
 Multiplication operator returning a new vector.
template<typename O>
vec operator/ (const O &other) const
 Division operator returning a new vector.
Toperator[] (size_t i)
 Index operator for non-const access to vector components.
const Toperator[] (size_t i) const
 Index operator for const access to vector components.
T length () const
 Computes the Euclidean length (magnitude) of the vector.
vec normalize () const
 Returns a normalized (unit length) copy of the vector.
Public Member Functions inherited from dz::vec< T, N >
template<typename... Args>
 vec (Args... args)
 Variadic constructor to initialize vector components.
template<typename OT, size_t ON>
 vec (const vec< OT, ON > &other)
 Copy constructor to convert from vectors of different types and/or sizes.
vecoperator= (const vec &other)
 Assignment operator for component-wise copy.
Toperator[] (size_t i)
 Index operator for non-const access to vector components.
const Toperator[] (size_t i) const
 Index operator for const access to vector components.
template<typename O>
vecoperator*= (const O &other)
 Compound multiplication-assignment operator.
template<typename O>
vecoperator/= (const O &other)
 Compound division-assignment operator.
template<typename O>
vecoperator+= (const O &other)
 Compound addition-assignment operator.
template<typename O>
vecoperator-= (const O &other)
 Compound subtraction-assignment operator.
template<typename O>
vec operator* (const O &other) const
 Multiplication operator returning a new vector.
template<typename O>
vec operator/ (const O &other) const
 Division operator returning a new vector.
template<typename O>
vec operator+ (const O &other) const
 Addition operator returning a new vector.
template<typename O>
vec operator- (const O &other) const
 Subtraction operator returning a new vector.
vec operator- () const
 Unary negation operator.
T length () const
 Computes the Euclidean length (magnitude) of the vector.
vec normalize () const
 Returns a normalized (unit length) copy of the vector.

Public Attributes

T data [N]
 Underlying array storing vector components.
Public Attributes inherited from dz::vec< T, N >
T data [N]
 Underlying array storing vector components.

Member Typedef Documentation

◆ Base

template<typename T, size_t N>
using dz::color_vec< T, N >::Base = vec<T, N>

Constructor & Destructor Documentation

◆ color_vec() [1/5]

template<typename T, size_t N>
template<typename... Args>
dz::color_vec< T, N >::color_vec ( Args &&... args)
inline

◆ color_vec() [2/5]

template<typename T, size_t N>
template<typename OT, size_t ON>
dz::color_vec< T, N >::color_vec ( const vec< OT, ON > & other)
inline

◆ color_vec() [3/5]

template<typename T, size_t N>
dz::color_vec< T, N >::color_vec ( )
default

◆ color_vec() [4/5]

template<typename T, size_t N>
dz::color_vec< T, N >::color_vec ( const color_vec< T, N > & )
default

◆ color_vec() [5/5]

template<typename T, size_t N>
dz::color_vec< T, N >::color_vec ( color_vec< T, N > && )
defaultnoexcept

Member Function Documentation

◆ length()

template<typename T, size_t N>
T dz::vec< T, N >::length ( ) const
inline

Computes the Euclidean length (magnitude) of the vector.

Calculates the square root of the sum of squares of all components.

Returns
The length of the vector as type T.

◆ normalize()

template<typename T, size_t N>
vec dz::vec< T, N >::normalize ( ) const
inline

Returns a normalized (unit length) copy of the vector.

Divides all components by the vector length.

Returns
A new vector normalized to length 1.

◆ operator*()

template<typename T, size_t N>
template<typename O>
vec dz::vec< T, N >::operator* ( const O & other) const
inline

Multiplication operator returning a new vector.

Supports multiplication by a scalar or component-wise multiplication by another vector.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to multiply by.
Returns
A new vector resulting from the multiplication.

◆ operator*=()

template<typename T, size_t N>
template<typename O>
vec & dz::vec< T, N >::operator*= ( const O & other)
inline

Compound multiplication-assignment operator.

Supports multiplication by a scalar or component-wise multiplication by another vector. Throws std::runtime_error if the operand type is unsupported.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to multiply by.
Returns
Reference to this vector after multiplication.
Exceptions
std::runtime_errorif unsupported operand type is used.

◆ operator+()

template<typename T, size_t N>
template<typename O>
vec dz::vec< T, N >::operator+ ( const O & other) const
inline

Addition operator returning a new vector.

Supports addition by a scalar or component-wise addition by another vector.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to add.
Returns
A new vector resulting from the addition.

◆ operator+=()

template<typename T, size_t N>
template<typename O>
vec & dz::vec< T, N >::operator+= ( const O & other)
inline

Compound addition-assignment operator.

Supports addition by a scalar or component-wise addition by another vector. Throws std::runtime_error if the operand type is unsupported.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to add.
Returns
Reference to this vector after addition.
Exceptions
std::runtime_errorif unsupported operand type is used.

◆ operator-() [1/2]

template<typename T, size_t N>
vec dz::vec< T, N >::operator- ( ) const
inline

Unary negation operator.

Returns a new vector with all components negated.

Returns
A new vector with negated components.

◆ operator-() [2/2]

template<typename T, size_t N>
template<typename O>
vec dz::vec< T, N >::operator- ( const O & other) const
inline

Subtraction operator returning a new vector.

Supports subtraction by a scalar or component-wise subtraction by another vector.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to subtract.
Returns
A new vector resulting from the subtraction.

◆ operator-=()

template<typename T, size_t N>
template<typename O>
vec & dz::vec< T, N >::operator-= ( const O & other)
inline

Compound subtraction-assignment operator.

Supports subtraction by a scalar or component-wise subtraction by another vector. Throws std::runtime_error if the operand type is unsupported.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to subtract.
Returns
Reference to this vector after subtraction.
Exceptions
std::runtime_errorif unsupported operand type is used.

◆ operator/()

template<typename T, size_t N>
template<typename O>
vec dz::vec< T, N >::operator/ ( const O & other) const
inline

Division operator returning a new vector.

Supports division by a scalar or component-wise division by another vector.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to divide by.
Returns
A new vector resulting from the division.

◆ operator/=()

template<typename T, size_t N>
template<typename O>
vec & dz::vec< T, N >::operator/= ( const O & other)
inline

Compound division-assignment operator.

Supports division by a scalar or component-wise division by another vector. Throws std::runtime_error if the operand type is unsupported.

Template Parameters
OOperand type (scalar T or vec<T, N>).
Parameters
otherThe scalar or vector to divide by.
Returns
Reference to this vector after division.
Exceptions
std::runtime_errorif unsupported operand type is used.

◆ operator=() [1/3]

template<typename T, size_t N>
color_vec & dz::color_vec< T, N >::operator= ( color_vec< T, N > && )
defaultnoexcept

◆ operator=() [2/3]

template<typename T, size_t N>
color_vec & dz::color_vec< T, N >::operator= ( const color_vec< T, N > & )
default

◆ operator=() [3/3]

template<typename T, size_t N>
vec & dz::vec< T, N >::operator= ( const vec & other)
inline

Assignment operator for component-wise copy.

Copies all components from the other vector using memcpy for efficiency.

Parameters
otherThe vector to copy from.
Returns
Reference to this vector after assignment.

◆ operator[]() [1/2]

template<typename T, size_t N>
T & dz::vec< T, N >::operator[] ( size_t i)
inline

Index operator for non-const access to vector components.

No bounds checking is performed.

Parameters
iThe component index to access.
Returns
Reference to the component at index i.

◆ operator[]() [2/2]

template<typename T, size_t N>
const T & dz::vec< T, N >::operator[] ( size_t i) const
inline

Index operator for const access to vector components.

No bounds checking is performed.

Parameters
iThe component index to access.
Returns
Const reference to the component at index i.

Member Data Documentation

◆ data

template<typename T, size_t N>
T dz::vec< T, N >::data[N]

Underlying array storing vector components.


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