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)

