Giter VIP home page Giter VIP logo

voronoidiagramue4's Introduction

VoronoiDiagram

This repository contains code that can generate a Voronoi Diagram by using an implementation of Fortune's Algorithm for the Unreal Engine.

The parameter of GenerateSites() will run Lloyd's Algorithm the specified amount of times.

To use, clone the code into a directory named 'VoronoiDiagram' in your Unreal project's plugin directory. Don't forget to add a public dependency to your project for the plugin, or else your Unreal project will not be able to find it.

The following code:

#include "VoronoiDiagram.h"

UTexture2D* MyTexture;

TSharedPtr<FVoronoiDiagram> VoronoiDiagram(new FVoronoiDiagram(FIntRect(0, 0, 4096, 4096)));
TArray<FIntPoint> Points;

for(int32 i = 0; i < 1000; ++i)
{
    Points.AddUnique(FIntPoint(FMath::RandRange(0, 4095), FMath::RandRange(0, 4095)));
}
VoronoiDiagram.AddPoints(Points);

VoronoiDiagram->GenerateSites(2);

for(int32 i = 0; i < VoronoiDiagram->GeneratedSites.Num(); ++i)
{
	VoronoiDiagram->GeneratedSites[i].Color = FColor::MakeRandomColor();
}

FVoronoiDiagramHelper::GenerateTexture(VoronoiDiagram, MyTexture);

Will create a texture similar to:

Voronoi Diagram

Citations:

Fortune's Algorithm as outlined in: Steve J. Fortune (1987). "A Sweepline Algorithm for Voronoi Diagrams". Algorithmica 2, 153-174.

Lloyd's algorithm as outlined in: Lloyd, Stuart P. (1982), "Least squares quantization in PCM", IEEE Transactions on Information Theory 28 (2): 129โ€“137

Monotone Chain Convex Hull Algorithm outlined in: A. M. Andrew, "Another Efficient Algorithm for Convex Hulls in Two Dimensions", Info. Proc. Letters 9, 216-219 (1979)

Based off of:

as3delaunay

voronoidiagramue4's People

Contributors

afuzzyllama 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.