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