Learn R Programming

RConics (version 1.0)

ellipse: 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

"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

Run this code
# NOT RUN {
# 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")
# }

Run the code above in your browser using DataLab