Description Usage Arguments Details Value Author(s) References See Also Examples
Compute the Bezier function of a collection of polynomials. By Bezier function we mean the Bezier curve function, a parametric map running from t = 0, the first point, to t = 1, the last point, where the coordinate mappings are linear combinations of Bernstein polynomials.
1 2 3 | bezier_function(points, weights = rep(1L, nrow(points)))
bezierFunction(...)
|
points |
a matrix or data frame of numerics. the rows represent points. |
weights |
the weights in a weighted Bezier curve |
... |
...; used internally |
The function returned is vectorized and evaluates the Bezier curve in a numerically stable way with de Castlejau's algorithm (implemented in R).
function of a single parameter
David Kahle
http://en.wikipedia.org/wiki/Bezier_curve, http://en.wikipedia.org/wiki/De_Casteljau's_algorithm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | library(ggplot2); theme_set(theme_bw())
t <- seq(0, 1, length.out = 201)
points <- data.frame(x = 0:3, y = c(0,1,-1,0))
f <- bezier_function(points)
df <- as.data.frame(f(t))
ggplot(aes(x = x, y = y), data = df) +
geom_point(data = points, color = "red", size = 8) +
geom_path(data = points, color = "red") +
geom_path()
f <- bezier_function(points, weights = c(1,5,5,1))
df <- as.data.frame(f(t))
ggplot(aes(x = x, y = y), data = df) +
geom_point(data = points, color = "red", size = 8) +
geom_path(data = points, color = "red") +
geom_path()
f <- bezier_function(points, weights = c(1,10,10,1))
df <- as.data.frame(f(t))
ggplot(aes(x = x, y = y), data = df) +
geom_point(data = points, color = "red", size = 8) +
geom_path(data = points, color = "red") +
geom_path()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.