circle: Encircle a set of 2D points

View source: R/circle.R

circleR Documentation

Encircle a set of 2D points

Description

Find a smooth convex shape that encircles the points given as input using either Bezier curves or semicircles around each corner.

Usage

circle(data, r = 0.5, s = 8, method = "b", closed = FALSE)

Arguments

data

Either a matrix or a data frame with two real-valued columns or a complex-valued vector.

r

The distance from the data to the encircling shape. Must be non-negative. Defaults to 0.5.

s

A smoothness parameter. Must be greater than 2. For bezier curves, this equals to the number of points around each point on the convex hull and for method = "c", scaled to yield similar results. Defaults to 8.

method

Either "b" for a quadratic Bezier curve or "c" for a semicircle around each point of the hull. Defaults to "b".

closed

If TRUE, the first point is added to the end of the list. Useful for plotting the shapes using e.g. geom_path in ggplot2. Defaults to FALSE.

Value

A matrix with points of the encircling shape as rows.

Examples


# A minimal example
data <- data.frame(x = rnorm(5), y = rnorm(5))
circ <- circle(data, closed = TRUE)
plot(circ, type = "l")




paasim/circlr documentation built on Oct. 3, 2023, 4:50 a.m.