bezier {fastmatrix} | R Documentation |
Computation of Bezier curve
Description
Computes the Bezier curve based on control points using the De Casteljau's method.
Usage
bezier(x, y, ngrid = 200)
Arguments
x , y |
vector giving the coordinates of the control points. Missing values are deleted. |
ngrid |
number of elements in the grid used to compute the smoother. |
Details
Given control points the Bezier curve is given by
defined as
where . To evaluate the Bezier curve the De Casteljau's method is used.
Value
A list containing xgrid
and ygrid
elements used to plot the Bezier curve.
Examples
# a tiny example
x <- c(1.0, 0.25, 1.25, 2.5, 4.00, 5.0)
y <- c(0.5, 2.00, 3.75, 4.0, 3.25, 1.0)
plot(x, y, type = "o")
z <- bezier(x, y, ngrid = 50)
lines(z$xgrid, z$ygrid, lwd = 2, lty = 2, col = "red")
# other simple example
x <- c(4,6,4,5,6,7)
y <- 1:6
plot(x, y, type = "o")
z <- bezier(x, y, ngrid = 50)
lines(z$xgrid, z$ygrid, lwd = 2, lty = 2, col = "red")
[Package fastmatrix version 0.5-772 Index]