Package: graham-scan-based-incremental-delaunay
graham-scan-based-incremental-delaunayA Delaunay triangulation algorithm visualization that incrementally add points during the process and uses Graham Scan to construct the initial triangulation of the iteration.DocumentationPoint.pyGrahamscandelaunay.pyVisual.pyGraham Scan-Based Incremental Delaunay Triangulation AlgorithmGiven a list of points:Sort the list of points such that:the first point is the leftmost, bottommost point, used as the pivot pointthe remaining points are sorted by their slope in ascending order relative to the first pointConstruct the base convex hull using first 3 points (pivot point and two points with the lowest slopes)Incrementally add the next sorted point:Use Graham Scan to get the convex hull, saving any edges that were madeFlip the current triangulation to DelaunayRepeat until doneHotkeysLEFT CLICKwith your mouse create point on where you clickedPress theGkey to generate a random pointPress theSkey to start the algorithm with your set of pointsPress theSPACEBARto iterate to the next stepPress theRkey to reset the algorithm, where you can pressSagain to start with the same set of pointsPress theCkey to stop the algorithm and clear all the pointsVisualizationAfter starting the algorithm, a triangle will be drawn using three of the points.PointsBlack points indicate points that are in the triangulationLight Grey points indicate points that have yet to be added to the triangulationRed points indicate the most recently added point, and the points that are involved when a circumcircle is displayedDark Red points indicate the point that is on the opposite triangle of a quadrilateral when an edge is being checked if it is Locally DelaunayYellow points indicate the circumcenter of the triangle formed by the Red pointsEdgesGrey edges indicate the edges in the triangulationGreen edges indicate the edges that are in the queue to be checked if they are Locally DelaunayBlue edges indicate the current edge that is being checked if it is Locally Delaunay
A Yellow circle is drawn when the current edge is an inside edge is being checked if it is Locally Delaunay. This is the circumcircle defined by the triangle formed by the Red points, centered on the Yellow circumcenter. If the Dark Red point is within the Yellow circle, then the current edge will be flipped.When the algorithm is complete, the background will turn green to indicate completion.Static Walkthroughhttps://user-images.githubusercontent.com/48186448/116015435-3212b200-a607-11eb-8a45-fde9a8893821.mp4Environment and package infoPlease make sure you have installed the pyglet and numpy before running the code, Those two package can be installed using pip commandpip install numpyandpip install pygletThis project has been uploaded to PyPi as a package. You can download the package by the following command:python3 -m pip install graham-scan-based-incremental-delaunayAfter install the package, you can start the project bypython3and then>>> from grahamscandelaunay import visualInteresting ExamplesSimple 10-GonPentagon in a PentagonCounterclockwise Inward Spiral starting from the leftHyperbolic Curve (Horizontal Gap) - looks like a suspension bridgeHyperbolic Curve (Vertical Gap) - looks like an hourglass