| disc | R Documentation |
Creates a circular window
disc(radius=1, centre=c(0,0), ...,
mask=FALSE, npoly=128, delta=NULL,
type=c("inscribed", "circumscribed", "approx"),
metric=NULL)
radius |
Radius of the circle. |
centre |
The centre of the circle. |
mask |
Logical flag controlling the type of approximation to a perfect circle. See Details. |
npoly |
Number of edges of the polygonal approximation,
if |
delta |
Tolerance of polygonal approximation: the length of arc
that will be replaced by one edge of the polygon.
Incompatible with |
type |
Optional. Character string (partially matched) indicating whether
the polygonal approximation should be an inscribed polygon
( |
... |
Arguments passed to |
metric |
Optional. A distance metric (object of class |
This command creates a window object representing a disc, with the given radius and centre.
By default, the circle is
approximated by a polygon with npoly edges.
If mask=TRUE, then the disc is approximated by a binary pixel
mask. The resolution of the mask is controlled by
the arguments ... which are passed to as.mask.
The argument radius must be a single positive number.
The argument centre specifies the disc centre: it can be either
a numeric vector of length 2 giving the coordinates,
or a list(x,y) giving the coordinates of exactly one point, or a
point pattern (object of class "ppp") containing exactly one
point.
If type="inscribed" (the default), the polygon is inscribed in
the perfect circle of radius radius, that is, all vertices of the
polygon are points on the circle, and the circle contains the
polygon. If type="circumscribed", the
polygon is circumscribed around the circle, that is, the polygon
contains the circle, and all edges of the polygon are tangent to the
circle. If type="approx", the polygon is constructed to lie
between the inscribed and circumscribed polygons, giving a better
approximation to the circle.
If the argument metric is given, it should be a distance metric
(object of class "metric"). The disc with respect to this
metric will be computed.
An object of class "owin" (see owin.object)
specifying a window.
This function can also be used to generate regular polygons,
by setting npoly to a small integer value. For example
npoly=5 generates a pentagon and npoly=13 a triskaidecagon.
.
ellipse,
discs,
owin.object,
owin,
as.mask
# unit disc
W <- disc()
# disc of radius 3 centred at x=10, y=5
W <- disc(3, c(10,5))
#
plot(disc())
plot(disc(mask=TRUE))
# nice smooth circle
plot(disc(npoly=256))
# how to control the resolution of the mask
plot(disc(mask=TRUE, dimyx=256))
# check accuracy of approximation
area(disc())/pi
area(disc(mask=TRUE))/pi
# inscribed and circumscribed
plot(disc(npoly=256), main="Inscribed and circumscribed", border="green")
plot(disc(npoly=7, type="i"), add=TRUE, border="red")
plot(disc(npoly=7, type="c"), add=TRUE, border="blue")
plot(disc(npoly=7, type="a"), add=TRUE, border="grey")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.