1 #ifndef _DRAGONTYPE_NUMBER_H_
2 #define _DRAGONTYPE_NUMBER_H_
7 #define DEFINE_CLAMP(type) \
8 type type ## _clamp(type v, type min, type max);
10 #define DEFINE_MIX(scalar, type) \
11 type type ## _mix(type a, type b, scalar f);
13 #define DEFINE_VECTOR(scalar, vector, box) vector; \
14 typedef struct {vector min; vector max;} box; \
15 bool vector ## _equals(vector a, vector b); \
16 vector vector ## _add(vector a, vector b); \
17 vector vector ## _clamp(vector v, vector min, vector max); \
20 #define DEFINE_VECTORS(scalar) \
21 typedef struct {scalar x, y ;} DEFINE_VECTOR(scalar, v2 ## scalar, aabb2 ## scalar) \
22 typedef struct {scalar x, y, z ;} DEFINE_VECTOR(scalar, v3 ## scalar, aabb3 ## scalar) \
23 typedef struct {scalar x, y, z, w;} DEFINE_VECTOR(scalar, v4 ## scalar, aabb4 ## scalar)
25 #define DEFINE_SCALAR(scalar, origin) \
26 typedef origin scalar; \
27 scalar scalar ## _max(scalar a, scalar b); \
28 scalar scalar ## _min(scalar a, scalar b); \
29 DEFINE_CLAMP(scalar) \
30 DEFINE_VECTORS(scalar)
32 #define DEFINE_INTEGER(bits) \
33 DEFINE_SCALAR(s ## bits, int ## bits ## _t) \
34 DEFINE_SCALAR(u ## bits, uint ## bits ## _t)
36 #define DEFINE_FLOAT(type, origin) \
37 DEFINE_SCALAR(type, origin) \
38 DEFINE_MIX(type, type) \
39 DEFINE_MIX(type, v2 ## type) \
40 DEFINE_MIX(type, v3 ## type) \
41 DEFINE_MIX(type, v4 ## type)
48 DEFINE_FLOAT(f32, float)
49 DEFINE_FLOAT(f64, double)