PointSampler library (C++)
Loading...
Searching...
No Matches
ps::Point< T, N > Struct Template Reference

A fixed-size N-dimensional point/vector class. More...

#include <point.hpp>

Public Member Functions

 Point ()=default
 
 Point (const std::vector< T > &v)
 
 Point (std::initializer_list< T > init)
 
 Point (const std::array< T, N > &coords_)
 
Toperator[] (size_t i)
 
const Toperator[] (size_t i) const
 
Tx ()
 
Ty ()
 
Tz ()
 
Tw ()
 
const Tx () const
 
const Ty () const
 
const Tz () const
 
const Tw () const
 

Public Attributes

std::array< T, Ncoords
 

Detailed Description

template<typename T, size_t N>
struct ps::Point< T, N >

A fixed-size N-dimensional point/vector class.

Represents a geometric or algebraic point in N-dimensional space with coordinates of type T. Supports element-wise arithmetic operations, scalar math, and basic geometric functions such as dot product, length, normalization, and distance.

Designed for use in procedural generation, geometry processing, simulation, and graphics.

  • Compatible with STL containers and algorithms
  • Zero-allocation, fast and cache-friendly (uses std::array<T, N>)
  • Works seamlessly in 2D, 3D, or arbitrary dimensions
Example:
Point<float, 2> p{1.0f, 2.0f};
auto length = p.x() * p.x() + p.y() * p.y();
std::vector< Point< T, N > > random(size_t count, const std::array< std::pair< T, T >, N > &axis_ranges, std::optional< unsigned int > seed=std::nullopt)
Generates a specified number of uniformly distributed random points in N-dimensional space.
Definition random.hpp:66
T length(const Point< T, N > &a)
Definition point.hpp:211
A fixed-size N-dimensional point/vector class.
Definition point.hpp:39
T & x()
Definition point.hpp:69

Constructor & Destructor Documentation

◆ Point() [1/4]

template<typename T , size_t N>
ps::Point< T, N >::Point ( )
default

◆ Point() [2/4]

template<typename T , size_t N>
ps::Point< T, N >::Point ( const std::vector< T > &  v)
inlineexplicit

◆ Point() [3/4]

template<typename T , size_t N>
ps::Point< T, N >::Point ( std::initializer_list< T init)
inline

◆ Point() [4/4]

template<typename T , size_t N>
ps::Point< T, N >::Point ( const std::array< T, N > &  coords_)
inline

Member Function Documentation

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ w() [1/2]

template<typename T , size_t N>
T & ps::Point< T, N >::w ( )
inline

◆ w() [2/2]

template<typename T , size_t N>
const T & ps::Point< T, N >::w ( ) const
inline

◆ x() [1/2]

template<typename T , size_t N>
T & ps::Point< T, N >::x ( )
inline

◆ x() [2/2]

template<typename T , size_t N>
const T & ps::Point< T, N >::x ( ) const
inline

◆ y() [1/2]

template<typename T , size_t N>
T & ps::Point< T, N >::y ( )
inline

◆ y() [2/2]

template<typename T , size_t N>
const T & ps::Point< T, N >::y ( ) const
inline

◆ z() [1/2]

template<typename T , size_t N>
T & ps::Point< T, N >::z ( )
inline

◆ z() [2/2]

template<typename T , size_t N>
const T & ps::Point< T, N >::z ( ) const
inline

Member Data Documentation

◆ coords

template<typename T , size_t N>
std::array<T, N> ps::Point< T, N >::coords

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