Skip to content

Instantly share code, notes, and snippets.

@quommit
Created January 23, 2013 13:45
Show Gist options
  • Save quommit/4605752 to your computer and use it in GitHub Desktop.
Save quommit/4605752 to your computer and use it in GitHub Desktop.
Pseudo-code for a medial axis transform algorithm based on Voronoi diagram.
//Get point cloud S from polygon P
//by running a densify operation
var S = P.Densify ();
//Create Voronoi diagram V for
//point cloud S
var V = Voronoi (S);
//Get intersection C of Voronoi diagram V
//with polygon P
var C = V.Intersection (P);
//Retrieve medial axis by selecting edges
//in C which do not touch the perimeter
//of polygon P
var skeleton = from edge in C
where (not (edge.Touches (P.Boundary))
and edge.ContainedBy (F))
select edge;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment