Regularity
Badness:
The goal: minimize the badness, defined as the sum of squares of difference between vertex valence and desired valence. The desired valence for boundary vertices is whatever they start at; for interior vertices it is 6. You can perform any of the following 3 operations repeatedly:
- Click on an edge and press 'f' to flip it.
- Click on an edge and press 'c' to collapse it. Not all edges are collapsable.
- Click on an edge and press 's' to split it.
Vertices with too many edges are green, those with too few are red.
Rules of thumb:
- An edge between two red vertices should be collapsed if there are any green vertices on the opposite corners.
- An edge between two green vertices should be flipped if there are any red vertices on the opposite corners.
- A green/red pair can be translted by flipping an edge on the green vertex next to the edge connecting the pair.
- The sum of greenness minus redness is always conserved.
- Edge flipping is its own inverse operation.
- Edge collapse is the opposite of edge splitting.
- Edge splitting is the opposite of edge collapse, but extra flips are needed to fully undo a collapse.
This is based on this Delaunay Triangulation script. Note that my code works very slowly in Internet Explorer due to event handling.
This work is dedicated to the Public Domain.