jc/math/module.jai

60 lines
1.8 KiB
Text

#module_parameters(
UNITS: enum { radians; degrees; turns; } = .turns,
RECT_TYPE: Type = float,
// RECT_METHOD: enum { dimension; absolute; } = absolute, // Note(Jesse): Maybe at a later point we can do this
RUN_TESTS := false
);
#assert meta.type_is_scalar(RECT_TYPE);
// @todo(judah): dumb we can't use meta.range_for here.
U8_Min, U8_Max :: #run meta.lo_for(u8), #run meta.hi_for(u8);
U16_Min, U16_Max :: #run meta.lo_for(u16), #run meta.hi_for(u16);
U32_Min, U32_Max :: #run meta.lo_for(u32), #run meta.hi_for(u32);
U64_Min, U64_Max :: #run meta.lo_for(u64), #run meta.hi_for(u64);
S8_Min, S8_Max :: #run meta.lo_for(s8), #run meta.hi_for(s8);
S16_Min, S16_Max :: #run meta.lo_for(s16), #run meta.hi_for(s16);
S32_Min, S32_Max :: #run meta.lo_for(s32), #run meta.hi_for(s32);
S64_Min, S64_Max :: #run meta.lo_for(s64), #run meta.hi_for(s64);
F32_Min, F32_Max :: #run meta.lo_for(float32), #run meta.hi_for(float32);
F64_Min, F64_Max :: #run meta.lo_for(float64), #run meta.hi_for(float64);
#load "common.jai";
#load "vec.jai";
#load "mat.jai";
#load "ease.jai";
#load "shape.jai";
#scope_module;
meta :: #import "jc/meta";
math :: #import "Math"; // @future
basic :: #import "Basic"; // @future
#if RUN_TESTS {
test :: #import "jc/test";
}
// @temp(judah): move these to the right files
v2_eq :: (a: Vec2, b: Vec2) -> bool {
return float_eq(a.x, b.x) && float_eq(a.y, b.y);
}
v3_eq :: (a: Vec3, b: Vec3) -> bool {
return float_eq(a.x, b.x) && float_eq(a.y, b.y) && float_eq(a.z, b.z);
}
v4_eq :: (a: Vec4, b: Vec4) -> bool {
return float_eq(a.x, b.x) && float_eq(a.y, b.y) && float_eq(a.z, b.z) && float_eq(a.w, b.w);
}
// Smallest difference where a float is basically that value
EPSILON :: 0.001;
float_eq :: (f: float, with: float) -> bool {
return f > with - EPSILON && f < with + EPSILON;
}