Class RepulsionCirclePack

java.lang.Object
micycle.pgs.commons.RepulsionCirclePack

public class RepulsionCirclePack extends Object
Repulsion Packing attempts to arrange a set of circles of specified radii within a rectangle such that there is no-overlap between circles.

It involves iterative pair-repulsion, in which overlapping circles move away from each other. The distance moved by each circle is proportional to the radius of the other to approximate inertia (very loosely), so that when a small circle is overlapped by a large circle, the small circle moves furthest. This process is repeated iteratively until no more movement takes place (acceptable layout) or a maximum number of iterations is reached (layout failure). To avoid edge effects, the bounding rectangle is treated as a toroid. Each circle's centre is constrained to lie within the rectangle but its edges are allowed to extend outside.

This Java code is based on an implementation of the algorithm from the packcircles R package, but adds grid-based indexing to speed up the packing convergence.

Author:
Michael Carleton
  • Constructor Details

    • RepulsionCirclePack

      public RepulsionCirclePack(List<processing.core.PVector> xyr, double xmin, double xmax, double ymin, double ymax, boolean wrap)
      Parameters:
      circles - overlapping circles, circle positions and sizes (x, y, radius)
      xmin -
      xmax -
      ymin -
      ymax -
      wrap -
  • Method Details

    • getPacking

      public List<processing.core.PVector> getPacking()