nngn
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
5#ifndef NNGN_MATH_MATH_H
6#define NNGN_MATH_MATH_H
7
8#include <bit>
9#include <cassert>
10#include <cmath>
11#include <optional>
12#include <random>
13#include <span>
14
16
17#include "mat3.h"
18#include "mat4.h"
19
20namespace nngn {
21
22class Math {
23public:
24 struct rnd_generator_t : private std::mt19937 {
25 using std::mt19937::default_seed;
26 using std::mt19937::result_type;
27 using std::mt19937::min;
28 using std::mt19937::max;
29 using std::mt19937::mt19937;
30 using std::mt19937::operator();
31 using std::mt19937::operator=;
32 using std::mt19937::seed;
34 };
35 using rand_seed_t = std::decay_t<decltype(rnd_generator_t::default_seed)>;
36private:
37 std::optional<rnd_generator_t> m_rnd_generator = {};
38public:
39 // Constants
40 template<typename T = double> static constexpr T sq2_2(void);
41 template<typename T = double> static constexpr T sq2(void);
42 template<typename T = double> static constexpr T e(void);
43 template<typename T = double> static constexpr T pi(void);
44 template<typename T = double> static constexpr T tau(void);
45 template<typename T = double> static constexpr T radians(T d);
46 template<typename T = double> static constexpr T degrees(T r);
47 // Scalar
48 template<typename T> static constexpr T round_down_pow2(T n, T d);
49 template<typename T> static constexpr T round_up_pow2(T n, T d);
50 template<typename T> static constexpr T round_down(T n, T d);
51 template<typename T> static constexpr T round_up(T n, T d);
52 template<typename T> static constexpr T round_up_div(T n, T d);
53 template<unsigned_integral T> static constexpr T mip_levels(T extent);
54 template<typename T> static constexpr auto dot(T u, T v);
55 // Vector
56 template<typename T> static constexpr auto length2(T v);
57 template<typename T> static auto length(T v);
58 template<typename T> static T normalize(T v);
59 template<template<typename> typename V, typename T>
60 requires vector<V, T>
61 static V<T> clamp_len(V<T> v, T len);
62 template<typename T>
63 static constexpr vector_type<T> sum(T v);
64 template<typename T>
65 static constexpr vector_type<T> product(T v);
66 template<typename T>
67 static constexpr vector_type<T> avg(T v);
68 template<typename T>
69 static constexpr vec3_base<T> cross(vec3_base<T> u, vec3_base<T> v);
70 template<typename T>
71 static constexpr T angle(vec2_base<T> u, vec2_base<T> v);
72 template<typename T>
73 static constexpr T angle(vec3_base<T> u, vec3_base<T> v, vec3_base<T> n);
74 template<typename T>
75 static constexpr vec3_base<T> reflect(vec3_base<T> v, vec3_base<T> n);
76 // Plane
77 template<typename T>
78 static constexpr vec3_base<T> normal(
80 // Matrix
81 static void mat_mul(
82 std::span<float> dst, const float *src0, const float *src1,
83 std::size_t n);
84 template<typename T>
85 static constexpr vec3_base<T> diag(
86 const mat3_base<T> &m, std::size_t i);
87 template<typename T>
88 static constexpr vec3_base<T> inv_diag(
89 const mat3_base<T> &m, std::size_t i);
90 template<typename T>
91 static constexpr mat3_base<T> minor_matrix(
92 const mat4_base<T> &m, std::size_t i, std::size_t j);
93 template<typename T>
94 static constexpr T minor(
95 const mat4_base<T> &m, std::size_t i, std::size_t j);
96 template<typename T>
97 static constexpr T determinant(const mat3_base<T> &m);
98 template<typename T>
99 static constexpr T determinant(const mat4_base<T> &m);
100 template<typename T>
101 static constexpr T cofactor(
102 const mat4_base<T> &m, std::size_t i, std::size_t j);
103 template<typename T>
104 static constexpr mat4_base<T> adjugate(const mat4_base<T> &m);
105 template<typename T>
106 static constexpr mat4_base<T> inverse(const mat4_base<T> &m);
107 template<typename T>
108 static constexpr mat3_base<T> transpose(const mat3_base<T> &m);
109 template<typename T>
110 static constexpr mat4_base<T> transpose(const mat4_base<T> &m);
111 template<typename T>
112 static constexpr mat4_base<T> translate(
113 const mat4_base<T> &m, vec3_base<T> v);
114 template<typename T>
115 static constexpr mat4_base<T> scale(
116 const mat4_base<T> &m, vec3_base<T> v);
117 // Rotation
118 template<typename T>
119 static constexpr vec2_base<T> rotate(vec2_base<T> v, T sin, T cos);
120 template<typename T>
121 static constexpr vec2_base<T> rotate(vec2_base<T> v, T angle);
122 template<typename T>
123 static constexpr vec3_base<T> rotate(
124 vec3_base<T> v, T sin, T cos, vec3_base<T> n);
125 template<typename T>
126 static constexpr vec3_base<T> rotate(
128 template<typename T>
129 static constexpr vec3_base<T> rotate_x(vec3_base<T> v, T sin, T cos);
130 template<typename T>
131 static constexpr vec3_base<T> rotate_y(vec3_base<T> v, T sin, T cos);
132 template<typename T>
133 static constexpr vec3_base<T> rotate_z(vec3_base<T> v, T sin, T cos);
134 template<typename T>
135 static constexpr vec3_base<T> rotate_x(vec3_base<T> v, T angle);
136 template<typename T>
137 static constexpr vec3_base<T> rotate_y(vec3_base<T> v, T angle);
138 template<typename T>
139 static constexpr vec3_base<T> rotate_z(vec3_base<T> v, T angle);
140 template<typename T>
141 static constexpr mat4_base<T> rotate(
142 const mat4_base<T> &m, T angle, vec3_base<T> v);
143 // Projection
144 template<typename T>
145 static constexpr mat4_base<T> ortho(T left, T right, T bottom, T top);
146 template<typename T>
147 static constexpr mat4_base<T> ortho(
148 T left, T right, T bottom, T top, T near, T far);
149 template<typename T>
150 static constexpr mat4_base<T> perspective(T fovy, T aspect, T near, T far);
151 // View
152 template<typename T>
153 static constexpr mat4_base<T> look_at(
154 vec3_base<T> eye, vec3_base<T> center, vec3_base<T> up);
155 // Etc.
156 static void gaussian_filter(
157 std::size_t size, float std_dev, std::span<float> s);
158 static void gaussian_filter(
159 std::size_t xsize, std::size_t ysize, float std_dev,
160 std::span<float> s);
161 static bool is_aligned(void *p, std::size_t a);
162 static void *align_ptr(void *p, std::size_t a);
163 template<typename T>
164 static T *align_ptr(void *p);
165 auto *rnd_generator(void) { return &*this->m_rnd_generator; }
166 void init(void);
167 void seed_rand(rand_seed_t s);
168 void rand_mat(std::span<float> m);
169};
170
171template<typename T> inline constexpr T Math::sq2(void) {
172 return static_cast<T>(1.41421356237309514547462185873882845);
173}
174
175template<typename T> inline constexpr T Math::sq2_2(void) {
176 return static_cast<T>(0.70710678118654757273731092936941423);
177}
178
179template<typename T> inline constexpr T Math::e(void) {
180 return static_cast<T>(2.7182818284590450907955982984276488);
181}
182
183template<typename T> inline constexpr T Math::pi(void) {
184 return static_cast<T>(3.14159265358979323846264338327950288);
185}
186
187template<typename T> inline constexpr T Math::tau(void) {
188 return static_cast<T>(6.28318530717958647692528676655900576);
189}
190
191template<typename T> inline constexpr T Math::radians(T d) {
192 constexpr auto mul = Math::tau<T>() / T{360};
193 return d * mul;
194}
195
196template<typename T> inline constexpr T Math::degrees(T r) {
197 constexpr auto mul = T{360} * Math::tau<T>();
198 return r * mul;
199}
200
201template<typename T>
202constexpr T Math::round_down_pow2(T n, T d) {
203 assert(std::popcount(d) == 1);
204 return n & ~--d;
205}
206
207template<typename T>
208constexpr T Math::round_up_pow2(T n, T d) {
209 assert(std::popcount(d) == 1);
210 return --d, (n + d) & ~d;
211}
212
213template<typename T>
214constexpr T Math::round_down(T n, T d) {
215 if(const auto r = n % d)
216 n -= r;
217 return n;
218}
219
220template<typename T>
221constexpr T Math::round_up(T n, T d) {
222 if(const auto r = n % d)
223 n += d - r;
224 return n;
225}
226
227template<typename T>
228constexpr T Math::round_up_div(T n, T d) {
229 return (d - 1 + n) / d;
230}
231
232template<unsigned_integral T>
233constexpr T Math::mip_levels(T extent) {
234 assert(std::popcount(extent) == 1);
235 return T{1} + static_cast<T>(std::countr_zero(std::bit_floor(extent)));
236}
237
238template<typename T>
239inline constexpr auto Math::dot(T u, T v) {
240 if constexpr(std::ranges::range<T>)
241 return std::inner_product(
242 std::ranges::begin(u), std::ranges::end(u), std::ranges::begin(v),
243 std::ranges::range_value_t<T>{});
244 else
245 return u * v;
246}
247
248template<typename T>
249inline constexpr auto Math::length2(T v) {
250 return Math::dot(v, v);
251}
252
253template<typename T>
254inline auto Math::length(T v) {
255 return std::sqrt(Math::length2(v));
256}
257
258template<typename T>
259inline T Math::normalize(T v) {
260 return v / Math::length(v);
261}
262
263template<template<typename> typename V, typename T>
264requires vector<V, T>
265inline V<T> Math::clamp_len(V<T> v, T len) {
266 const auto len2 = Math::length2(v), max2 = len * len;
267 return len2 <= max2 ? v : v * std::sqrt(max2 / len2);
268}
269
270template<typename T>
271inline constexpr vector_type<T> Math::sum(T v) {
272 return std::accumulate(begin(v), end(v), vector_type<T>{});
273}
274
275template<typename T>
276inline constexpr vector_type<T> Math::product(T v) {
277 return std::accumulate(
278 begin(v), end(v), vector_type<T>{1}, std::multiplies<>{});
279}
280
281template<typename T>
282inline constexpr vector_type<T> Math::avg(T v) {
283 return Math::sum(v) / vector_type<T>{T::n_dim};
284}
285
286template<typename T>
288 return {
289 u.y * v.z - u.z * v.y,
290 u.z * v.x - u.x * v.z,
291 u.x * v.y - u.y * v.x,
292 };
293}
294
295template<typename T>
296inline constexpr T Math::angle(vec2_base<T> u, vec2_base<T> v) {
297 return Math::angle(vec3_base<T>(u), vec3_base<T>(v), {0, 0, 1});
298}
299
300template<typename T>
302 const auto cross = Math::cross(u, v);
303 const auto ret = std::acos(Math::dot(u, v));
304 return Math::dot(cross, n) < 0 ? Math::tau<T>() - ret : ret;
305}
306
307template<typename T>
309 return v - T(2) * n * Math::dot(v, n);
310}
311
312template<typename T>
313inline constexpr vec3_base<T> Math::normal(
315{
316 return Math::cross(p1 - p0, p2 - p0);
317}
318
319template<typename T>
320inline constexpr mat3_base<T> Math::transpose(const mat3_base<T> &m) {
321 return {m.row(0), m.row(1), m.row(2)};
322}
323
324template<typename T>
325inline constexpr mat4_base<T> Math::transpose(const mat4_base<T> &m) {
326 return {m.row(0), m.row(1), m.row(2), m.row(3)};
327}
328
329template<typename T>
330inline constexpr vec3_base<T> Math::diag(
331 const mat3_base<T> &m, std::size_t i)
332{
333 return {m[i][0], m[(i + 1) % 3][1], m[(i + 2) % 3][2]};
334}
335
336template<typename T>
338 const mat3_base<T> &m, std::size_t i)
339{
340 return {m[i][0], m[(i + 2) % 3][1], m[(i + 1) % 3][2]};
341}
342
343template<typename T>
345 const mat4_base<T> &m, std::size_t i, std::size_t j)
346{
347 mat3_base<T> ret = {};
348 std::size_t c = 0;
349 for(; c != i; ++c) {
350 std::size_t r = 0;
351 for( ; r != j; ++r) ret[c][r ] = m[c][r];
352 for(++r; r != 4; ++r) ret[c][r - 1] = m[c][r];
353 }
354 for(++c; c != 4; ++c) {
355 std::size_t r = 0;
356 for( ; r != j; ++r) ret[c - 1][r ] = m[c][r];
357 for(++r; r != 4; ++r) ret[c - 1][r - 1] = m[c][r];
358 }
359 return ret;
360}
361
362template<typename T>
363inline constexpr T Math::minor(
364 const mat4_base<T> &m, std::size_t i, std::size_t j)
365{
367}
368
369template<typename T>
370inline constexpr T Math::determinant(const mat3_base<T> &m) {
371 using M = Math;
372 return M::product(M::diag(m, 0)) - M::product(M::inv_diag(m, 0))
373 + M::product(M::diag(m, 1)) - M::product(M::inv_diag(m, 1))
374 + M::product(M::diag(m, 2)) - M::product(M::inv_diag(m, 2));
375}
376
377template<typename T>
378inline constexpr T Math::determinant(const mat4_base<T> &m) {
379 using M = Math;
380 return m[0][0] * M::minor(m, 0, 0)
381 - m[0][1] * M::minor(m, 0, 1)
382 + m[0][2] * M::minor(m, 0, 2)
383 - m[0][3] * M::minor(m, 0, 3);
384}
385
386template<typename T>
387inline constexpr mat4_base<T> Math::adjugate(const mat4_base<T> &m) {
388 mat4_base<T> ret = {};
389 float s = 1.0f;
390 for(std::size_t c = 0; c != 4; ++c, s = -s)
391 for(std::size_t r = 0; r != 4; ++r, s = -s)
392 ret[c][r] = s * Math::minor(m, r, c);
393 return ret;
394}
395
396template<typename T>
397inline constexpr mat4_base<T> Math::inverse(const mat4_base<T> &m) {
398 return T{1} / Math::determinant(m) * Math::adjugate(m);
399}
400
401template<typename T>
404{
405 return {
406 m[0], m[1], m[2],
407 {m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]}};
408}
409
410template<typename T>
411inline constexpr mat4_base<T> Math::scale(
413{
414 return {m[0] * v[0], m[1] * v[1], m[2] * v[2], m[3]};
415}
416
417template<typename T>
418inline constexpr vec2_base<T> Math::rotate(vec2_base<T> v, T sin, T cos) {
419 return {v.x * cos - v.y * sin, v.x * sin + v.y * cos};
420}
421
422
423template<typename T>
424inline constexpr vec2_base<T> Math::rotate(vec2_base<T> v, T angle) {
425 return Math::rotate(v, std::sin(angle), std::cos(angle));
426}
427
428template<typename T>
429inline constexpr vec3_base<T> Math::rotate(
430 vec3_base<T> v, T sin, T cos, vec3_base<T> n)
431{
432 const auto proj = n * Math::dot(n, v);
433 const auto d = v - proj;
434 const auto rot = cos * d + sin * Math::cross(n, d);
435 return proj + rot;
436}
437
438template<typename T>
439inline constexpr vec3_base<T> Math::rotate(
440 vec3_base<T> v, T angle, vec3_base<T> n)
441{
442 return Math::rotate(v, std::sin(angle), std::cos(angle), n);
443}
444
445template<typename T>
446inline constexpr vec3_base<T> Math::rotate_x(vec3_base<T> v, T sin, T cos) {
447 const auto r = Math::rotate(v.yz(), sin, cos);
448 return {v.x, r.x, r.y};
449}
450
451template<typename T>
452inline constexpr vec3_base<T> Math::rotate_y(vec3_base<T> v, T sin, T cos) {
453 const auto r = Math::rotate(v.zx(), sin, cos);
454 return {r.y, v.y, r.x};
455}
456
457template<typename T>
458inline constexpr vec3_base<T> Math::rotate_z(vec3_base<T> v, T sin, T cos) {
459 const auto r = Math::rotate(v.xy(), sin, cos);
460 return {r.x, r.y, v.z};
461}
462
463template<typename T>
464inline constexpr vec3_base<T> Math::rotate_x(vec3_base<T> v, T angle) {
465 return Math::rotate_x(v, std::sin(angle), std::cos(angle));
466}
467
468template<typename T>
469inline constexpr vec3_base<T> Math::rotate_y(vec3_base<T> v, T angle) {
470 return Math::rotate_y(v, std::sin(angle), std::cos(angle));
471}
472
473template<typename T>
474inline constexpr vec3_base<T> Math::rotate_z(vec3_base<T> v, T angle) {
475 return Math::rotate_z(v, std::sin(angle), std::cos(angle));
476}
477
478template<typename T>
479inline constexpr mat4_base<T> Math::rotate(
480 const mat4_base<T> &m, T angle, vec3_base<T> v)
481{
482 const T cos = std::cos(angle);
483 const T sin = std::sin(angle);
484 const auto axis = Math::normalize(v);
485 const auto tmp = (T{1} - cos) * axis;
486 mat4 rot = {};
487 rot[0][0] = tmp.x * axis.x + cos;
488 rot[0][1] = tmp.y * axis.x + sin * axis.z;
489 rot[0][2] = tmp.z * axis.x - sin * axis.y;
490 rot[1][0] = tmp.x * axis.y - sin * axis.z;
491 rot[1][1] = tmp.y * axis.y + cos;
492 rot[1][2] = tmp.z * axis.y + sin * axis.x;
493 rot[2][0] = tmp.x * axis.z + sin * axis.y;
494 rot[2][1] = tmp.y * axis.z - sin * axis.x;
495 rot[2][2] = tmp.z * axis.z + cos;
496 rot[3][3] = T{1};
497 return m * rot;
498}
499
500template<typename T>
501inline constexpr mat4_base<T> Math::ortho(T left, T right, T bottom, T top) {
502 const auto w = right - left, h = top - bottom;
503 auto ret = mat4_base<T>{0};
504 ret[0][0] = T{2} / w;
505 ret[1][1] = T{2} / h;
506 ret[2][2] = T{-1};
507 ret[3][3] = T{1};
508 ret[3][0] = -(right + left) / w;
509 ret[3][1] = -(top + bottom) / h;
510 return ret;
511}
512
513template<typename T>
514inline constexpr mat4_base<T> Math::ortho(
515 T left, T right, T bottom, T top, T near, T far)
516{
517 auto ret = Math::ortho(left, right, bottom, top);
518 const auto z = far - near;
519 ret[2][2] = -T{2} / z;
520 ret[3][2] = -(far + near) / z;
521 return ret;
522}
523
524template<typename T>
526 T fovy, T aspect, T near, T far)
527{
528 assert(std::abs(aspect) > -std::numeric_limits<T>::epsilon());
529 const auto tan = std::tan(fovy / T{2});
530 auto ret = mat4_base<T>{0};
531 ret[0][0] = T{1} / (aspect * tan);
532 ret[1][1] = T{1} / tan;
533 ret[2][2] = -(far + near) / (far - near);
534 ret[2][3] = -T{1};
535 ret[3][2] = -T{2} * far * near / (far - near);
536 return ret;
537}
538
539template<typename T>
541 vec3_base<T> eye, vec3_base<T> center, vec3_base<T> up)
542{
543 const auto f = Math::normalize(center - eye);
544 const auto s = Math::normalize(Math::cross(f, up));
545 const auto u = Math::cross(s, f);
546 return Math::transpose(mat4{
547 vec4{s, -Math::dot(s, eye)},
548 vec4{u, -Math::dot(u, eye)},
549 vec4{-f, Math::dot(f, eye)},
550 vec4{0, 0, 0, 1},
551 });
552}
553
554inline bool Math::is_aligned(void *p, std::size_t a) {
555 const auto u = reinterpret_cast<std::uintptr_t>(p);
556 return !(u & --a);
557}
558
559inline void *Math::align_ptr(void *p, std::size_t a) {
560 const auto u = reinterpret_cast<std::uintptr_t>(p);
561 const auto r = Math::round_up_pow2(u, a);
562 return reinterpret_cast<void*>(r);
563}
564
565template<typename T>
566T *Math::align_ptr(void *p) {
567 return static_cast<T*>(Math::align_ptr(p, alignof(T)));
568}
569
570}
571
572#endif
Definition: math.h:22
static constexpr mat3_base< T > minor_matrix(const mat4_base< T > &m, std::size_t i, std::size_t j)
Definition: math.h:344
static constexpr T pi(void)
Definition: math.h:183
static constexpr mat4_base< T > ortho(T left, T right, T bottom, T top)
Definition: math.h:501
std::decay_t<> rand_seed_t
Definition: math.h:35
static constexpr T tau(void)
Definition: math.h:187
void init(void)
Definition: math.cpp:56
static constexpr vec3_base< T > rotate_z(vec3_base< T > v, T sin, T cos)
Definition: math.h:458
static constexpr vec3_base< T > inv_diag(const mat3_base< T > &m, std::size_t i)
Definition: math.h:337
static constexpr T round_down(T n, T d)
Definition: math.h:214
static constexpr T e(void)
Definition: math.h:179
static constexpr mat4_base< T > inverse(const mat4_base< T > &m)
Definition: math.h:397
static void mat_mul(std::span< float > dst, const float *src0, const float *src1, std::size_t n)
Definition: math.cpp:44
static constexpr mat4_base< T > translate(const mat4_base< T > &m, vec3_base< T > v)
Definition: math.h:402
static constexpr vec3_base< T > normal(vec3_base< T > p0, vec3_base< T > p1, vec3_base< T > p2)
Definition: math.h:313
static constexpr mat3_base< T > transpose(const mat3_base< T > &m)
Definition: math.h:320
static constexpr T round_up_div(T n, T d)
Definition: math.h:228
static constexpr T determinant(const mat3_base< T > &m)
Definition: math.h:370
static auto length(T v)
Definition: math.h:254
static constexpr vector_type< T > product(T v)
Definition: math.h:276
static constexpr vector_type< T > avg(T v)
Definition: math.h:282
static constexpr T mip_levels(T extent)
Definition: math.h:233
static constexpr T cofactor(const mat4_base< T > &m, std::size_t i, std::size_t j)
static constexpr mat4_base< T > look_at(vec3_base< T > eye, vec3_base< T > center, vec3_base< T > up)
Definition: math.h:540
static constexpr T round_up_pow2(T n, T d)
Definition: math.h:208
void seed_rand(rand_seed_t s)
Definition: math.cpp:58
static constexpr vector_type< T > sum(T v)
Definition: math.h:271
std::optional< rnd_generator_t > m_rnd_generator
Definition: math.h:37
static constexpr T sq2(void)
Definition: math.h:171
static constexpr mat4_base< T > adjugate(const mat4_base< T > &m)
Definition: math.h:387
static V< T > clamp_len(V< T > v, T len)
Definition: math.h:265
static constexpr T sq2_2(void)
Definition: math.h:175
static bool is_aligned(void *p, std::size_t a)
Definition: math.h:554
static constexpr auto dot(T u, T v)
Definition: math.h:239
static constexpr T round_down_pow2(T n, T d)
Definition: math.h:202
static constexpr vec3_base< T > rotate_y(vec3_base< T > v, T sin, T cos)
Definition: math.h:452
static constexpr vec3_base< T > diag(const mat3_base< T > &m, std::size_t i)
Definition: math.h:330
static constexpr T radians(T d)
Definition: math.h:191
static constexpr T angle(vec2_base< T > u, vec2_base< T > v)
Definition: math.h:296
static constexpr T round_up(T n, T d)
Definition: math.h:221
static constexpr auto length2(T v)
Definition: math.h:249
auto * rnd_generator(void)
Definition: math.h:165
static constexpr T degrees(T r)
Definition: math.h:196
static constexpr vec2_base< T > rotate(vec2_base< T > v, T sin, T cos)
Definition: math.h:418
static T normalize(T v)
Definition: math.h:259
static constexpr mat4_base< T > perspective(T fovy, T aspect, T near, T far)
Definition: math.h:525
void rand_mat(std::span< float > m)
Definition: math.cpp:67
static constexpr vec3_base< T > reflect(vec3_base< T > v, vec3_base< T > n)
Definition: math.h:308
static constexpr mat4_base< T > scale(const mat4_base< T > &m, vec3_base< T > v)
Definition: math.h:411
static constexpr T minor(const mat4_base< T > &m, std::size_t i, std::size_t j)
Definition: math.h:363
static constexpr vec3_base< T > cross(vec3_base< T > u, vec3_base< T > v)
Definition: math.h:287
static constexpr vec3_base< T > rotate_x(vec3_base< T > v, T sin, T cos)
Definition: math.h:446
static void gaussian_filter(std::size_t size, float std_dev, std::span< float > s)
Definition: math.cpp:10
static void * align_ptr(void *p, std::size_t a)
Definition: math.h:559
Definition: vec.h:60
assert
Definition: debug.lua:3
end
Definition: entities.lua:9
Definition: debug.h:45
constexpr const R * begin(const T< R > &v)
Definition: vec.h:207
typename T::type vector_type
Definition: vec.h:62
rotate
Definition: camera.lua:44
m
Definition: input.lua:19
function f()) end
v[1]
Definition: math.lua:19
w
Definition: strict.lua:12
Definition: math.h:24
Definition: mat3.h:12
Definition: mat4.h:12
Definition: vec2.h:11
Definition: vec3.h:12
T z
Definition: vec3.h:13
T x
Definition: vec3.h:13
T y
Definition: vec3.h:13
Definition: vec4.h:12
std::chrono::seconds s
Definition: timing.cpp:6