[R-sig-Geo] create a asymmetric ellipse

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Mar 23 23:03:18 CET 2010


Here's a solution for four elliptical quadrants:

elly <- function(N,S,W,E,x=0,y=0,n=100){

  xo=yo=double(n*4)
  step=pi/(2*n)

  xf=c(E,W,W,E)
  yf=c(N,N,S,S)
  j=1
  for(q in 1:4){
    for(i in 1:n){
      theta=(q-1)*(pi/2)+(i-1)*step
      xo[j]=xf[q]*cos(theta)
      yo[j]=yf[q]*sin(theta)
      j=j+1
    }
  }

  return(cbind(xo+x,yo+y))
}

then try:

plot(elly(10,5,3,5),type='l')

Barry



More information about the R-sig-Geo mailing list