f_ellipse: Ellipse function with angle argument 'theta'

View source: R/curves.R

f_ellipseR Documentation

Ellipse function with angle argument theta

Description

Ellipse function with angle argument theta

Usage

f_ellipse(x0 = 0, y0 = 0, a = 1, b = 1, alpha = 0, theta0 = 0, dir = 1)

Arguments

x0

A numeric value. The x-axis value of the ellipse center.

y0

A numeric value. The y-axis value of the ellipse center.

a

A numeric value. The major radius.

b

A numeric value. The minor radius.

alpha

A numeric value. The rotation angle of the ellipse.

theta0

A numeric value. The (anti-clockwise) angle/rotation of the starting point on the ellipse.

dir

A numeric value, interpreted as either -1, i.e., clockwise, or as 1, i.e., anti-clockwise direction.

Examples

thetas <- seq(0, 2 * pi, length = 200)
# circle with radius 1 and center at 0/0
ellipse1 <- f_ellipse()
plot(ellipse1(thetas), asp = 1, type = "l")
points(0, 0, pch = 4)
# ellipse with radii 0.2 and 0.1, 1/4-rotation, and center at 0.3/0.3
lines(f_ellipse(0.3, 0.3, 0.2, 0.1, pi / 4)(thetas))
# ellipse with radii 0.2 and 0.1, -1/4-rotation, and center at -0.3/0.3
lines(f_ellipse(-0.3, 0.3, 0.2, 0.1, -pi / 4)(thetas))
# semi-ellipse with radii 0.25 and 0.5 and center at 0/0
lines(f_ellipse(0, 0, 0.25, 0.5, dir = -1)(seq(0, pi, length = 200)))


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.