bcurve | R Documentation |
nD B-curve governed by (x,y,...) control points.
bcurve(xy, n = 3)
xy |
Real matrix of (x,y,...) coordinates, one control point per row. |
n |
Integer scalar, polynomial order of B-spline (3 by default) |
The curve will pass by the first and the last points in 'xy'. The tangents at the first and last points will coincide with the first and last segments of control points. Example of signature is inspired from this blog.
Function of one argument calculating B-curve. The argument is supposed to be in [0, 1] interval.
# simulate doctor's signature ;)
set.seed(71);
xy=matrix(rnorm(16), ncol=2)
tp=seq(0,1,len=301)
doc_signtr=bcurve(xy)
plot(doc_signtr(tp), t="l", xaxt='n', yaxt='n', ann=FALSE, frame.plot=FALSE,
xlim=range(xy[,1]), ylim=range(xy[,2]))
# see where control points are
text(xy, labels=seq(nrow(xy)), col=rgb(0, 0, 0, 0.25))
# join them by segments
lines(bcurve(xy, n=1)(tp), col=rgb(0, 0, 1, 0.25))
# randomly curved wire in 3D space
## Not run:
if (requireNamespace("rgl", quietly=TRUE)) {
xyz=matrix(rnorm(24),ncol=3)
tp=seq(0,1,len=201)
curv3d=bcurve(xyz)
rgl::plot3d(curv3d(tp), t="l", decorate=FALSE)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.