ellipse: Return ellipse points

View source: R/ellipse.R

ellipseR Documentation

Return ellipse points

Description

Return ellipse points. Usefull for ploting ellipses.

Usage

ellipse(
  saxes = c(1, 1),
  loc = c(0, 0),
  theta = 0,
  n = 201,
  method = c("default", "angle", "distance")
)

Arguments

saxes

a (2 \times 1) vector of the length of the ellipse semi-axes.

loc

a (2 \times 1) vector of the Cartesian coordinates of the ellipse center.

theta

the angle of rotation of the elllipse (in radians).

n

the number of points returned by the function.

method

The method used to return the points: either "default", "angle", or "distance" (see Details).

Details

"default"

returns points according to the polar equation;

"angle"

returns points radially equidistant;

"distance"

returns points that are equidistant on the ellipse arc.

Value

A (n \times 2) matrix whose columns correspond to the Cartesian coordinates of the points lying on the ellipse.

Examples

# Ellipse parameters
saxes <- c(5,2)
loc <- c(0,0)
theta <- pi/4

# Plot
plot(ellipse(saxes, loc, theta, n=500),type="l")
points(ellipse(saxes, loc, theta, n=30),pch=20,col="red")
points(ellipse(saxes, loc, theta, n=30, method="angle"),pch=20,col="blue")
points(ellipse(saxes, loc, theta, n=30, method="distance"),pch=20,col="green")

RConics documentation built on March 18, 2022, 5:33 p.m.