Der Code erzeugt eine konvexe Polylinie um eine zufällig positionierte Punktmenge; innerhalb dieses Polygons liegen alle anderen Punkte. 201 Punkte (For v = 0 To anzahl, anzahl = 200) liegen zufällig im Feld 1000 × 800 und werden nach x sortiert. Vom Punkt ganz links aus prüft das Skript jeden Punkt und wählt den mit dem größten Winkelwert – das Verfahren ähnelt dem „Geschenkpapier“-Algorithmus (Jarvis-Marsch):
Hinweg: ergebnis = 90° + Steigungswinkel (nur Punkte rechts von startP)Rückweg: ergebnis = 90° + Gefällewinkel (nur Punkte links, ab dem Punkt mit dem größten x)
Auf dem Hinweg wickelt die Kette so die Oberseite der Punktwolke von links nach rechts ab, auf dem Rückweg die Unterseite zurück, bis sie wieder am ersten Punkt ankommt. Jede Kante bekommt die AutoCAD-Farbe ihrer Nummer: weiß, rot, gelb, grün, cyan, blau, magenta … Den Winkel berechnet das Skript mit einem selbst geschriebenen Arkuskosinus über Atn, weil VBA keinen eingebauten hat.
Hier läuft die Suche Punkt für Punkt: Der Strahl zeigt den gerade geprüften Punkt, die gestrichelte Linie den bisher besten Kandidaten. Klick setzt einen Punkt, Rechtsklick entfernt einen – die Hülle beginnt dann von vorn. Die App ist eine Neuumsetzung des AutoCAD-VBA-Skripts von Reinhard König (April 2004; aus den Experimenten zur Arbeit Computergenerierte Stadtstrukturen). Zwei Programmfehler sind behoben, siehe QUELLE.md.
The code draws a convex polyline around a randomly placed set of points; all other points lie inside this polygon. 201 points (For v = 0 To anzahl, anzahl = 200) are scattered over a 1000 × 800 field and sorted by x. Starting from the leftmost point, the script checks every point and picks the one with the largest angle value – a method similar to the gift-wrapping algorithm (Jarvis march):
outward: ergebnis = 90° + angle of ascent (only points to the right of startP)return: ergebnis = 90° + angle of descent (only points to the left, from the point with the largest x)
On the way out the chain wraps the top of the point cloud from left to right, on the way back the bottom, until it reaches the first point again. Each edge takes the AutoCAD colour of its number: white, red, yellow, green, cyan, blue, magenta … The script computes the angle with a home-made arc cosine via Atn, since VBA has no built-in one.
Here the search runs point by point: the ray shows the point being checked, the dashed line the best candidate so far. Click adds a point, right-click removes one – the hull then starts afresh. The app re-implements Reinhard König's AutoCAD VBA script (April 2004; from the experiments for Computergenerierte Stadtstrukturen). Two program errors have been fixed, see QUELLE.md.