nngn
Loading...
Searching...
No Matches
nngn::Math Class Reference

#include <math.h>

Classes

struct  rnd_generator_t
 

Public Types

using rand_seed_t = std::decay_t< >
 

Public Member Functions

auto * rnd_generator (void)
 
void init (void)
 
void seed_rand (rand_seed_t s)
 
void rand_mat (std::span< float > m)
 

Static Public Member Functions

template<typename T = double>
static constexpr T sq2_2 (void)
 
template<typename T = double>
static constexpr T sq2 (void)
 
template<typename T = double>
static constexpr T e (void)
 
template<typename T = double>
static constexpr T pi (void)
 
template<typename T = double>
static constexpr T tau (void)
 
template<typename T = double>
static constexpr T radians (T d)
 
template<typename T = double>
static constexpr T degrees (T r)
 
template<typename T >
static constexpr T round_down_pow2 (T n, T d)
 
template<typename T >
static constexpr T round_up_pow2 (T n, T d)
 
template<typename T >
static constexpr T round_down (T n, T d)
 
template<typename T >
static constexpr T round_up (T n, T d)
 
template<typename T >
static constexpr T round_up_div (T n, T d)
 
template<unsigned_integral T>
static constexpr T mip_levels (T extent)
 
template<typename T >
static constexpr auto dot (T u, T v)
 
template<typename T >
static constexpr auto length2 (T v)
 
template<typename T >
static auto length (T v)
 
template<typename T >
static T normalize (T v)
 
template<template< typename > typename V, typename T >
requires vector<V, T>
static V< Tclamp_len (V< T > v, T len)
 
template<typename T >
static constexpr vector_type< Tsum (T v)
 
template<typename T >
static constexpr vector_type< Tproduct (T v)
 
template<typename T >
static constexpr vector_type< Tavg (T v)
 
template<typename T >
static constexpr vec3_base< Tcross (vec3_base< T > u, vec3_base< T > v)
 
template<typename T >
static constexpr T angle (vec2_base< T > u, vec2_base< T > v)
 
template<typename T >
static constexpr T angle (vec3_base< T > u, vec3_base< T > v, vec3_base< T > n)
 
template<typename T >
static constexpr vec3_base< Treflect (vec3_base< T > v, vec3_base< T > n)
 
template<typename T >
static constexpr vec3_base< Tnormal (vec3_base< T > p0, vec3_base< T > p1, vec3_base< T > p2)
 
static void mat_mul (std::span< float > dst, const float *src0, const float *src1, std::size_t n)
 
template<typename T >
static vec3_base< Tperspective_transform (const mat4_base< T > &m, vec3_base< T > v)
 
template<typename T >
static constexpr vec3_base< Tdiag (const mat3_base< T > &m, std::size_t i)
 
template<typename T >
static constexpr vec3_base< Tinv_diag (const mat3_base< T > &m, std::size_t i)
 
template<typename T >
static constexpr mat3_base< Tminor_matrix (const mat4_base< T > &m, std::size_t i, std::size_t j)
 
template<typename T >
static constexpr T minor (const mat4_base< T > &m, std::size_t i, std::size_t j)
 
template<typename T >
static constexpr T determinant (const mat3_base< T > &m)
 
template<typename T >
static constexpr T determinant (const mat4_base< T > &m)
 
template<typename T >
static constexpr T cofactor (const mat4_base< T > &m, std::size_t i, std::size_t j)
 
template<typename T >
static constexpr mat4_base< Tadjugate (const mat4_base< T > &m)
 
template<typename T >
static constexpr mat4_base< Tinverse (const mat4_base< T > &m)
 
template<typename T >
static constexpr mat3_base< Ttranspose (const mat3_base< T > &m)
 
template<typename T >
static constexpr mat4_base< Ttranspose (const mat4_base< T > &m)
 
template<typename T >
static constexpr mat4_base< Ttranslate (const mat4_base< T > &m, vec3_base< T > v)
 
template<typename T >
static constexpr mat4_base< Tscale (const mat4_base< T > &m, vec3_base< T > v)
 
template<typename T >
static constexpr vec2_base< Trotate (vec2_base< T > v, T sin, T cos)
 
template<typename T >
static constexpr vec2_base< Trotate (vec2_base< T > v, T angle)
 
template<typename T >
static constexpr vec3_base< Trotate (vec3_base< T > v, T sin, T cos, vec3_base< T > n)
 
template<typename T >
static constexpr vec3_base< Trotate (vec3_base< T > v, T angle, vec3_base< T > n)
 
template<typename T >
static constexpr vec3_base< Trotate_x (vec3_base< T > v, T sin, T cos)
 
template<typename T >
static constexpr vec3_base< Trotate_y (vec3_base< T > v, T sin, T cos)
 
template<typename T >
static constexpr vec3_base< Trotate_z (vec3_base< T > v, T sin, T cos)
 
template<typename T >
static constexpr vec3_base< Trotate_x (vec3_base< T > v, T angle)
 
template<typename T >
static constexpr vec3_base< Trotate_y (vec3_base< T > v, T angle)
 
template<typename T >
static constexpr vec3_base< Trotate_z (vec3_base< T > v, T angle)
 
template<typename T >
static constexpr mat4_base< Trotate (const mat4_base< T > &m, T angle, vec3_base< T > v)
 
template<typename T >
static constexpr mat4_base< Tortho (T left, T right, T bottom, T top)
 
template<typename T >
static constexpr mat4_base< Tortho (T left, T right, T bottom, T top, T near, T far)
 
template<typename T >
static constexpr mat4_base< Tperspective (T fovy, T aspect, T near, T far)
 
template<typename T >
static constexpr mat4_base< Tlook_at (vec3_base< T > eye, vec3_base< T > center, vec3_base< T > up)
 
static void gaussian_filter (std::size_t size, float std_dev, std::span< float > s)
 
static void gaussian_filter (std::size_t xsize, std::size_t ysize, float std_dev, std::span< float > s)
 
static bool is_aligned (void *p, std::size_t a)
 
static void * align_ptr (void *p, std::size_t a)
 
template<typename T >
static Talign_ptr (void *p)
 

Private Attributes

std::optional< rnd_generator_tm_rnd_generator = {}
 

Member Typedef Documentation

◆ rand_seed_t

using nngn::Math::rand_seed_t = std::decay_t< >

Member Function Documentation

◆ adjugate()

template<typename T >
mat4_base< T > nngn::Math::adjugate ( const mat4_base< T > & m)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ align_ptr() [1/2]

template<typename T >
T * nngn::Math::align_ptr ( void * p)
static
Here is the call graph for this function:

◆ align_ptr() [2/2]

void * nngn::Math::align_ptr ( void * p,
std::size_t a )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ angle() [1/2]

template<typename T >
T nngn::Math::angle ( vec2_base< T > u,
vec2_base< T > v )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ angle() [2/2]

template<typename T >
T nngn::Math::angle ( vec3_base< T > u,
vec3_base< T > v,
vec3_base< T > n )
inlinestaticconstexpr
Here is the call graph for this function:

◆ avg()

template<typename T >
vector_type< T > nngn::Math::avg ( T v)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clamp_len()

template<template< typename > typename V, typename T >
requires vector<V, T>
V< T > nngn::Math::clamp_len ( V< T > v,
T len )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cofactor()

template<typename T >
static constexpr T nngn::Math::cofactor ( const mat4_base< T > & m,
std::size_t i,
std::size_t j )
staticconstexpr

◆ cross()

template<typename T >
vec3_base< T > nngn::Math::cross ( vec3_base< T > u,
vec3_base< T > v )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ degrees()

template<typename T >
T nngn::Math::degrees ( T r)
inlinestaticconstexpr
Here is the call graph for this function:

◆ determinant() [1/2]

template<typename T >
T nngn::Math::determinant ( const mat3_base< T > & m)
inlinestaticconstexpr
Here is the caller graph for this function:

◆ determinant() [2/2]

template<typename T >
T nngn::Math::determinant ( const mat4_base< T > & m)
inlinestaticconstexpr

◆ diag()

template<typename T >
vec3_base< T > nngn::Math::diag ( const mat3_base< T > & m,
std::size_t i )
inlinestaticconstexpr

◆ dot()

template<typename T >
auto nngn::Math::dot ( T u,
T v )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ e()

template<typename T >
T nngn::Math::e ( void )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ gaussian_filter() [1/2]

void nngn::Math::gaussian_filter ( std::size_t size,
float std_dev,
std::span< float > s )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gaussian_filter() [2/2]

void nngn::Math::gaussian_filter ( std::size_t xsize,
std::size_t ysize,
float std_dev,
std::span< float > s )
static
Here is the call graph for this function:

◆ init()

void nngn::Math::init ( void )

◆ inv_diag()

template<typename T >
vec3_base< T > nngn::Math::inv_diag ( const mat3_base< T > & m,
std::size_t i )
inlinestaticconstexpr

◆ inverse()

template<typename T >
mat4_base< T > nngn::Math::inverse ( const mat4_base< T > & m)
inlinestaticconstexpr
Here is the call graph for this function:

◆ is_aligned()

bool nngn::Math::is_aligned ( void * p,
std::size_t a )
inlinestatic
Here is the caller graph for this function:

◆ length()

template<typename T >
auto nngn::Math::length ( T v)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ length2()

template<typename T >
auto nngn::Math::length2 ( T v)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ look_at()

template<typename T >
mat4_base< T > nngn::Math::look_at ( vec3_base< T > eye,
vec3_base< T > center,
vec3_base< T > up )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mat_mul()

void nngn::Math::mat_mul ( std::span< float > dst,
const float * src0,
const float * src1,
std::size_t n )
static
Here is the caller graph for this function:

◆ minor()

template<typename T >
T nngn::Math::minor ( const mat4_base< T > & m,
std::size_t i,
std::size_t j )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ minor_matrix()

template<typename T >
mat3_base< T > nngn::Math::minor_matrix ( const mat4_base< T > & m,
std::size_t i,
std::size_t j )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ mip_levels()

template<unsigned_integral T>
T nngn::Math::mip_levels ( T extent)
staticconstexpr
Here is the caller graph for this function:

◆ normal()

template<typename T >
vec3_base< T > nngn::Math::normal ( vec3_base< T > p0,
vec3_base< T > p1,
vec3_base< T > p2 )
inlinestaticconstexpr
Here is the call graph for this function:

◆ normalize()

template<typename T >
T nngn::Math::normalize ( T v)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ortho() [1/2]

template<typename T >
mat4_base< T > nngn::Math::ortho ( T left,
T right,
T bottom,
T top )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ ortho() [2/2]

template<typename T >
mat4_base< T > nngn::Math::ortho ( T left,
T right,
T bottom,
T top,
T near,
T far )
inlinestaticconstexpr
Here is the call graph for this function:

◆ perspective()

template<typename T >
mat4_base< T > nngn::Math::perspective ( T fovy,
T aspect,
T near,
T far )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ perspective_transform()

template<typename T >
vec3_base< T > nngn::Math::perspective_transform ( const mat4_base< T > & m,
vec3_base< T > v )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pi()

template<typename T >
T nngn::Math::pi ( void )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ product()

template<typename T >
vector_type< T > nngn::Math::product ( T v)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ radians()

template<typename T >
T nngn::Math::radians ( T d)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rand_mat()

void nngn::Math::rand_mat ( std::span< float > m)
Here is the call graph for this function:

◆ reflect()

template<typename T >
vec3_base< T > nngn::Math::reflect ( vec3_base< T > v,
vec3_base< T > n )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rnd_generator()

auto * nngn::Math::rnd_generator ( void )
inline
Here is the caller graph for this function:

◆ rotate() [1/5]

template<typename T >
mat4_base< T > nngn::Math::rotate ( const mat4_base< T > & m,
T angle,
vec3_base< T > v )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate() [2/5]

template<typename T >
vec2_base< T > nngn::Math::rotate ( vec2_base< T > v,
T angle )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate() [3/5]

template<typename T >
vec2_base< T > nngn::Math::rotate ( vec2_base< T > v,
T sin,
T cos )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ rotate() [4/5]

template<typename T >
vec3_base< T > nngn::Math::rotate ( vec3_base< T > v,
T angle,
vec3_base< T > n )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate() [5/5]

template<typename T >
vec3_base< T > nngn::Math::rotate ( vec3_base< T > v,
T sin,
T cos,
vec3_base< T > n )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate_x() [1/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_x ( vec3_base< T > v,
T angle )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate_x() [2/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_x ( vec3_base< T > v,
T sin,
T cos )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_y() [1/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_y ( vec3_base< T > v,
T angle )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate_y() [2/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_y ( vec3_base< T > v,
T sin,
T cos )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_z() [1/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_z ( vec3_base< T > v,
T angle )
inlinestaticconstexpr
Here is the call graph for this function:

◆ rotate_z() [2/2]

template<typename T >
vec3_base< T > nngn::Math::rotate_z ( vec3_base< T > v,
T sin,
T cos )
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ round_down()

template<typename T >
T nngn::Math::round_down ( T n,
T d )
staticconstexpr

◆ round_down_pow2()

template<typename T >
T nngn::Math::round_down_pow2 ( T n,
T d )
staticconstexpr

◆ round_up()

template<typename T >
T nngn::Math::round_up ( T n,
T d )
staticconstexpr
Here is the caller graph for this function:

◆ round_up_div()

template<typename T >
T nngn::Math::round_up_div ( T n,
T d )
staticconstexpr
Here is the caller graph for this function:

◆ round_up_pow2()

template<typename T >
T nngn::Math::round_up_pow2 ( T n,
T d )
staticconstexpr
Here is the caller graph for this function:

◆ scale()

template<typename T >
mat4_base< T > nngn::Math::scale ( const mat4_base< T > & m,
vec3_base< T > v )
inlinestaticconstexpr

◆ seed_rand()

void nngn::Math::seed_rand ( rand_seed_t s)
Here is the call graph for this function:

◆ sq2()

template<typename T >
T nngn::Math::sq2 ( void )
inlinestaticconstexpr

◆ sq2_2()

template<typename T >
T nngn::Math::sq2_2 ( void )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ sum()

template<typename T >
vector_type< T > nngn::Math::sum ( T v)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tau()

template<typename T >
T nngn::Math::tau ( void )
inlinestaticconstexpr
Here is the caller graph for this function:

◆ translate()

template<typename T >
mat4_base< T > nngn::Math::translate ( const mat4_base< T > & m,
vec3_base< T > v )
inlinestaticconstexpr

◆ transpose() [1/2]

template<typename T >
mat3_base< T > nngn::Math::transpose ( const mat3_base< T > & m)
inlinestaticconstexpr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transpose() [2/2]

template<typename T >
mat4_base< T > nngn::Math::transpose ( const mat4_base< T > & m)
inlinestaticconstexpr
Here is the call graph for this function:

Member Data Documentation

◆ m_rnd_generator

std::optional<rnd_generator_t> nngn::Math::m_rnd_generator = {}
private

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