Skip to content

trystan/voronoi-diagram

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
 
 
 
 
 
 

voronoi-diagram

Get a voronoi diagram for a given collection of points.

Leiningen

[trystan/voronoi-diagram "1.0.0"]

Usage

There's only one usefull function, diagram. It takes a collection of points and returns a map with :points, :edges, and :cells. Each point is a vector of two coordinates, each edges is a vector of two points, and each cell is a vector of at least three points.

(ns example.core
  (:require [voronoi-diagram.core :as voronoi]))

(let [points [[2 2] [1 4] [4 1] [-10 -10] [-10 10] [10 10] [10 -10]]
      {:keys [points edges cells]} (vornoi/diagram points)]
  (println "point" (first points))
  (println "edge" (first edges))
  (println "cell" (first cells)))

#=> point [2.0 2.0]
#=> edge [[-2.3333333333333335 -1.3333333333333333] [2.3333333333333335 2.3333333333333335]]
#=> cell [[-2.3333333333333335 -1.3333333333333333] [2.3333333333333335 2.3333333333333335] [-1.3333333333333333 -2.3333333333333335]]

License

Copyright © 2015 Trystan

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Get a Voronoi diagram given some points

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published