This is a collection of procedures for performing computations on a B é zier curve.
Computes the length of a B é zier curve via
ℓ = ∫01∥B′(s)∥ ds.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param double* length
[Output] The computed length ℓ.
- param int* error_val
[Output] An error status passed along from
dqagse
(a QUADPACK procedure).Signature:
void BEZ_compute_length(const int *num_nodes, const int *dimension, const double *nodes, double *length, int *error_val);Example:
example_compute_length.c
Consider the line segment $B(s) = \left[\begin{array}{c} 3s \\ 4s \end{array}\right]$, we can verify the length:
example-compute-length, example-elevate-nodes-curve, example-evaluate-curve-barycentric, example-evaluate-hodograph, example-evaluate-multi, example-full-reduce, example-get-curvature, example-locate-point-curve, example-newton-refine-curve, example-reduce-pseudo-inverse, example-specialize-curve, example-subdivide-nodes-curve
import tests.utils
build_and_run_c = tests.utils.build_and_run_c
example-compute-length
build_and_run_c("example_compute_length.c")
example-compute-length
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_compute_length.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Length: 5.000000 Error value: 0
Degree-elevate a B é zier curve. Does so by producing control points of a higher degree that define the exact same curve.
See
.Curve.elevate
for more details.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param double* elevated
[Output] The control points of the degree-elevated curve as a D × (N + 1) array, laid out in Fortran order.
Signature:
void BEZ_elevate_nodes_curve(const int *num_nodes, const int *dimension, const double *nodes, double *elevated);Example:
After elevating $B(s) = \left[\begin{array}{c} 0 \\ 0 \end{array}\right] (1 - s)^2 + \frac{1}{2} \left[\begin{array}{c} 3 \\ 3 \end{array}\right] 2 (1 - s) s + \left[\begin{array}{c} 3 \\ 0 \end{array}\right] s^2$:
example_elevate_nodes_curve.c
we have $B(s) = \left[\begin{array}{c} 0 \\ 0 \end{array}\right] (1 - s)^3 + \left[\begin{array}{c} 1 \\ 1 \end{array}\right] 3 (1 - s)^2 s + \left[\begin{array}{c} 2 \\ 1 \end{array}\right] 3 (1 - s) s^2 + \left[\begin{array}{c} 3 \\ 0 \end{array}\right] s^3$:
example-elevate-nodes-curve
build_and_run_c("example_elevate_nodes_curve.c")
example-elevate-nodes-curve
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_elevate_nodes_curve.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Elevated: 0.000000, 1.000000, 2.000000, 3.000000 0.000000, 1.000000, 1.000000, 0.000000
For a B é zier curve with control points p0, …, pd, this evaluates the quantity
$$Q(\lambda_1, \lambda_2) = \sum_{j = 0}^d \binom{d}{j} \lambda_1^{d - j} \lambda_2^j p_j.$$ The typical case is barycentric, i.e. λ1 + λ2 = 1, but this is not required.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param num_vals
[Input] The number of values k where the quantity will be evaluated.
- type num_vals
const int*
- param lambda1
[Input] An array of k values used for the first parameter λ1.
- type lambda1
const double*
- param lambda2
[Input] An array of k values used for the second parameter λ2.
- type lambda2
const double*
- param double* evaluated
[Output] The evaluated quantites as a D × k array, laid out in Fortran order. Column j of
evaluated
will contain Q(λ1[j],λ2[j]).Signature:
void BEZ_evaluate_curve_barycentric(const int *num_nodes, const int *dimension, const double *nodes, const int *num_vals, const double *lambda1, const double *lambda2, double *evaluated);Example:
For the curve $B(s) = \left[\begin{array}{c} 0 \\ 1 \end{array}\right] (1 - s)^2 + \left[\begin{array}{c} 2 \\ 1 \end{array}\right] 2 (1 - s) s + \left[\begin{array}{c} 3 \\ 3 \end{array}\right] s^2 = \left[\begin{array}{c} s(4 - s) \\ 2s^2 + 1 \end{array}\right]$:
example_evaluate_curve_barycentric.c
we have
$$\begin{aligned} \begin{align*} Q\left(\frac{1}{4}, \frac{3}{4}\right) &= \frac{1}{16} \left[ \begin{array}{c} 39 \\ 34 \end{array}\right] \\\ Q\left(\frac{1}{2}, \frac{1}{4}\right) &= \frac{1}{16} \left[ \begin{array}{c} 11 \\ 11 \end{array}\right] \\\ Q\left(0, \frac{1}{2}\right) &= \frac{1}{4} \left[ \begin{array}{c} 3 \\ 3 \end{array}\right] \\\ Q\left(1, \frac{1}{4}\right) &= \frac{1}{16} \left[ \begin{array}{c} 19 \\ 27 \end{array}\right] \end{align*} \end{aligned}$$ example-evaluate-curve-barycentric
build_and_run_c("example_evaluate_curve_barycentric.c")
example-evaluate-curve-barycentric
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_evaluate_curve_barycentric.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Evaluated: 2.437500, 0.687500, 0.750000, 1.187500 2.125000, 0.687500, 0.750000, 1.687500
Evaluates the hodograph (or derivative) of a B é zier curve function B′(s).
- param s
[Input] The parameter s where the hodograph is being computed.
- type s
const double*
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param double* hodograph
[Output] The hodograph B′(s) as a D × 1 array.
Signature:
void BEZ_evaluate_hodograph(const double *s, const int *num_nodes, const int *dimension, const double *nodes, double *hodograph);Example:
For the curve $B(s) = \left[\begin{array}{c} 1 \\ 0 \end{array}\right] (1 - s)^3 + \left[\begin{array}{c} 1 \\ 1 \end{array}\right] 3 (1 - s)^2 s + \left[\begin{array}{c} 2 \\ 0 \end{array}\right] 3 (1 - s) s^2 + \left[\begin{array}{c} 2 \\ 1 \end{array}\right] s^3$:
example_evaluate_hodograph.c
we have $B'\left(\frac{1}{8}\right) = \frac{1}{32} \left[ \begin{array}{c} 21 \\ 54 \end{array}\right]$:
example-evaluate-hodograph
build_and_run_c("example_evaluate_hodograph.c")
example-evaluate-hodograph
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_evaluate_hodograph.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Hodograph: 0.656250 1.687500
Evaluate a B é zier curve function B(sj) at multiple values {sj}j.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param num_vals
[Input] The number of values k where the B(s) will be evaluated.
- type num_vals
const int*
- param s_vals
[Input] An array of k values sj.
- type s_vals
const double*
- param double* evaluated
[Output] The evaluated points as a D × k array, laid out in Fortran order. Column j of
evaluated
will contain B(sj).Signature:
void BEZ_evaluate_multi(const int *num_nodes, const int *dimension, const double *nodes, const int *num_vals, const double *s_vals, double *evaluated);Example:
For the curve $B(s) = \left[\begin{array}{c} 1 \\ 0 \end{array}\right] (1 - s)^3 + \left[\begin{array}{c} 1 \\ 1 \end{array}\right] 3 (1 - s)^2 s + \left[\begin{array}{c} 2 \\ 0 \end{array}\right] 3 (1 - s) s^2 + \left[\begin{array}{c} 2 \\ 1 \end{array}\right] s^3$:
example_evaluate_multi.c
we have $B\left(0\right) = \left[\begin{array}{c} 1 \\ 0 \end{array}\right], B\left(\frac{1}{2}\right) = \frac{1}{2} \left[\begin{array}{c} 3 \\ 1 \end{array}\right]$ and $B\left(1\right) = \left[\begin{array}{c} 2 \\ 1 \end{array}\right]$:
example-evaluate-multi
build_and_run_c("example_evaluate_multi.c")
example-evaluate-multi
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_evaluate_multi.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Evaluated: 1.000000, 1.500000, 2.000000 0.000000, 0.500000, 1.000000
Perform a "full" degree reduction. Does so by using :c
BEZ_reduce_pseudo_inverse
continually until the degree of the curve can no longer be reduced.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param num_reduced_nodes
[Output] The number of control points M of the fully reduced curve.
- type num_reduced_nodes
const int*
- param double* reduced
[Output] The control points of the fully reduced curve as a D × N array. The first M columns will contain the reduced nodes.
reduced
must be allocated by the caller and since M = N occurs when no reduction is possible, this array must be D × N.- param bool* not_implemented
[Output] Indicates if degree-reduction has been implemented for the current curve's degree. (Currently, the only degrees supported are 1, 2, 3 and 4.)
Signature:
void BEZ_full_reduce(const int *num_nodes, const int *dimension, const double *nodes, const int *num_reduced_nodes, double *reduced, bool *not_implemented);Example:
When taking a curve that is degree-elevated from linear to quartic:
example_full_reduce.c
this procedure reduces it to the line $B(s) = \left[\begin{array}{c} 1 \\ 3 \end{array}\right] (1 - s) + \left[\begin{array}{c} 2 \\ 5 \end{array}\right] s = \left[\begin{array}{c} 1 + s \\ 3 + 2s \end{array}\right]$:
example-full-reduce
build_and_run_c("example_full_reduce.c")
example-full-reduce
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_full_reduce.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Number of reduced nodes: 2 Reduced: 1.000000, 2.000000 3.000000, 5.000000 Not implemented: FALSE
Get the signed curvature of a B é zier curve at a point. See
._py_curve_helpers.get_curvature
for more details.Note
This only computes curvature for plane curves (i.e. curves in R2). An equivalent notion of curvature exists for space curves, but support for that is not implemented here.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param nodes
[Input] The actual control points of the curve as a 2 × N array. This should be laid out in Fortran order, with 2N total values.
- type nodes
const double*
- param tangent_vec
[Input] The hodograph B′(s) as a 2 × 1 array. Note that this could be computed once s and B are known, but this allows the caller to re-use an already computed tangent vector.
- type tangent_vec
const double*
- param s
[Input] The parameter s where the curvature is being computed.
- type s
const double*
- param double* curvature
[Output] The signed curvature κ.
Signature:
void BEZ_get_curvature(const int *num_nodes, const double *nodes, const double *tangent_vec, const double *s, double *curvature);Example:
example_get_curvature.c
example-get-curvature
build_and_run_c("example_get_curvature.c")
example-get-curvature
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_get_curvature.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Curvature: -12.000000
This solves the inverse problem B(s) = p (if it can be solved). Does so by subdividing the curve until the segments are sufficiently small, then using Newton's method to narrow in on the pre-image of the point.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param point
[Input] The point p as a D × 1 array.
- type point
const double*
- param double* s_approx
[Output] The parameter s of the solution. If p can't be located on the curve, then
s_approx = -1.0
. If there are multiple parameters that satisfy B(s) = p (indicating that B(s) has a self-crossing) thens_approx = -2.0
.Signature:
void BEZ_locate_point_curve(const int *num_nodes, const int *dimension, const double *nodes, const double *point, double *s_approx);Example:
For $B(s) = \left[\begin{array}{c} 0 \\ 2 \end{array}\right] (1 - s)^3 + \left[\begin{array}{c} -1 \\ 0 \end{array}\right] 3 (1 - s)^2 s + \left[\begin{array}{c} 1 \\ 1 \end{array}\right] 3 (1 - s) s^2 + \frac{1}{8} \left[\begin{array}{c} -6 \\ 13 \end{array}\right] s^3$:
example_locate_point_curve.c
We can locate the point $B\left(\frac{1}{2}\right) = \frac{1}{64} \left[\begin{array}{c} -6 \\ 53 \end{array}\right]$ but find that $\frac{1}{2} \left[\begin{array}{c} 0 \\ 3 \end{array}\right]$ is not on the curve and that
$$\begin{aligned} B\left(\frac{3 - \sqrt{5}}{6}\right) = B\left(\frac{3 + \sqrt{5}}{6}\right) = \frac{1}{8} \left[ \begin{array}{c} -2 \\ 11 \end{array}\right] \end{aligned}$$ is a self-crossing:
example-locate-point-curve
build_and_run_c("example_locate_point_curve.c")
example-locate-point-curve
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_locate_point_curve.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example When B(s) = [-0.093750, 0.828125]; s = 0.500000 When B(s) = [ 0.000000, 1.500000]; s = -1.000000 When B(s) = [-0.250000, 1.375000]; s = -2.000000
This refines a solution to B(s) = p using Newton's method. Given a current approximation sn for a solution, this produces the updated approximation via
$$s_{n + 1} = s_n - \frac{B'(s_n)^T \left[B(s_n) - p\right]}{ B'(s_n)^T B'(s_n)}.$$
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param point
[Input] The point p as a D × 1 array.
- type point
const double*
- param s
[Input] The parameter sn of the current approximation of a solution.
- type s
const double*
- param double* updated_s
[Output] The parameter sn + 1 of the updated approximation.
Signature:
void BEZ_newton_refine_curve(const int *num_nodes, const int *dimension, const double *nodes, const double *point, const double *s, double *updated_s);Example:
When trying to locate $B\left(\frac{1}{4}\right) = \frac{1}{16} \left[\begin{array}{c} 9 \\ 13 \end{array}\right]$ on the curve $B(s) = \left[\begin{array}{c} 0 \\ 0 \end{array}\right] (1 - s)^2 + \left[\begin{array}{c} 1 \\ 2 \end{array}\right] 2 (1 - s) s + \left[\begin{array}{c} 3 \\ 1 \end{array}\right] s^2$, starting at
$s = \frac{3}{4}$ :example_newton_refine_curve.c
we expect a Newton update
$\Delta s = -\frac{2}{5}$ , which produces a new parameter value$s = \frac{7}{20}$ :example-newton-refine-curve
build_and_run_c("example_newton_refine_curve.c")
example-newton-refine-curve
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_newton_refine_curve.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Updated s: 0.350000
Perform a pseudo inverse to :c
BEZ_elevate_nodes_curve
. If an inverse can be found, i.e. if a curve can be degree-reduced, then this will produce the equivalent curve of lower degree. If no inverse can be found, then this will produce the "best" answer in the least squares sense.
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param double* reduced
[Output] The control points of the degree-(pseudo)reduced curve D × (N − 1) array, laid out in Fortran order.
- param bool* not_implemented
[Output] Indicates if degree-reduction has been implemented for the current curve's degree. (Currently, the only degrees supported are 1, 2, 3 and 4.)
Signature:
void BEZ_reduce_pseudo_inverse(const int *num_nodes, const int *dimension, const double *nodes, double *reduced, bool *not_implemented);Example:
After reducing $B(s) = \left[\begin{array}{c} -3 \\ 3 \end{array}\right] (1 - s)^3 + \left[\begin{array}{c} 0 \\ 2 \end{array}\right] 3 (1 - s)^2 s + \left[\begin{array}{c} 1 \\ 3 \end{array}\right] 3 (1 - s) s^2 + \left[\begin{array}{c} 0 \\ 6 \end{array}\right] s^3$:
example_reduce_pseudo_inverse.c
we get the valid quadratic representation of $B(s) = \left[\begin{array}{c} 3(1 - s)(2s - 1) \\ 3(2s^2 - s + 1) \end{array}\right]$:
example-reduce-pseudo-inverse
build_and_run_c("example_reduce_pseudo_inverse.c")
example-reduce-pseudo-inverse
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_reduce_pseudo_inverse.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Reduced: -3.000000, 1.500000, 0.000000 3.000000, 1.500000, 6.000000 Not implemented: FALSE
Specialize a B é zier curve to an interval [a,b]. This produces the control points for the curve given by B(a+(b−a)s).
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param start
[Input] The start a of the specialized interval.
- type start
const double*
- param end
[Input] The end b of the specialized interval.
- type end
const double*
- param double* new_nodes
[Output] The control points of the specialized curve, as a D × N array, laid out in Fortran order.
Signature:
void BEZ_specialize_curve(const int *num_nodes, const int *dimension, const double *nodes, const double *start, const double *end, double *new_nodes);Example:
When we specialize the curve $B(s) = \left[\begin{array}{c} 0 \\ 0 \end{array}\right] (1 - s)^2 + \frac{1}{2} \left[\begin{array}{c} 1 \\ 2 \end{array}\right] 2 (1 - s) s + \left[\begin{array}{c} 1 \\ 0 \end{array}\right] s^2 = \left[\begin{array}{c} s \\ 2s(1 - s) \end{array}\right]$ to the interval
$\left[-\frac{1}{4}, \frac{3}{4}\right]$ :example_specialize_curve.c
we get the specialized curve $S(t) = \frac{1}{8} \left[ \begin{array}{c} -2 \\ -5 \end{array}\right] (1 - s)^2 + \frac{1}{8} \left[\begin{array}{c} 2 \\ 7 \end{array}\right] 2 (1 - s) s + \frac{1}{8} \left[\begin{array}{c} 6 \\ 3 \end{array}\right] s^2 = \frac{1}{8} \left[\begin{array}{c} 2(4t - 1) \\ (4t - 1)(5 - 4t) \end{array}\right]$, which still lies on y = 2x(1 − x):
example-specialize-curve
build_and_run_c("example_specialize_curve.c")
example-specialize-curve
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_specialize_curve.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example New Nodes: -0.250000, 0.250000, 0.750000 -0.625000, 0.875000, 0.375000
Split a B é zier curve into two halves
$B\left(\left[0, \frac{1}{2}\right]\right)$ and$B\left(\left[\frac{1}{2}, 1\right]\right)$ .
- param num_nodes
[Input] The number of control points N of a B é zier curve.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the curve lies in RD.
- type dimension
const int*
- param nodes
[Input] The actual control points of the curve as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param double* left_nodes
[Output] The control points of the left half curve
$B\left(\left[0, \frac{1}{2}\right]\right)$ as a D × N array, laid out in Fortran order.- param double* right_nodes
[Output] The control points of the right half curve
$B\left(\left[\frac{1}{2}, 1\right]\right)$ as a D × N array, laid out in Fortran order.Signature:
void BEZ_subdivide_nodes_curve(const int *num_nodes, const int *dimension, const double *nodes, double *left_nodes, double *right_nodes);Example:
For example, subdividing the curve $B(s) = \left[\begin{array}{c} 0 \\ 0 \end{array}\right] (1 - s)^2 + \frac{1}{4} \left[\begin{array}{c} 5 \\ 12 \end{array}\right] 2 (1 - s) s + \left[\begin{array}{c} 2 \\ 1 \end{array}\right] s^2$:
example_subdivide_nodes_curve.c
yields:
example-subdivide-nodes-curve
build_and_run_c("example_subdivide_nodes_curve.c")
example-subdivide-nodes-curve
$ INCLUDE_DIR=.../libbezier-release/usr/include $ LIB_DIR=.../libbezier-release/usr/lib $ gcc > -o example > example_subdivide_nodes_curve.c > -I "${INCLUDE_DIR}" > -L "${LIB_DIR}" > -Wl,-rpath,"${LIB_DIR}" > -lbezier > -lm -lgfortran $ ./example Left Nodes: 0.000000, 0.625000, 1.125000 0.000000, 1.500000, 1.750000 Right Nodes: 1.125000, 1.625000, 2.000000 1.750000, 2.000000, 1.000000