39using u8 = std::uint8_t;
40using i32 = std::int32_t;
41using u32 = std::uint32_t;
65inline constexpr f32 F32_LOWEST = std::numeric_limits<f32>::lowest();
66inline constexpr f32 F32_MAX = std::numeric_limits<f32>::max();
67inline constexpr f32 F32_MIN_NORMAL = std::numeric_limits<f32>::min();
68inline constexpr f32 F32_DENORM_MIN = std::numeric_limits<f32>::denorm_min();
69inline constexpr f32 F32_EPSILON = std::numeric_limits<f32>::epsilon();
70inline constexpr f32 F32_INFINITY = std::numeric_limits<f32>::infinity();
71inline constexpr f32 F32_QUIET_NAN = std::numeric_limits<f32>::quiet_NaN();
75inline constexpr f32 F32_COMPARE_EPSILON = 1e-6f;
79inline constexpr f32 E = 2.7182818284590452354f;
80inline constexpr f32 LOG2_E = 1.4426950408889634074f;
81inline constexpr f32 LOG10_E = 0.43429448190325182765f;
82inline constexpr f32 LN_2 = 0.69314718055994530942f;
83inline constexpr f32 LN_10 = 2.30258509299404568402f;
85inline constexpr f32 PI = 3.14159265358979323846f;
86inline constexpr f32 TWO_PI = 6.2831853071795864769f;
87inline constexpr f32 PI_OVER_2 = 1.57079632679489661923f;
88inline constexpr f32 PI_OVER_4 = 0.78539816339744830962f;
89inline constexpr f32 ONE_OVER_PI = 0.31830988618379067154f;
90inline constexpr f32 TWO_OVER_PI = 0.63661977236758134308f;
91inline constexpr f32 TWO_OVER_SQRT_PI = 1.12837916709551257390f;
93inline constexpr f32 SQRT_2 = 1.41421356237309504880f;
94inline constexpr f32 ONE_OVER_SQRT_2 = 0.70710678118654752440f;
138 f32vec3(f32 x_, f32 y_, f32 z_);
159 f32vec4(f32 x_, f32 y_, f32 z_, f32 w_);
266std::string to_string(
const f32vec2& v);
267std::string to_string(
const f32vec3& v);
268std::string to_string(
const f32vec4& v);
271const f32* value_ptr(
const f32vec2& v);
273const f32* value_ptr(
const f32vec3& v);
275const f32* value_ptr(
const f32vec4& v);
277f32vec2 make_vec2(
const f32* ptr);
278f32vec3 make_vec3(
const f32* ptr);
279f32vec4 make_vec4(
const f32* ptr);
385std::string to_string(
const i32vec2& v);
386std::string to_string(
const i32vec3& v);
387std::string to_string(
const i32vec4& v);
390const i32* value_ptr(
const i32vec2& v);
392const i32* value_ptr(
const i32vec3& v);
394const i32* value_ptr(
const i32vec4& v);
396i32vec2 make_vec2(
const i32* ptr);
397i32vec3 make_vec3(
const i32* ptr);
398i32vec4 make_vec4(
const i32* ptr);
500std::string to_string(
const u32vec2& v);
501std::string to_string(
const u32vec3& v);
502std::string to_string(
const u32vec4& v);
505const u32* value_ptr(
const u32vec2& v);
507const u32* value_ptr(
const u32vec3& v);
509const u32* value_ptr(
const u32vec4& v);
511u32vec2 make_vec2(
const u32* ptr);
512u32vec3 make_vec3(
const u32* ptr);
513u32vec4 make_vec4(
const u32* ptr);
631const u8* value_ptr(
const u8vec2& v);
634const u8* value_ptr(
const u8vec3& v);
637const u8* value_ptr(
const u8vec4& v);
639u8vec2 make_vec2(
const u8* ptr);
640u8vec3 make_vec3(
const u8* ptr);
641u8vec4 make_vec4(
const u8* ptr);
643std::string to_string(
const u8vec2& v);
644std::string to_string(
const u8vec3& v);
645std::string to_string(
const u8vec4& v);
711f32 determinant(
const f32mat2& m);
712f32 determinant(
const f32mat3& m);
713f32 determinant(
const f32mat4& m);
726std::string to_string(
const f32mat2& m,
unsigned pad = 10);
727std::string to_string(
const f32mat3& m,
unsigned pad = 10);
728std::string to_string(
const f32mat4& m,
unsigned pad = 10);
731const f32* value_ptr(
const f32mat2& m);
733const f32* value_ptr(
const f32mat3& m);
735const f32* value_ptr(
const f32mat4& m);
737f32mat2 make_mat2(
const f32* ptr);
738f32mat3 make_mat3(
const f32* ptr);
739f32mat4 make_mat4(
const f32* ptr);
746 f32quat(f32 w_, f32 x_, f32 y_, f32 z_);
782std::string to_string(
const f32quat& q);
785const f32* value_ptr(
const f32quat& q);
787f32quat make_quat(
const f32* ptr);
791f32mat4 perspective(f32 fovy, f32 aspect, f32 z_near, f32 z_far);
792f32mat4 ortho(f32 left, f32 right, f32 bottom, f32 top, f32 z_near, f32 z_far);
802f32 uniform_01(std::mt19937* gen);
805f32 uniform_n11(std::mt19937* gen);
807u8 uniform_linear(u8 min, u8 max);
808u8 uniform_linear(std::mt19937* gen, u8 min, u8 max);
810u32 uniform_linear(u32 min, u32 max);
811u32 uniform_linear(std::mt19937* gen, u32 min, u32 max);
813i32 uniform_linear(i32 min, i32 max);
814i32 uniform_linear(std::mt19937* gen, i32 min, i32 max);
816f32 uniform_linear(f32 min, f32 max);
817f32 uniform_linear(std::mt19937* gen, f32 min, f32 max);
828f32vec2 uniform_circular(f32 radius);
829f32vec2 uniform_circular(std::mt19937* gen, f32 radius);
831f32vec3 uniform_spherical(f32 radius);
832f32vec3 uniform_spherical(std::mt19937* gen, f32 radius);
834f32vec2 uniform_disk(f32 radius);
835f32vec2 uniform_disk(std::mt19937* gen, f32 radius);
837f32vec3 uniform_ball(f32 radius);
838f32vec3 uniform_ball(std::mt19937* gen, f32 radius);
840f32 gaussian(f32 mean, f32 deviation, f32 min, f32 max);
841f32 gaussian(std::mt19937* gen, f32 mean, f32 deviation, f32 min, f32 max);
843bool bernoulli(f32 p);
844bool bernoulli(std::mt19937* gen, f32 p);
850f32 lerp(f32 a, f32 b, f32 t);
851f32 lerp_01(f32 a, f32 b, f32 t);
862f32 inverse_lerp(f32 a, f32 b, f32 v);
863f32 inverse_lerp_01(f32 a, f32 b, f32 v);
865f32 remap(f32 in_a, f32 in_b, f32 out_a, f32 out_b, f32 v);
866f32 remap_01(f32 in_a, f32 in_b, f32 out_a, f32 out_b, f32 v);
868f32 step(f32 edge, f32 x);
870f32 smoothstep(f32 t);
871f32 smoothstep_01(f32 t);
873f32 smootherstep(f32 t);
874f32 smootherstep_01(f32 t);
876f32 smoothstep(f32 edge0, f32 edge1, f32 x);
877f32 smoothstep_unclamped(f32 edge0, f32 edge1, f32 x);
879f32 smootherstep(f32 edge0, f32 edge1, f32 x);
880f32 smootherstep_unclamped(f32 edge0, f32 edge1, f32 x);
882f32 ease_linear(f32 t);
883f32 ease_linear_01(f32 t);
885f32 ease_in_quadratic(f32 t);
886f32 ease_out_quadratic(f32 t);
887f32 ease_in_out_quadratic(f32 t);
889f32 ease_in_cubic(f32 t);
890f32 ease_out_cubic(f32 t);
891f32 ease_in_out_cubic(f32 t);
893f32 ease_in_quartic(f32 t);
894f32 ease_out_quartic(f32 t);
895f32 ease_in_out_quartic(f32 t);
897f32 ease_in_quintic(f32 t);
898f32 ease_out_quintic(f32 t);
899f32 ease_in_out_quintic(f32 t);
901f32 ease_in_sine(f32 t);
902f32 ease_out_sine(f32 t);
903f32 ease_in_out_sine(f32 t);
905f32 ease_in_circular(f32 t);
906f32 ease_out_circular(f32 t);
907f32 ease_in_out_circular(f32 t);
909f32 ease_in_exponential(f32 t);
910f32 ease_out_exponential(f32 t);
911f32 ease_in_out_exponential(f32 t);
913f32 ease_in_back(f32 t, f32 overshoot = 1.70158f);
914f32 ease_out_back(f32 t, f32 overshoot = 1.70158f);
915f32 ease_in_out_back(f32 t, f32 overshoot = 1.70158f);
917f32 ease_in_elastic(f32 t);
918f32 ease_out_elastic(f32 t);
919f32 ease_in_out_elastic(f32 t);
921f32 ease_in_bounce(f32 t);
922f32 ease_out_bounce(f32 t);
923f32 ease_in_out_bounce(f32 t);
933f32 srgb_to_linear(f32 v);
934f32 linear_to_srgb(f32 v);
945f32 luminance_rec709(
const f32vec3& rgb);
946f32 luminance_rec709(
const f32vec4& rgba);
959f32 radians(f32 degrees);
960f32 degrees(f32 radians);
970f32 atan2(f32 y, f32 x);
980bool equal(f32 a, f32 b, f32 eps = F32_COMPARE_EPSILON);
992f32 pow(f32 x, f32 y);
1006constexpr T min(T a, T b) {
1007 return (b < a) ? b : a;
1011constexpr T max(T a, T b) {
1012 return (a < b) ? b : a;
1016constexpr T clamp(T v, T lo, T hi) {
1017 return (v < lo) ? lo : (hi < v) ? hi : v;
1021f32vec2 clamp_01(
const f32vec2& v);
1022f32vec3 clamp_01(
const f32vec3& v);
1023f32vec4 clamp_01(
const f32vec4& v);
1027f32 fmod(f32 x, f32 y);
1028f32 mod(f32 x, f32 y);
1029f32 wrap(f32 x, f32 lo, f32 hi);
1034bool is_infinite(f32 n);
1035bool is_finite(f32 n);
1036bool sign_bit(f32 n);
1040void swap(f32& a, f32& b);
1042template<
class T2, std::
size_t N>
1043void swap(T2 (&a)[N], T2 (&b)[N]) {
1044 for (std::size_t i = 0; i < N; ++i) {
1045 std::swap(a[i], b[i]);
const f32vec2 & operator[](std::size_t i) const
f32vec2 & operator[](std::size_t i)
f32vec3 & operator[](std::size_t i)
f32vec4 & operator[](std::size_t i)
f32 & operator[](std::size_t i)
f32 & operator[](std::size_t i)
f32 & operator[](std::size_t i)
f32 & operator[](std::size_t i)
i32 & operator[](std::size_t i)
const i32 & operator[](std::size_t i) const
i32 & operator[](std::size_t i)
const i32 & operator[](std::size_t i) const
i32 & operator[](std::size_t i)
u32 & operator[](std::size_t i)
u32 & operator[](std::size_t i)
u32 & operator[](std::size_t i)
u8 & operator[](std::size_t i)
u8 & operator[](std::size_t i)
u8 & operator[](std::size_t i)