Last chance! 50% off unlimited learning
Sale ends in
Draw a geometric object on the current plot.
draw(x, ...)# S3 method for Triangle
draw(x, ...)
# S3 method for Circle
draw(x, npoints = 100L, ...)
# S3 method for Arc
draw(x, npoints = 100L, ...)
# S3 method for Ellipse
draw(x, npoints = 100L, ...)
# S3 method for EllipticalArc
draw(x, npoints = 100L, ...)
# S3 method for Line
draw(x, ...)
geometric object (Triangle
, Circle
, Line
,
Ellipse
, Arc
, EllipticalArc
)
arguments passed to lines
for a Triangle
object, an Arc
object or an ElipticalArc
object,
to polypath
for a Circle
object or an
Ellipse
object, general graphical parameters for a Line
object, passed to lines
, curve
, or
abline
.
integer, the number of points of the path
# open new plot window
plot(0, 0, type="n", asp = 1, xlim = c(0,2.5), ylim = c(0,2.5),
xlab = NA, ylab = NA)
grid()
# draw a triangle
t <- Triangle$new(c(0,0), c(1,0), c(0.5,sqrt(3)/2))
draw(t, col = "blue", lwd = 2)
draw(t$rotate(90, t$C), col = "green", lwd = 2)
# draw a circle
circ <- t$incircle()
draw(circ, col = "orange", border = "brown", lwd = 2)
# draw an ellipse
S <- Scaling$new(circ$center, direction = c(2,1), scale = 2)
draw(S$scaleCircle(circ), border = "grey", lwd = 2)
# draw a line
l <- Line$new(c(1,1), c(1.5,1.5), FALSE, TRUE)
draw(l, col = "red", lwd = 2)
perp <- l$perpendicular(c(2,1))
draw(perp, col = "yellow", lwd = 2)
Run the code above in your browser using DataLab