View source: R/circleRemoveOverlaps.R
circleRemoveOverlaps | R Documentation |
Given an initial set of circles, this function identifies a subset of non-overlapping circles using a simple heuristic algorithm. Circle positions remain fixed.
circleRemoveOverlaps(
x,
xysizecols = 1:3,
sizetype = c("area", "radius"),
tolerance = 1,
method = c("maxov", "minov", "largest", "smallest", "random", "lparea", "lpnum")
)
x |
A matrix or data frame containing circle x-y centre coordinates and sizes (area or radius). |
xysizecols |
The integer indices or names of the columns in |
sizetype |
The type of size values: either |
tolerance |
Controls the amount of overlap allowed. Set to 1 for simple exclusion of overlaps. Values lower than 1 allow more overlap. Values > 1 have the effect of expanding the influence of circles so that more space is required between them. The input value must be > 0. |
method |
Specifies whether to use linear programming (default) or one of
the variants of the heuristic algorithm. Alternatives are:
|
The method
argument specifies whether to use the heuristic algorithm or
linear programming. The following options select the heuristic algorithm and
specify how to choose an overlapping circle for rejection at each iteration:
Choose one of the circles with the greatest number of overlaps.
Choose one of the circle with the least number of overlaps.
Choose one of the largest circles.
Choose one of the smallest circles.
Choose a circle at random.
At each iteration the number of overlaps is checked for each candidate circle and any non-overlapping circles added to the selected subset. Then a single overlapping circle is chosen, based on the method being used, from among the remainder and marked as rejected. Iterations continue until all circles have been either selected or rejected. The 'maxov' option (default) generally seems to perform best at maximizing the number of circles retained. The other options are provided for comparison and experiment. Beware that some can perform surprisingly poorly, especially 'minov'.
Two further options select linear programming:
Maximise the total area of circles in the subset.
Maximise the total number of circles in the subset.
The 'lpSolve' package must be installed to use the linear programming options. These options will find an optimal subset, but for anything other than a small number of initial circles the running time can be prohibitive.
A data frame with centre coordinates and radii of selected circles.
This function is experimental and will almost certainly change before the next package release. In particular, it will probably return something other than a data frame.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.