mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
update docs
This commit is contained in:
@@ -82,7 +82,11 @@ Currently *cglm* uses default clip space configuration (-1, 1) for camera functi
|
|||||||
- inline or pre-compiled function call
|
- inline or pre-compiled function call
|
||||||
- frustum (extract view frustum planes, corners...)
|
- frustum (extract view frustum planes, corners...)
|
||||||
- bounding box (AABB in Frustum (culling), crop, merge...)
|
- bounding box (AABB in Frustum (culling), crop, merge...)
|
||||||
|
- bounding sphere
|
||||||
- project, unproject
|
- project, unproject
|
||||||
|
- easing functions
|
||||||
|
- curves
|
||||||
|
- curve interpolation helpers (S*M*C, deCasteljau...)
|
||||||
- and other...
|
- and other...
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
@@ -47,3 +47,4 @@ Follow the :doc:`build` documentation for this
|
|||||||
call
|
call
|
||||||
sphere
|
sphere
|
||||||
curve
|
curve
|
||||||
|
bezier
|
||||||
|
|||||||
89
docs/source/bezier.rst
Normal file
89
docs/source/bezier.rst
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
.. default-domain:: C
|
||||||
|
|
||||||
|
Bezier
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
Header: cglm/bezier.h
|
||||||
|
|
||||||
|
Common helpers for cubic bezier and similar curves.
|
||||||
|
|
||||||
|
Table of contents (click to go):
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
|
||||||
|
1. :c:func:`glm_bezier`
|
||||||
|
2. :c:func:`glm_hermite`
|
||||||
|
3. :c:func:`glm_decasteljau`
|
||||||
|
|
||||||
|
Functions documentation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. c:function:: float glm_bezier(float s, float p0, float c0, float c1, float p1)
|
||||||
|
|
||||||
|
| cubic bezier interpolation
|
||||||
|
| formula:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
B(s) = P0*(1-s)^3 + 3*C0*s*(1-s)^2 + 3*C1*s^2*(1-s) + P1*s^3
|
||||||
|
|
||||||
|
| similar result using matrix:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
B(s) = glm_smc(t, GLM_BEZIER_MAT, (vec4){p0, c0, c1, p1})
|
||||||
|
|
||||||
|
| glm_eq(glm_smc(...), glm_bezier(...)) should return TRUE
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s** parameter between 0 and 1
|
||||||
|
| *[in]* **p0** begin point
|
||||||
|
| *[in]* **c0** control point 1
|
||||||
|
| *[in]* **c1** control point 2
|
||||||
|
| *[in]* **p1** end point
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
B(s)
|
||||||
|
|
||||||
|
.. c:function:: float glm_hermite(float s, float p0, float t0, float t1, float p1)
|
||||||
|
|
||||||
|
| cubic hermite interpolation
|
||||||
|
| formula:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
| similar result using matrix:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
H(s) = glm_smc(t, GLM_HERMITE_MAT, (vec4){p0, p1, c0, c1})
|
||||||
|
|
||||||
|
| glm_eq(glm_smc(...), glm_hermite(...)) should return TRUE
|
||||||
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **s** parameter between 0 and 1
|
||||||
|
| *[in]* **p0** begin point
|
||||||
|
| *[in]* **t0** tangent 1
|
||||||
|
| *[in]* **t1** tangent 2
|
||||||
|
| *[in]* **p1** end point
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
B(s)
|
||||||
|
|
||||||
|
.. c:function:: float glm_decasteljau(float prm, float p0, float c0, float c1, float p1)
|
||||||
|
|
||||||
|
| iterative way to solve cubic equation
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
| *[in]* **prm** parameter between 0 and 1
|
||||||
|
| *[in]* **p0** begin point
|
||||||
|
| *[in]* **c0** control point 1
|
||||||
|
| *[in]* **c1** control point 2
|
||||||
|
| *[in]* **p1** end point
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
parameter to use in cubic equation
|
||||||
@@ -75,7 +75,7 @@ glm_bezier(float s, float p0, float c0, float c1, float p1) {
|
|||||||
* @param[in] t1 tangent 2
|
* @param[in] t1 tangent 2
|
||||||
* @param[in] p1 end point
|
* @param[in] p1 end point
|
||||||
*
|
*
|
||||||
* @return B(s)
|
* @return H(s)
|
||||||
*/
|
*/
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
float
|
float
|
||||||
|
|||||||
Reference in New Issue
Block a user