Class IRectanglesUnion

java.lang.Object
net.algart.math.rectangles.IRectanglesUnion

public class IRectanglesUnion extends Object

Set-theoretic union of several 2-dimensional rectangles with integer coordinates of vertices and sides, parallel to coordinate axes. This class allows to solve the following main tasks:

  1. find connected components in this union;
  2. find its boundary as a polygon: a sequence of links, where each link is a horizontal or vertical segment (1st link is horizontal, 2nd is vertical, 3rd is horizontal, etc.);
  3. find the largest rectangle (with sides, parallel to the coordinate axes), which is a subset of this union.

This class is immutable and thread-safe: there are no ways to modify settings of the created instance. However, all important information is returned "lazily", i.e. while the 1st attempt to read it. So, the instance creation method newInstance(Collection) works quickly and does not lead to complex calculations and allocating additional memory.

Author:
Daniel Alievsky