Learn R Programming

cwhmisc (version 3.0)

ellipse: Generate ellipses

Description

Given a positive definite symmetric matrix A of dimension 2 by 2 and a constant cn, or the axes a, b and an angle phi (in radian, counter clockwise), and the midpoint coordinates m, points on the ellipse $(y-m)'*A^{(-1)}*(y-m) = cn^2$ or rotm(2,1,2,phi) %*% matrix(c(a,0,0,b), 2, 2) will be generated.

Usage

ellipse(k, m, A, cn)
  ellipse(k, m, a=, b=, phi=)
  conf.ellipse(k, m, A, df, level = 0.95)

Arguments

k
the number of generated points on the ellipse.
m
vector of length 2 containing the midpoint coordinates of the ellipse.
A
positive definite symmetric matrix of dimension 2 by 2
cn
positive constant.
a
major axis
b
minor axis
phi
angle in radian describing the counter clockwise rotation from the x-axis to the major axis.
df
degree of freedom of F-distribution.
level
probability level of F-distribution F(2,df).

Value

  • The matrix with columns consisting of the x and y coordinates of the ellipse.

synopsis

ellipse(k, m, A = NULL, cn = NULL, a = NULL, b = NULL, phi = NULL)

See Also

rotm

Examples

Run this code
A <- matrix(c(1,1,1,2), ncol = 2)		 # define matrix A
m <- c(3, 4)					 # define vector m
plot(ellipse(1000,m,A,1))  

plot(pe <- ellipse(800,m,A,1),pch=".",type="n")
lines(rbind(pe,pe[1,]))
lines({pe <- ellipse(600,m,A,0.5); rbind(pe,pe[1,])})
lines({pe <- ellipse(400,m,A,0.25); rbind(pe,pe[1,])})
lines(conf.ellipse(51,m,A,20,0.9),lty=4,col="red")
lines(conf.ellipse(51,m,A,20,0.8),lty=4,col="green")

Run the code above in your browser using DataLab