• Stars
    star
    3
  • Rank 3,847,270 (Top 78 %)
  • Language
    Julia
  • License
    Other
  • Created almost 9 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Work with Voroni cells of a point process

VoronoiCells

provides access to Voronoi cells in VoronoiDelaunay.jl

Linux, OSX: Build Status Β  Windows: Build Status Β  Β  Β  Coverage Status codecov.io

Other package with same name

There is a package by the same name VoronoiCells.jl that was created about nine months later than this package. The other package is registered, this one is not.

Installation

VoronoiCells depends on VoronoiDelaunay.jl which depends on GeometricalPredicates.jl, and often, only the development version of GeometricalPredicates.jl will successfully load. You can switch to the development version like this:

Pkg.add("GeometricalPredicates")
Pkg.checkout("GeometricalPredicates")
Pkg.clone("https://github.com/jlapeyre/VoronoiCells.jl")

Some functions

cells = poissonvoronoicells(npts)

Sample a Poisson point process in the plane with mean npts 'generator' points per unit square and return the Voronoi cells. Only complete cells within the unit square [1,2] x [1,2] are returned. The cells very near the boundary do not have the same geometrical statistics as those in the bulk. length(cells) returns the number of cells retained. If Distributions.jl is installed, then the number of generators in the square is sampled from the Poisson distribution, otherwise, the number is taken to be exactly npts. Use approxpoissonvoronoicells(npts) to force the latter behavior.

Lookup of the cell containing a point is done via a square grid. By default, about 100 generator points are put in each square. cells = poissonvoronoicells(npts,ndiv), will put about ndiv^2 generator points in each square, at the cost of a higher storage requirement with increasing ndiv.

cells = poissonvoronoicellsnogrid(npts)

Return an array of VoronoiCell's without the grid structure for locating them.

smaxcoord(cells), smincoord(cells)

Scaled maximum and minimum of both x and y coordinates. The scaling is such that the average cell size is (approximately) 1 and the origin is at the center of the square area.

search efficiently for and returns the index of the cell containing the scaled point (x,y). The cell may then be retrieved via cells[idx]. findindex finds cells at unscaled (within the shifted unit square) coordinates. If no cell contains the point (x,y), an invalid index is returned. This condition is checked with isvalid().

isvalid(idx)

Return true if a cell was found containing (x,y), otherwise false.

getinvalidcellindex()

Return an invalid cell index.

c = cells[idx], sarea(cells,idx), nedges(c), nverts(c)

Scaled area of cell at index idx. Number of edges and number of vertices in the cell.

cells = poissonvoronoicells(npts)
write("fname.dat", cells)

Write cells to a file. The file is in a fast binary format. It does not use any generic serialization.

cells = read_one_cellfile("fname.dat")

Read cells from file written by write.

cells = poissonvoronoicells(npts)
isexternal(cell[i])

Return true if the vertices of the cell lie entirely within the unit square [1,2] x [1,2].

cells = poissonvoronoicells(npts)
random_cell(cell)

Return the cell at a randomly chosen point on the plane. (Resampling until a point containing a cell is found.

t = poissontesselation(npts)
t = approxpoissontesselation(npts)

Return Delaunay tesselation of the Poisson point process in the plane.

gcells = voronoicells(t)
cells = voronoicellsnogrid(t)

Return the cells corresponding to the DelaunayTessellation2D t.

Example

Here is sample code that inefficiently measures the second moment of the cell area distribution by doing a random walk and recording the area of the containing cell at each step.

flip() = 2*rand(Bool) - 1

function walkmean()
    npts = 100000  # number of points in Poisson point process
    cells = poissonvoronoicells(npts)  # cells with unit mean size
    nsteps = 10^6  # number of walk steps
    dx = 0.1       # step length
    x = 0.0        # walker's position
    y = 0.0
    sumarea = 0.0  # sum of areas of cells at each step
    nareas = 0     # number of area samples collected
    for stp in 1:nsteps
        x += flip() * dx
        y += flip() * dx
        idx = sfindindex(cells,x,y)  # find index of cell containing point (x,y)
        if ! isvalid(idx)
            println("Exited tesselated area at step number $stp.")
            break
        end
        sumarea += sarea(cells,idx)  # add (scaled) area of cell
        nareas += 1
    end
    @printf("mean sampled area %.4f,  nareas %d\n", sumarea/nareas,  nareas)
end

There is more to the interface including unscaled versions of functions. The unscaled area is a square with both x and y coordinates restricted to approximately 1 <= x,y <= 2. See VoronoiDelaunay.jl for details. More of the interface may be documented later.

sizeof(poissonvoronoicells(npts))

Size in bytes for storage of cells. This includes cell generators, edges, and the grid structure.

cells = poissonvoronoicells(npts)
sizeof(cells[1])

sizeof a single cell.

Unexported functions

These functions have doc strings.

More Repositories

1

Symata.jl

language for symbolic mathematics
Julia
172
star
2

JuliaQuantumInformation

List of quantum information and computation projects in Julia
52
star
3

ManualDispatch.jl

Avoid method dispatch at runtime
Julia
39
star
4

EmpiricalCDFs.jl

Online empirical cumulative distribution functions
Julia
33
star
5

SymataSyntax.jl

Mathematica syntax for Symata.jl
Julia
13
star
6

julia_project

Manage a Julia project living within a Python package
Python
13
star
7

ZChop.jl

replace small numbers with zero
Julia
13
star
8

qinf

Quantum information library for Maxima
Common Lisp
11
star
9

PrimeSieve.jl

fast generation and counting of primes
Julia
10
star
10

IsApprox.jl

Interface for approximate and exact equality
Julia
10
star
11

StreamToString.jl

redirect stdout and stderr to a string in Julia
Julia
6
star
12

pika-asynchronous-consumer

asynchronous RabbitMQ consumer
Python
6
star
13

FileCmp.jl

Compare two files byte by byte
Julia
6
star
14

PDL-IO-Matlab

Reading and writing matlab format data files for the perl data language.
C
5
star
15

IdentityMatrix.jl

efficient methods for identity matrices
Julia
4
star
16

ranwalk-Julia-vs-Cxx

Compare speed of Julia and C++-11 for random walk simulations
C++
4
star
17

CachePath.jl

Allow caching precompiled Julia code in a specified directory
Julia
3
star
18

Qurt.jl

Qiskit compatible circuit manipulation in Julia
Julia
3
star
19

PDL-DSP-Windows

Signal processing window functions for PDL
Perl
3
star
20

PDL-Fit-Levmar

PDL interface to constrained Levenberg-Marquardt library levmar
C
3
star
21

openqasm-rust

QASM 3.0 parser for the Rust langauge
Rust
3
star
22

DeepConvert.jl

Convenient literal expressions for large numbers
Jupyter Notebook
3
star
23

MaximumLikelihoodPower.jl

Maximum Likelihood Estimate for power laws
Julia
3
star
24

BlockEnums.jl

Like Enums but with more features
Julia
3
star
25

DictTools.jl

Improvements on standard dict tools in julia
Julia
2
star
26

mixima

Compatibility tools for porting from Mathematica to Maxima
Common Lisp
2
star
27

SocialNet.jl

Simplified Social Network
Julia
2
star
28

MethodInSrc.jl

Test whether a call is dispatched to a method in your module
Julia
2
star
29

PermPlain.jl

Permutations of integers
Julia
2
star
30

gjlcxx_util

c++ templates for physics simulations and sundry
C++
2
star
31

diffeq_julia

alternative packaging of diffeqpy
Python
2
star
32

mext

Package management and packages for Maxima (the CAS)
Common Lisp
2
star
33

QuantumGlue.jl

Convert types between quantum packages
Julia
1
star
34

TupleArrays.jl

a lot like StructArrays
Julia
1
star
35

SampleShots.jl

experiments with shot sampling
Julia
1
star
36

PDL-StatPhys-Cluster

cluster counting routine for statistical physics (biology,...) 2-d site model
Perl
1
star
37

RowTables.jl

Data table with row-wise storage
Julia
1
star
38

hexdens

create density plots on a triangular or square lattice
Perl
1
star
39

vigenere-crack

program to encode decode decrypt vigenere cipher
Perl
1
star
40

clevo-xsm-wmi

Kernel module for keyboard backlighting of Clevo SM series notebooks. (And several EM/ZM/DM series models)
C
1
star
41

BitsX.jl

bit manipulation and static bit vectors
Julia
1
star
42

Rotate.jl

Cyclic assignment
Julia
1
star
43

ControlFlow.jl

Some constructs for control flow
Julia
1
star
44

msieve-shared

shared library version of msieve
C
1
star
45

PDL-DSP-Iir

Infinite impulse response and recursive filters
Perl
1
star
46

prime-pi-maxima

prime counting function for maxima, the CAS
Common Lisp
1
star
47

CBOOCall.jl

The way of CBOO for Julia
Julia
1
star
48

GraphsExt.jl

Some types and functions that could be in Graphs.jl
Julia
1
star