Debian Codegraph @

man/ellipsePoints.Rd

raw
1 \name{ellipsePoints}
2 \alias{ellipsePoints}
3 \title{Compute Radially Equispaced Points on Ellipse}
4 \description{
5 Compute points on (the boundary of) an ellipse which is given by
6 elementary geometric parameters.
7 }
8 \usage{
9 ellipsePoints(a, b, alpha = 0, loc = c(0, 0), n = 201, keep.ab.order=FALSE)
10 }
11 \arguments{
12 \item{a,b}{length of half axes in (x,y) direction. Note that
13 \eqn{(a,b)} is equivalent to \eqn{(b,a)} \emph{unless}
14 \code{keep.ab.order=TRUE}.}
15 \item{alpha}{angle (in degrees) giving the orientation of the ellipse,
16 i.e., the original (x,y)-axis ellipse is rotated by \code{angle}.}
17 \item{loc}{center (LOCation) of the ellipse.}
18 \item{n}{number of points to generate.}
19 \item{keep.ab.order}{logical indicating if \eqn{(a,b)} should be
20 considered \emph{ordered}. When \code{FALSE}, as per default,
21 the orientation of the ellipse is solely determined by \code{alpha}.
22
23 Note that \code{keep.ab.order = TRUE} seems a more natural default,
24 but \code{FALSE} is there for back-compatibility.}
25 }
26 \value{
27 A numeric matrix of dimension \code{n x 2}, each row containing the
28 (x,y) coordinates of a point.
29 }
30 \author{Martin Maechler, March 2002.}
31 \seealso{the \CRANpkg{ellipse} package and \code{\link[cluster]{ellipsoidhull}}
32 and \code{\link[cluster]{ellipsoidPoints}}
33 in the \CRANpkg{cluster} package.
34 }
35 \examples{
36 ## Simple Ellipse, centered at (0,0), x-/y- axis parallel:
37 ep <- ellipsePoints(5,2)
38 str(ep)
39 plot(ep, type="n",asp=1) ; polygon(ep, col = 2)
40 ## (a,b) = (2,5) is equivalent to (5,2) :
41 lines(ellipsePoints(2,5), lwd=2, lty=3)
42 ## keep.order=TRUE : Now, (2,5) are axes in x- respective y- direction:
43 lines(ellipsePoints(2,5, keep.ab.order=TRUE), col="blue")
44
45 ## rotate by 30 degrees :
46 plot(ellipsePoints(5,2, alpha = 30), asp=1)
47 abline(h=0,v=0,col="gray")
48 abline(a=0,b= tan( 30 *pi/180), col=2, lty = 2)
49 abline(a=0,b= tan(120 *pi/180), col=3, lty = 2)
50
51 ## NB: use x11(type = "Xlib") for the following if you can
52 if(dev.interactive(TRUE)) {
53 ## Movie : rotating ellipse :
54 nTurns <- 4 # #{full 360 deg turns}
55 for(al in 1:(nTurns*360)) {
56 ep <- ellipsePoints(3,6, alpha=al, loc = c(5,2))
57 plot(ep,type="l",xlim=c(-1,11),ylim=c(-4,8),
58 asp=1, axes = FALSE, xlab="", ylab="")
59 }
60
61 ## Movie : rotating _filled_ ellipse {less nice to look at}
62 for(al in 1:180) {
63 ep <- ellipsePoints(3,6, alpha=al, loc = c(5,2))
64 plot(ep,type="n",xlim=c(-1,11),ylim=c(-4,8),
65 asp=1, axes = FALSE, xlab="", ylab="")
66 polygon(ep,col=2,border=3,lwd=2.5)
67 }
68 }# only if interactive
69 }
70 \keyword{iplot}
71 \keyword{utilities}