ellipsePoints            package:sfsmisc            R Documentation

_C_o_m_p_u_t_e _R_a_d_i_a_l_l_y _E_q_u_i_s_p_a_c_e_d _P_o_i_n_t_s _o_n _E_l_l_i_p_s_e

_D_e_s_c_r_i_p_t_i_o_n:

     Compute points on (the boundary of) an ellipse which is given by
     elementary geometric parameters.

_U_s_a_g_e:

     ellipsePoints(a, b, alpha = 0, loc = c(0, 0), n = 201)

_A_r_g_u_m_e_n_t_s:

     a,b: length of half axes in (x,y) direction.

   alpha: angle (in degrees) giving the orientation of the ellipse,
          i.e., the original (x,y)-axis ellipse is rotated by 'angle'.

     loc: center (LOCation) of the ellipse.

       n: number of points to generate.

_V_a_l_u_e:

     A numeric matrix of dimension 'n x 2', each row containing the
     (x,y) coordinates of a point.

_A_u_t_h_o_r(_s):

     Martin Maechler, March 2002.

_S_e_e _A_l_s_o:

     the 'ellipse' package and 'ellipsoidhull' and 'ellipsoidPoints' in
     the 'cluster' package.

_E_x_a_m_p_l_e_s:

     ## Simple Ellipse, centered at (0,0), x-/y- axis parallel:
     ep <- ellipsePoints(2,5)
     str(ep)
     plot(ep, type="n",asp=1) ; polygon(ep, col = 2)

     ## rotate by 30 degrees :
     plot(ellipsePoints(2,5, alpha = 30), asp=1)
     abline(h=0,v=0,col="gray")
     abline(a=0,b= tan( 30 *pi/180), col=2, lty = 2)
     abline(a=0,b= tan(120 *pi/180), col=3, lty = 2)

     if(dev.interactive()) {
       ## Movie : rotating ellipse  :
       nTurns <- 4 # #{full 360 deg turns}
       for(al in 1:(nTurns*360)) {
           ep <- ellipsePoints(3,6, alpha=al, loc = c(5,2))
           plot(ep,type="l",xlim=c(-1,11),ylim=c(-4,8),
                asp=1, axes = FALSE, xlab="", ylab="")
       }

       ## Movie : rotating _filled_ ellipse {less nice to look at}
       for(al in 1:180) {
           ep <- ellipsePoints(3,6, alpha=al, loc = c(5,2))
           plot(ep,type="n",xlim=c(-1,11),ylim=c(-4,8),
                asp=1, axes = FALSE, xlab="", ylab="")
           polygon(ep,col=2,border=3,lwd=2.5)
       }
     }# only if interactive

