Code Monkey home page Code Monkey logo

voronoi-diagram's Introduction

Voronoi_Diagram

This repository contains a simple implementation of 2D Voronoi Diagram calculated for three random points. Points always form acute triangle.

Table of contents

Introduction

Algorithm at the beginning randomly generates points on the board. At the same time, it is verified that the points are not too close to each other.

obraz

Next, objects representing lines between points and the centers of the lines are created.

obraz

Parametres of the circle described on this triangle are determined.

obraz

The next step is to determine the connections between the centers of the line and the center of the circle.

obraz

To obtain a Voronoi diagram for an acute triangle, it is necessary to determine the points of intersection of the pink lines with the lines x = 0 and x = 500 (frame sizes). If the intersection point is to the left of the center of the circle, then the line is routed to the intersection with the line x = 0, and the left side of the line intersects with x = 500.

obraz

At the end, you can cover the intersection points, the center of the circle and the sides of the triangle. Thus, we obtain the Voronoi diagram.

obraz

Technologies

The project was made entirely in Java. The paint method was used to draw elements, thanks to which the interface of the frame was designed.

List of crucial classes:

  • java.util.Arrays (storing data)
  • java.util.Random (random points)
  • javax.swing (frame interface)
  • java.awt (geometric structures)

Sources

Links to useful pages:

voronoi-diagram's People

Contributors

pyother avatar

Watchers

 avatar

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.