Learn R Programming

DescTools (version 0.99.37)

DrawBezier: Draw a Bezier Curve

Description

Draw a Bezier curve.

Usage

DrawBezier(x = 0, y = x, nv = 100, col = par("col"), lty = par("lty"), 
           lwd = par("lwd"), plot = TRUE)

Arguments

x, y

a vector of xy-coordinates to define the Bezier curve. Should at least contain 3 points.

nv

number of vertices to draw the curve.

col

color(s) for the curve. Default is par("fg").

lty

line type for borders and shading; defaults to "solid".

lwd

line width for borders and shading.

plot

logical. If TRUE the structure will be plotted. If FALSE only the xy-points are calculated and returned. Use this if you want to combine several geometric structures to a single polygon.

Value

DrawBezier invisibly returns a list of the calculated coordinates for all shapes.

Details

Bezier curves appear in such areas as mechanical computer aided design (CAD). They are named after P. Bezier, who used a closely related representation in Renault's UNISURF CAD system in the early 1960s (similar, unpublished, work was done by P. de Casteljau at Citroen in the late 1950s and early 1960s). The 1970s and 1980s saw a flowering of interest in Bezier curves, with many CAD systems using them, and many important developments in their theory. The usefulness of Bezier curves resides in their many geometric and analytical properties. There are elegant and efficient algorithms for evaluation, differentiation, subdivision of the curves, and conversion to other useful representations. (See: Farin, 1993)

References

G. Farin (1993) Curves and surfaces for computer aided geometric design. A practical guide, Acad. Press

See Also

polygon, DrawRegPolygon, DrawCircle, DrawArc

Examples

Run this code
# NOT RUN {
Canvas(xlim=c(0,1))
grid()
DrawBezier( x=c(0,0.5,1), y=c(0,0.5,0), col="blue", lwd=2)
DrawBezier( x=c(0,0.5,1), y=c(0,1,0), col="red", lwd=2)
DrawBezier( x=c(0,0.25,0.5,0.75,1), y=c(0,1,1,1,0), col="darkgreen", lwd=2)
# }

Run the code above in your browser using DataLab