guillaume 1.0.0
Guillaume is a component-based UI framework library built around a primitive rendering system. It's designed for building user interfaces across XR platforms and traditional platforms with custom rendering backends and input handling. The framework is lightweight, flexible, and easy to integrate into existing projects.
Loading...
Searching...
No Matches
Vector< Type, Dimension > Class Template Reference

A generic N-dimensional vector class template. More...

#include <vector.hpp>

Public Member Functions

 Vector ()
 Default constructor - initializes all components to zero.
 
 Vector (std::initializer_list< Type > values)
 Constructor from initializer list.
 
Type & operator[] (size_t index)
 Non-const element access operator.
 
const Type & operator[] (size_t index) const
 Const element access operator.
 
Vector operator+ (const Vector &other) const
 Vector addition operator.
 
Vector operator- (const Vector &other) const
 Vector subtraction operator.
 
Vector operator* (Type scalar) const
 Scalar multiplication operator.
 
Type dot (const Vector &other) const
 Compute dot product with another vector.
 
Type magnitude () const
 Calculate the magnitude (length) of the vector.
 
Vector normalize () const
 Create a normalized (unit) vector.
 
constexpr size_t size () const
 Get the number of dimensions/components.
 

Detailed Description

template<typename Type, size_t Dimension>
class Vector< Type, Dimension >

A generic N-dimensional vector class template.

This class provides a mathematical vector implementation with support for basic vector operations including addition, subtraction, scalar multiplication, dot product, magnitude calculation, and normalization.

Template Parameters
TypeThe numeric type of vector components (e.g., float, double, int)
DimensionThe number of dimensions/components in the vector

Definition at line 39 of file vector.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/2]

template<typename Type , size_t Dimension>
Vector< Type, Dimension >::Vector ( )
inline

Default constructor - initializes all components to zero.

Definition at line 47 of file vector.hpp.

◆ Vector() [2/2]

template<typename Type , size_t Dimension>
Vector< Type, Dimension >::Vector ( std::initializer_list< Type >  values)
inline

Constructor from initializer list.

Initializes vector components from the provided values. If fewer values are provided than the dimension, remaining components are zero-initialized. Extra values beyond the dimension are ignored.

Parameters
valuesInitializer list of component values

Definition at line 58 of file vector.hpp.

Member Function Documentation

◆ dot()

template<typename Type , size_t Dimension>
Type Vector< Type, Dimension >::dot ( const Vector< Type, Dimension > &  other) const
inline

Compute dot product with another vector.

Parameters
otherThe vector to compute the dot product with
Returns
The dot product (scalar) result

Definition at line 132 of file vector.hpp.

Here is the caller graph for this function:

◆ magnitude()

template<typename Type , size_t Dimension>
Type Vector< Type, Dimension >::magnitude ( ) const
inline

Calculate the magnitude (length) of the vector.

Returns
The Euclidean magnitude of the vector

Definition at line 145 of file vector.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

template<typename Type , size_t Dimension>
Vector Vector< Type, Dimension >::normalize ( ) const
inline

Create a normalized (unit) vector.

Returns a vector with the same direction but magnitude of 1. If the vector has zero magnitude, returns the original vector unchanged.

Returns
A new normalized vector

Definition at line 155 of file vector.hpp.

Here is the call graph for this function:

◆ operator*()

template<typename Type , size_t Dimension>
Vector Vector< Type, Dimension >::operator* ( Type  scalar) const
inline

Scalar multiplication operator.

Parameters
scalarThe scalar value to multiply each component by
Returns
A new vector with all components scaled by the scalar

Definition at line 118 of file vector.hpp.

◆ operator+()

template<typename Type , size_t Dimension>
Vector Vector< Type, Dimension >::operator+ ( const Vector< Type, Dimension > &  other) const
inline

Vector addition operator.

Parameters
otherThe vector to add to this vector
Returns
A new vector containing the component-wise sum

Definition at line 90 of file vector.hpp.

◆ operator-()

template<typename Type , size_t Dimension>
Vector Vector< Type, Dimension >::operator- ( const Vector< Type, Dimension > &  other) const
inline

Vector subtraction operator.

Parameters
otherThe vector to subtract from this vector
Returns
A new vector containing the component-wise difference

Definition at line 104 of file vector.hpp.

◆ operator[]() [1/2]

template<typename Type , size_t Dimension>
Type & Vector< Type, Dimension >::operator[] ( size_t  index)
inline

Non-const element access operator.

Parameters
indexThe index of the component to access
Returns
Reference to the component at the specified index

Definition at line 73 of file vector.hpp.

◆ operator[]() [2/2]

template<typename Type , size_t Dimension>
const Type & Vector< Type, Dimension >::operator[] ( size_t  index) const
inline

Const element access operator.

Parameters
indexThe index of the component to access
Returns
Const reference to the component at the specified index

Definition at line 81 of file vector.hpp.

◆ size()

template<typename Type , size_t Dimension>
constexpr size_t Vector< Type, Dimension >::size ( ) const
inlineconstexpr

Get the number of dimensions/components.

Returns
The dimension of the vector (compile-time constant)

Definition at line 165 of file vector.hpp.


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