diff options
| author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 19:04:04 -0700 | 
|---|---|---|
| committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-06 20:22:19 -0700 | 
| commit | 107d688e7262db5731041294df3d57b0cfd89566 (patch) | |
| tree | 31c0cba4ab4692bd26bdc6ead894f5994a6c746a | |
| parent | a1be48106253be3644148d56dae122a67958c4ff (diff) | |
v3f: add bi-linear interpolation: v3f_bilerp()
| -rw-r--r-- | v3f.h | 28 | 
1 files changed, 28 insertions, 0 deletions
| @@ -209,6 +209,34 @@ static inline v3f_t * v3f_nlerp(v3f_t *res, const v3f_t *a, const v3f_t *b, floa  } +/* + *       1 ab-------bb + *       | |         | + *       | |         | + *       | |         | + *       0 aa-------ba + *  t_x:   0---------1 + *       ^ + *       t_y + */ +static inline v3f_t _v3f_bilerp(const v3f_t *aa, const v3f_t *ab, const v3f_t *ba, const v3f_t *bb, float t_x, float t_y) +{ +	v3f_t	xa = _v3f_lerp(aa, ba, t_x); +	v3f_t	xb = _v3f_lerp(ab, bb, t_x); + +	return _v3f_lerp(&xa, &xb, t_y); +} + + +static inline v3f_t * v3f_bilerp(v3f_t *res, const v3f_t *aa, const v3f_t *ab, const v3f_t *ba, const v3f_t *bb, float t_x, float t_y) +{ +	if (_v3f_allocated(&res)) +		*res = _v3f_bilerp(aa, ab, ba, bb, t_x, t_y); + +	return res; +} + +  static inline v3f_t _v3f_cross(const v3f_t *a, const v3f_t *b)  {  	return (v3f_t){ | 
