Coder Social home page Coder Social logo

hpaulkeeler / voronoi_uniform Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 30 KB

Uniformly places a single random point in each bounded cell of a Voronoi/Dirichlet tesselation.

License: MIT License

MATLAB 46.33% Python 53.67%
voronoi-tessellation voronoi-diagram voronoi uniform poisson-process poisson-point-process dirichlet-tessellation

voronoi_uniform's Introduction

voronoi_uniform

Uniformly places a single random point in each bounded cell of a two-dimensional Voronoi/Dirichlet tesselation of some given point pattern, such as a single realization of a (random) point process.

If you use this code in a research publication, please cite this repository:

@misc{keeler2019voronoi, author = {Keeler, H.P.}, title = {Uniform placement of random points in bounded Voronoi cells}, year = {2019}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{github.com/hpaulkeeler/voronoi_uniform}}, commit = {dc3ab3c5d27d96c18969fc9b201b376c2251c423} }

The MATLAB and Python code do essentially the same thing, which can be verified with a given (ie non-random) point pattern. The key functions are respectively located in funVoronoiUniform.m and funVoronoiUniform.py. More details are found in the comments in the files. To create a Voronoi/Dirichlet tesselation, either the MATLAB function voronoin[1] or the SciPy function Voronoi[2] needs to be run, depending on which language is being used. (Note: The MATLAB code uses a Voronoi tesselation created by the MATLAB function voronoin[1], and not the MATLAB function voronoi, which creates different data structures.)

The random (uniform) placement step is done by first dividing each (bounded) Voronoi cell (ie an irregular polygon) with, say, m sides into m scalene triangles. The i th triangle is then randomly chosen based on the ratio of areas. A point is then uniformly placed on the i-th triangle (via eq. 1 in [3]). The random (uniform) placement step is repeated for all bounded Voronoi cells.

To test the functions, run VoronoiUniformTest.m or VoronoiUniformTest.py (with the aforementioned files in the same directory/folder). For a given point pattern (for example, a realization of a Poisson point process), these files run the function funVoronoiUniform repeatedly over number of simulations. For each simulation, a single random point is uniformly placed in each bounded cell. Then the averages of the Cartesian components of the uniformly placed points are then taken. As the number of simulations (of placing single points) increases, these averages should converge to the centroids (or geometric centres) of all the bounded Voronoi cells.

Author: H.Paul Keeler, 2019

References:

[1] http://www.mathworks.com.au/help/matlab/ref/voronoin.html

[2] http://scipy.github.io/devdocs/generated/scipy.spatial.Voronoi.html

[3] Osada, R., Funkhouser, T., Chazelle, B. and Dobkin. D., "Shape distributions", ACM Transactions on Graphics, vol 21, issue 4, 2002

voronoi_uniform's People

Contributors

hpaulkeeler avatar

Stargazers

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