Voronoi Fortune Additional Events in Lua
Posted: Sun Apr 21, 2024 6:50 pm
I've tried to make the Fortune's algorithm in Lua, but within limited frame, so it needs flat beach line and several new events:
- Event 1: First site event.
Creating frame with x, y, w, h and finding any highest site (point with x, y).
Adding first site to the diagram.
Creating the beach line, first parabola arc and two flat beach lines: one is left from arc, another right from arc.
The beachlines-array has three beachlines:
flat-left (p1; u2),
parabola arc (u2; u3)
flat-right (u3; p4).
Beachline:
1) Create flat beachline (p1, p4).
2) Create arc beachline (u2, u3).
3) Split the flat beachline (p1, p4) with arc beachline (u2, u3):
new beachline will be: (p1, u2, u3, p4).
Events:
4) Create parabola vertex event for event 6.
5) Create corner event for left flat beachline (for event 5).
6) Create corner event for right flat beachline (for event 4, but it will be updated in event 2).
- Event 2: point event. (here is special case with same x, it creates vertical edge)
Add new site to the diagram:
1) Split the flat beachline (u3, p4) with arc beachline (u5, u6):
new beachline will be: (p1, u2, u3, u5, u6, p4).
Events:
2) Create parabola vertex event for event 6.
3) Create flat collapse event for event 3.
4) Update corner event for right flat beachline for event 4. - Event 3: Flat collapse.
1) Removing flat beachline (u3; u5) from beachlines-array.
2) Creating new vertex v7. Adding it to the cell1 (given with site = focus1) and to cell2 (given with site = focus2).
3) Creating new point u8.
4) Updating arc beachline (u2; u3) to be (u2; u8),
5) Updating arc beachline (u5; u6) to be (u8; u6),
After the event:
Now beachlines-array is: (p1; u2; u8; u6; p4): desmos - Event 4: right corner event.
1) Removing the right flat beachline (u6, u9) from beachlines-array.
2) Creating new vertex v4; now it belongs to cell 2.
3) Creating new point u9.
4) Updating arc beachline (u8; u6) to be (u8; u9).
After event:
Now beachlines-array is: (p1; u2; u8; u9): - Event 5: left corner event.
1) Removing left flat beachline from beachlines-array.
2) Creating new vertex v1; now it belongs to cell 1.
3) Creating new point u10.
4) Updating arc beachline (u2; u8) to be (u10; u8).
After event:
Now beachlines-array is: (u10; u8; u9): https://www.desmos.com/calculator/nuetvgpfwc