EntwurfsforschungKI Lab ← Frühe SimulationenEarly Simulations

ÜberlagerungsflächenOverlapping areas

/

Klick: Rechteck setzen · Rechtsklick oder Umschalt: Rechteck entfernen · ein Schritt = ein geprüftes PaarClick: add a rectangle · right-click or shift: remove a rectangle · one step = one pair checked

Ein Klick auf „Erstellen“ (im Original „Rechtecke erstellen“) streut numbers rote Rechtecke über das Feld (Voreinstellung 10): Mittelpunkt zufällig, jede Seite 10 bis 59 Pixel vom Mittelpunkt entfernt. Dann wird jedes Paar geprüft – For I … For K := I + 1 … – und jede Überlagerung als blaues Rechteck eingetragen. Die Summe ihrer Flächen ist die Überlagerungsfläche:

Überlagerungsfläche = Σ (Höhe · Breite) aller Schnittrechtecke

Die Fassung 05 schneidet zwei Rechtecke mit der Windows-Funktion IntersectRect. Die Fassung 04 rechnet „die gleiche Berechnung“ selbst, mit dem Cohen-Sutherland-Verfahren aus der Computergrafik: Die Kanten von A teilen die Ebene in neun Gebiete, jede Ecke von B bekommt einen vierstelligen Clipcode (unten, oben, rechts, links; 0000 = innen). Aus den Codes zweier benachbarter Ecken folgt, ob die Kante innen liegt, ganz außen oder A schneidet – und welche Punkte das Überlagerungsrechteck bilden. Beide Fassungen kommen auf dieselbe Fläche; 04 zählt bloße Berührungen als Rechteck der Fläche 0 mit.

Hier läuft die Prüfung Paar für Paar, das gerade geprüfte Paar ist umrandet, in Fassung 04 mit den Clipcodes. Danach erzeugt der nächste Schritt neue Rechtecke. Das Programm ist die Vorstufe zu Dichte Packungen, in der eine evolutionäre Strategie diese Fläche minimiert. Was geändert wurde, steht in QUELLE.md.

Clicking “Create” (“Rechtecke erstellen” in the original) scatters numbers red rectangles over the field (default 10): random centre, each side 10 to 59 pixels from the centre. Then every pair is checked – For I … For K := I + 1 … – and each overlap is entered as a blue rectangle. The sum of their areas is the overlapping area:

overlapping area = Σ (height · width) of all intersection rectangles

Version 05 intersects two rectangles with the Windows function IntersectRect. Version 04 does “the same calculation” itself, using the Cohen–Sutherland method from computer graphics: the edges of A divide the plane into nine regions, and each corner of B gets a four-digit clip code (below, above, right, left; 0000 = inside). The codes of two adjacent corners tell whether the edge lies inside, entirely outside or crosses A – and which points form the overlap rectangle. Both versions arrive at the same area; 04 also counts mere contact as a rectangle of area 0.

Here the check runs pair by pair; the pair being checked is outlined, in version 04 with its clip codes. Afterwards the next step creates new rectangles. The program is the precursor of Dense packing, where an evolutionary strategy minimises this area. Changes are listed in QUELLE.md.