diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 22:22:24 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 22:22:24 -0700 |
commit | 0018bb69e154aa326dc09f343a50ceee1e267f99 (patch) | |
tree | a7d964ea6931531e020a58e7817c35e545db15d9 /v2f.h | |
parent | 103d41a979132e3a541c622c1874de0781b2516f (diff) |
v2f: add nearest integrals: v2f_ceil()/v2f_floor()
Diffstat (limited to 'v2f.h')
-rw-r--r-- | v2f.h | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -295,4 +295,40 @@ static inline v2f_t * v2f_rand(v2f_t *res, const v2f_t *min, const v2f_t *max) return res; } + +static inline v2f_t _v2f_ceil(const v2f_t *v) +{ + return (v2f_t){ + .x = ceilf(v->x), + .y = ceilf(v->y), + }; +} + + +static inline v2f_t * v2f_ceil(v2f_t *res, const v2f_t *v) +{ + if (_v2f_allocated(&res)) + *res = _v2f_ceil(v); + + return res; +} + + +static inline v2f_t _v2f_floor(const v2f_t *v) +{ + return (v2f_t){ + .x = floorf(v->x), + .y = floorf(v->y), + }; +} + + +static inline v2f_t * v2f_floor(v2f_t *res, const v2f_t *v) +{ + if (_v2f_allocated(&res)) + *res = _v2f_floor(v); + + return res; +} + #endif |