An open API service indexing awesome lists of open source software.

https://github.com/hellfire01/fortuneline_voronoi

A fortune line voronoi for Unity3D also compatible C#. Allows you to get a complete graph with edges / cellcores / vertices and their relations
https://github.com/hellfire01/fortuneline_voronoi

csharp fortune-line unity3d voronoi voronoi-generator

Last synced: 3 months ago
JSON representation

A fortune line voronoi for Unity3D also compatible C#. Allows you to get a complete graph with edges / cellcores / vertices and their relations

Awesome Lists containing this project

README

          

# FortuneLine_voronoi
This is an implementation of a C# fortune line of witch you can find the source code here

This code is intended to work with Unity3d projects but will also work on C# projects

## Voronoi data structure
When using this program, a `VoronoiData` class is returned such as follows :

public class VoronoiData {
public List cores;
public List nodes;
public List edges;
}

The `CellCore` class contains all of the data on the cell, it also references it's edges, vertices and neighbour cells

The `Node` class represents the vertices of the diagram, each one references it's cellcore parents, neighbour vertices and related edges

The `Edge` class references both related cells and vertices

## API

The file getVoronoï.cs contains all of the API methods needed to get your voronoï diagram, the prototypes are as follow :

public static VoronoiData getVoronoi(double[] xVal, double[] yVal, int mapSize);
public static VoronoiData getVoronoi(float[] xVal, float[] yVal, int mapSize);
public static VoronoiData getVoronoi(List cells, int mapSize);
public static VoronoiData getVoronoi(List cellPos, int mapSize);

The programm needs the coordinates of the cellcores in order to be able to work, they can be given as doubles, floats, Vector2 or directly as CellCore.

The coordinates of the cellcores should always range from 0 to `mapSize` for a correct generation

## Note on the architechture of this code

This code is an encapsulation of an already working fortune line made by Burhan Joukhadar

This project encapsulates his code witch only returns a graph made of edges and adds the classes for the vertices and the cellcores in order to have the relations of these different elements.

## Possible uses of this programm

This project was first intended to be used for procedural generation ( hence all of the different relations between the classes ) but could be used wherever a Voronoï diagram is needed.

I will however add that should you only need the edge graph, you are better of using the original code as you will not have all of the extra features slowing down your programm.