summaryrefslogtreecommitdiff
path: root/v2f.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-05-06 22:22:24 -0700
committerVito Caputo <vcaputo@pengaru.com>2019-05-06 22:22:24 -0700
commit0018bb69e154aa326dc09f343a50ceee1e267f99 (patch)
treea7d964ea6931531e020a58e7817c35e545db15d9 /v2f.h
parent103d41a979132e3a541c622c1874de0781b2516f (diff)
v2f: add nearest integrals: v2f_ceil()/v2f_floor()
Diffstat (limited to 'v2f.h')
-rw-r--r--v2f.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/v2f.h b/v2f.h
index 44a4985..5d1cbbc 100644
--- a/v2f.h
+++ b/v2f.h
@@ -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
© All Rights Reserved