rectUnique               package:xcms               R Documentation

_D_e_t_e_r_m_i_n_e _a _s_u_b_s_e_t _o_f _r_e_c_t_a_n_g_l_e_s _w_i_t_h _u_n_i_q_u_e, _n_o_n-_o_v_e_r_l_a_p_p_i_n_g _a_r_e_a_s

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

     Given a matrix of rectangular areas, this function determines a
     subset of those rectangles that do not overalp. Rectangles are
     preserved on a first come, first served basis, with user control
     over the order in which the rectangles are processed.

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

     rectUnique(m, order = seq(length = nrow(m)), xdiff = 0, ydiff = 0)

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

       m: four column matrix defining rectangular areas

   order: order in which matrix columns should be scanned

   xdiff: maximum space between overalpping rectangles in x dimension

   ydiff: maximum space between overalpping rectangles in y dimension

_D_e_t_a_i_l_s:

     The 'm' matrix must contain four colums defining the position of
     rectangle sides in the folloing order: left, right, bottom, top.
     This function is currently implemented in 'C' using a an algorithm
     with quadratic running time.

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

     A logical vector indicating which rows should be kept.

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

     Colin A. Smith, csmith@scripps.edu

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

     m <- rbind(c(0,4,0,3), c(1,3,2,6), c(3,6,4,6))
     plot(0, 0, type = "n", xlim=range(m[,1:2]), ylim=range(m[,3:4]))
     rect(m[,1], m[,3], m[,2], m[,4])
     rectUnique(m)
     # Changing order of processing
     rectUnique(m, c(2,1,3))
     # Requiring border spacing
     rectUnique(m, ydiff = 1)
     # Allowing adjacent boxes
     rectUnique(m, c(2,1,3), xdiff = -0.00001)
     # Allowing interpenetration
     rectUnique(m, xdiff = -1.00001, ydiff = -1.00001)

