Skip to content

zainkhan-afk/Delaunay-Triangulation-Pygame

Repository files navigation

Delaunay-Triangulation-Pygame

The code is based on this article.

Overview

Delaunay Triangulation implemented in python and solved using Bowyer-Watson algorithm. The program takes a set of points and connects them using a mesh.

Delauny Triangulation Gif

Usage

Running the main.py will create a delaunay triangulated mesh out of random points. Clicking on the screen will create a new point the mesh is recalculated to add the new point into the mesh. The mesh and its heatmap are rendered using Pygame.

The Delaunay triangulation code can be used without using any renderer.

from delaunayTriangulation import DelaunayTriangulation
from random import randint

N = 50

for i in range(N):
	point = Point(randint(0, 100), randint(0, 100), randint(0, 50))
	DT.AddPoint(point)

DT.Triangulate()
# The DT.mesh contains the triangles that make up the delaunay triangulated mesh

About

An implementation of Delaunay Triangulation in Pygame using the Bowyer-Watson algorithm

Topics

Resources

Stars

Watchers

Forks

Languages