summaryrefslogtreecommitdiff
path: root/v3f.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-05-06 21:08:40 -0700
committerVito Caputo <vcaputo@pengaru.com>2019-05-06 21:08:40 -0700
commit86f26e03952d306c3b971a7919a7e1f89883ce47 (patch)
tree660ecfa6e9474371ccdb82ffafbf1a5619ad8c06 /v3f.h
parent96f83e33c523a91093825f4dc1ed6e79315d1578 (diff)
v3f: add nearest integrals: v3f_ceil()/v3f_floor()
Diffstat (limited to 'v3f.h')
-rw-r--r--v3f.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/v3f.h b/v3f.h
index d169e76..9c1d6e4 100644
--- a/v3f.h
+++ b/v3f.h
@@ -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
© All Rights Reserved