diff options
Diffstat (limited to 'v2f.h')
-rw-r--r-- | v2f.h | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -30,24 +30,56 @@ static inline v2f_t v2f_add(const v2f_t *a, const v2f_t *b) } +static inline v2f_t * pv2f_add(const v2f_t *a, const v2f_t *b, v2f_t *res) +{ + *res = v2f_add(a, b); + + return res; +} + + static inline v2f_t v2f_sub(const v2f_t *a, const v2f_t *b) { return (v2f_t){a->x - b->x, a->y - b->y}; } +static inline v2f_t * pv2f_sub(const v2f_t *a, const v2f_t *b, v2f_t *res) +{ + *res = v2f_sub(a, b); + + return res; +} + + static inline v2f_t v2f_mult(const v2f_t *a, const v2f_t *b) { return (v2f_t){a->x * b->x, a->y * b->y}; } +static inline v2f_t * pv2f_mult(const v2f_t *a, const v2f_t *b, v2f_t *res) +{ + *res = v2f_mult(a, b); + + return res; +} + + static inline v2f_t v2f_mult_scalar(const v2f_t *v, float scalar) { return (v2f_t){ v->x * scalar, v->y * scalar }; } +static inline v2f_t * pv2f_mult_scalar(const v2f_t *v, float scalar, v2f_t *res) +{ + *res = v2f_mult_scalar(v, scalar); + + return res; +} + + static inline float v2f_dot(const v2f_t *a, const v2f_t *b) { return a->x * b->x + a->y * b->y; @@ -66,6 +98,14 @@ static inline v2f_t v2f_normalize(const v2f_t *v) } +static inline v2f_t * pv2f_normalize(const v2f_t *v, v2f_t *res) +{ + *res = v2f_normalize(v); + + return res; +} + + static inline v2f_t v2f_lerp(const v2f_t *a, const v2f_t *b, float t) { v2f_t lerp_a, lerp_b; @@ -77,6 +117,14 @@ static inline v2f_t v2f_lerp(const v2f_t *a, const v2f_t *b, float t) } +static inline v2f_t * pv2f_lerp(const v2f_t *a, const v2f_t *b, float t, v2f_t *res) +{ + *res = v2f_lerp(a, b, t); + + return res; +} + + static inline v2f_t v2f_nlerp(const v2f_t *a, const v2f_t *b, float t) { v2f_t lerp = v2f_lerp(a, b, t); @@ -84,4 +132,12 @@ static inline v2f_t v2f_nlerp(const v2f_t *a, const v2f_t *b, float t) return v2f_normalize(&lerp); } + +static inline v2f_t * pv2f_nlerp(const v2f_t *a, const v2f_t *b, float t, v2f_t *res) +{ + *res = v2f_nlerp(a, b, t); + + return res; +} + #endif |