Skip to content
forked from pzsz/voronoi

Steve Fortune's algorithm to compute Voronoi diagrams written in golang

License

Notifications You must be signed in to change notification settings

haddock7/voronoi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voronoi diagrams in Go

A Implementation of of Steven J. Fortune's algorithm to efficiently compute Voronoi diagrams in Go language. Based on a Raymond Hill's javascript implementation (https://raw.github.com/gorhill/Javascript-Voronoi).

Forked from github.com/pzsz/voronoi. The only change is a new SiteVertex type that includes a user data type. Sites were defined by a Vertex struct on the original repository.

Usage

import "github.com/haddock7/voronoi"

func useVoronoi() {
    // Sites of voronoi diagram
	sites := []SiteVertex{
		{Vertex: Vertex{4, 5}},
		{Vertex: Vertex{6, 5}},
		...
	}

	// Create bounding box of [0, 20] in X axis
	// and [0, 10] in Y axis
	bbox := NewBBox(0, 20, 0, 10)

	// Compute diagram and close cells (add half edges from bounding box)
	diagram := NewVoronoi().ComputeDiagram(sites, bbox, true)

	// Iterate over cells
	for _, cell := diagram.Cells {
		for _, hedge := cell.Halfedges {
		    ...
		}	
	}

	// Iterate over all edges
	for _, edge := diagram.Edge {
	    ...
	}
}

About

Steve Fortune's algorithm to compute Voronoi diagrams written in golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%