Code Monkey home page Code Monkey logo

voronoi-java's Introduction

voronoi-java License Build Status

A lightweight java library for generating 2D Voronoi diagrams using Fortune's Algorithm

Usage

voronoi-java is available in the central maven repository:

    <dependency>
        <groupId>de.alsclo</groupId>
        <artifactId>voronoi-java</artifactId>
        <version>1.0</version>
    </dependency>

To get the latest version you can just clone the repository and install it into your local maven repository (see Building from Source).

Getting started

Use a code snippet like this:

    Collection<Point> points = ...
    Voronoi voronoi = new Voronoi(points);
    voronoi.getGraph();

Source Code

The latest source can be found here on GitHub. To clone the project:

git clone git://github.com/aschlosser/voronoi-java.git

Or download the latest archive.

Building from Source

This project can be built with the latest Java Development Kit and Maven. The command mvn package will build the project and will put the compiled JAR in target, and mvn install will copy it to your local Maven repository.

Contributing

Your help is welcome! Just open a pull request with your changes.

License

voronoi-java is licensed under the MIT License. Basically, you can do as you please as long as you include the original copyright notice. Please see the License.md file for details.

Credits

Most of the code is derived from the desciptions included in the book 'Computational Geometry: Algorithms and Applications' by Mark de Berg, Otfried Cheong, Marc van Kreveld and Mark Overmars (ISBN-13: 978-3540779735)

voronoi-java's People

Contributors

aschlosser avatar aschlosser-tf avatar nmasondo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voronoi-java's Issues

speed and bug

Thanks for implementing fortune's algo, I tried your code

When multiplying the number of point by 60 from 1024 to 60,000 is should go only about 80 times slower, since it is claimed a complexity of n log(n), but I waited 5mm and it did not complete.
Also I experiment a bug with the following set of points , it tries to go a get() on an optional which is empty

new Point(64.0,554.2562584220407),new Point(576.0,332.55375505322445),new Point(640.0,221.70250336881628),new Point(128.0,443.40500673763256),new Point(896.0,443.40500673763256),new Point(0.0,221.70250336881628),new Point(512.0,221.70250336881628),new Point(192.0,332.55375505322445),new Point(960.0,332.55375505322445),new Point(896.0,221.70250336881628),new Point(704.0,554.2562584220407),new Point(320.0,332.55375505322445),new Point(896.0,0.0),new Point(256.0,221.70250336881628),new Point(384.0,0.0),new Point(832.0,554.2562584220407),new Point(512.0,0.0),new Point(640.0,0.0),new Point(768.0,443.40500673763256),new Point(768.0,221.70250336881628),new Point(192.0,554.2562584220407),new Point(832.0,332.55375505322445),

Fails for 3x3 grid of points

Example set of 9 points in a grid, 2 distance between each:
[(0.00,0.00), (0.00,2.00), (0.00,4.00), (2.00,0.00), (2.00,2.00), (2.00,4.00), (4.00,0.00), (4.00,2.00), (4.00,4.00)]

    @Test
    public void testColinear() {
    	List<Point> points = new ArrayList<Point>();
    	for (int x = 0; x <= 4; x +=2) {
    		for (int y = 0; y <= 4; y+= 2) {
    			points.add(new Point(x, y));
    		}
    	}

        Voronoi diagram = new Voronoi(points);
    }

When running this, I get:

java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at de.alsclo.voronoi.event.VertexEvent.handle(VertexEvent.java:61)
	at de.alsclo.voronoi.Voronoi.<init>(Voronoi.java:50)
	at de.alsclo.voronoi.VoronoiTest.testColinear(VoronoiTest.java:30)

Let me know if I've made a mistake or misunderstood something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.