vec: lerp for vec3 and vec4

This commit is contained in:
Recep Aslantas
2018-04-10 11:44:16 +03:00
parent 1fb82a1922
commit 416e2f4452
3 changed files with 59 additions and 0 deletions

View File

@@ -143,4 +143,19 @@ glm_clamp(float val, float minVal, float maxVal) {
return glm_min(glm_max(val, minVal), maxVal);
}
/*!
* @brief linear interpolation between two number
*
* formula: from + s * (to - from)
*
* @param[in] from from value
* @param[in] to to value
* @param[in] t interpolant (amount) clamped between 0 and 1
*/
CGLM_INLINE
float
glm_lerp(float from, float to, float t) {
return from + glm_clamp(t, 0.0f, 1.0f) * (to - from);
}
#endif /* cglm_util_h */