diff options
Diffstat (limited to 'v2f.h')
-rw-r--r-- | v2f.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -277,4 +277,22 @@ static inline v2f_t * v2f_trilerp(v2f_t *res, const v2f_t *aaa, const v2f_t *aba return res; } + +static inline v2f_t _v2f_rand(const v2f_t *min, const v2f_t *max) +{ + return (v2f_t){ + .x = min->x + (float)rand() * (1.f/RAND_MAX) * (max->x - min->x), + .y = min->y + (float)rand() * (1.f/RAND_MAX) * (max->y - min->y), + }; +} + + +static inline v2f_t * v2f_rand(v2f_t *res, const v2f_t *min, const v2f_t *max) +{ + if (_v2f_allocated(&res)) + *res = _v2f_rand(min, max); + + return res; +} + #endif |