curve.h 914 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c), Recep Aslantas.
  3. *
  4. * MIT License (MIT), http://opensource.org/licenses/MIT
  5. * Full license can be found in the LICENSE file
  6. */
  7. #ifndef cglm_curve_h
  8. #define cglm_curve_h
  9. #include "common.h"
  10. #include "vec4.h"
  11. #include "mat4.h"
  12. /*!
  13. * @brief helper function to calculate S*M*C multiplication for curves
  14. *
  15. * This function does not encourage you to use SMC,
  16. * instead it is a helper if you use SMC.
  17. *
  18. * if you want to specify S as vector then use more generic glm_mat4_rmc() func.
  19. *
  20. * Example usage:
  21. * B(s) = glm_smc(s, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1})
  22. *
  23. * @param[in] s parameter between 0 and 1 (this will be [s3, s2, s, 1])
  24. * @param[in] m basis matrix
  25. * @param[in] c position/control vector
  26. *
  27. * @return B(s)
  28. */
  29. CGLM_INLINE
  30. float
  31. glm_smc(float s, mat4 m, vec4 c) {
  32. vec4 vs;
  33. glm_vec4_cubic(s, vs);
  34. return glm_mat4_rmc(vs, m, c);
  35. }
  36. #endif /* cglm_curve_h */