VoronoiDiagramUE4
Voronoi Diagram with Fortune's Algorithm implementation
Install / Use
/learn @afuzzyllama/VoronoiDiagramUE4README
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:

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:
Related Skills
node-connect
347.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
