diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 21:08:40 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 21:08:40 -0700 |
commit | 86f26e03952d306c3b971a7919a7e1f89883ce47 (patch) | |
tree | 660ecfa6e9474371ccdb82ffafbf1a5619ad8c06 /v3f.h | |
parent | 96f83e33c523a91093825f4dc1ed6e79315d1578 (diff) |
v3f: add nearest integrals: v3f_ceil()/v3f_floor()
Diffstat (limited to 'v3f.h')
-rw-r--r-- | v3f.h | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -316,4 +316,41 @@ static inline v3f_t * v3f_rand(v3f_t *res, const v3f_t *min, const v3f_t *max) } +static inline v3f_t _v3f_ceil(const v3f_t *v) +{ + return (v3f_t){ + .x = ceilf(v->x), + .y = ceilf(v->y), + .z = ceilf(v->z), + }; +} + + +static inline v3f_t * v3f_ceil(v3f_t *res, const v3f_t *v) +{ + if (_v3f_allocated(&res)) + *res = _v3f_ceil(v); + + return res; +} + + +static inline v3f_t _v3f_floor(const v3f_t *v) +{ + return (v3f_t){ + .x = floorf(v->x), + .y = floorf(v->y), + .z = floorf(v->z), + }; +} + + +static inline v3f_t * v3f_floor(v3f_t *res, const v3f_t *v) +{ + if (_v3f_allocated(&res)) + *res = _v3f_floor(v); + + return res; +} + #endif |