Skip to contents

as_ellipse2d() casts to an Ellipse2D object.

Usage

as_ellipse2d(x, ...)

# S3 method for class 'Coord2D'
as_ellipse2d(x, ..., r = 0.5, rx = r, ry = r, theta = angle(0))

# S3 method for class 'numeric'
as_ellipse2d(x, y = 0, ..., r = 0.5, rx = r, ry = rx, theta = angle(0))

Arguments

x

Object to cast. Either a Coord2D object of center(s) or a numeric vector of x-coordinates of center(s).

...

Ignored; only included for S3 method consistency.

r

Numeric vector of (circular) radii (default 0.5).

rx

Numeric vector of x-axis semi-radii (default r).

ry

Numeric vector of y-axis semi-radii (default r).

theta

An angle() vector (or numeric interpreted using the default angular unit) of rotation angles (default angle(0)).

y

Numeric vector of y-coordinates of center(s) (used when x is numeric).

Value

An Ellipse2D object.

Examples

# Ellipse from Coord2D center
e <- as_ellipse2d(as_coord2d(0, 0), rx = 2, ry = 1, theta = degrees(30))
plot(e)


# Multiple ellipses
e2 <- as_ellipse2d(x = c(0, 1), y = c(0, 1), rx = c(1, 2), ry = c(0.5, 1))
plot(e2)


# Multiple circles from x, y, r vectors
c2 <- as_ellipse2d(x = c(0, 1), y = c(0, 1), rx = c(0.3, 0.4))
plot(c2)