bezier.rst 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .. default-domain:: C
  2. Bezier
  3. ================================================================================
  4. Header: cglm/bezier.h
  5. Common helpers for cubic bezier and similar curves.
  6. Table of contents (click to go):
  7. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. Functions:
  9. 1. :c:func:`glm_bezier`
  10. 2. :c:func:`glm_hermite`
  11. 3. :c:func:`glm_decasteljau`
  12. Functions documentation
  13. ~~~~~~~~~~~~~~~~~~~~~~~
  14. .. c:function:: float glm_bezier(float s, float p0, float c0, float c1, float p1)
  15. | cubic bezier interpolation
  16. | formula:
  17. .. code-block:: text
  18. B(s) = P0*(1-s)^3 + 3*C0*s*(1-s)^2 + 3*C1*s^2*(1-s) + P1*s^3
  19. | similar result using matrix:
  20. .. code-block:: text
  21. B(s) = glm_smc(t, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1})
  22. | glm_eq(glm_smc(...), glm_bezier(...)) should return TRUE
  23. Parameters:
  24. | *[in]* **s** parameter between 0 and 1
  25. | *[in]* **p0** begin point
  26. | *[in]* **c0** control point 1
  27. | *[in]* **c1** control point 2
  28. | *[in]* **p1** end point
  29. Returns:
  30. B(s)
  31. .. c:function:: float glm_hermite(float s, float p0, float t0, float t1, float p1)
  32. | cubic hermite interpolation
  33. | formula:
  34. .. code-block:: text
  35. H(s) = P0*(2*s^3 - 3*s^2 + 1) + T0*(s^3 - 2*s^2 + s) + P1*(-2*s^3 + 3*s^2) + T1*(s^3 - s^2)
  36. | similar result using matrix:
  37. .. code-block:: text
  38. H(s) = glm_smc(t, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1})
  39. | glm_eq(glm_smc(...), glm_hermite(...)) should return TRUE
  40. Parameters:
  41. | *[in]* **s** parameter between 0 and 1
  42. | *[in]* **p0** begin point
  43. | *[in]* **t0** tangent 1
  44. | *[in]* **t1** tangent 2
  45. | *[in]* **p1** end point
  46. Returns:
  47. B(s)
  48. .. c:function:: float glm_decasteljau(float prm, float p0, float c0, float c1, float p1)
  49. | iterative way to solve cubic equation
  50. Parameters:
  51. | *[in]* **prm** parameter between 0 and 1
  52. | *[in]* **p0** begin point
  53. | *[in]* **c0** control point 1
  54. | *[in]* **c1** control point 2
  55. | *[in]* **p1** end point
  56. Returns:
  57. parameter to use in cubic equation