Skip to main content

Python implementation of Discrete Voronoi Chain algorithm by Mirko Velić, Dave May & Louis Moresi (2009).

Project description

About pyDVC

pyDVC is a Python-based implementation of the Discrete Voronoi Chain tessellation algorithm, originally introduced by Velic, May and Moresi (2009) [1]. This algorithm will perform a bounded tessellation of 3D point-cloud centre-of-mass data on a 3D voxel grid to a desired resolution. Although the algorithm is single-threaded, pyDVC utilises the Numba Python library for speed, and is usually reasonably quick for N~= 1000-10000 particles.

pyDVC can be found on pyPI and GitHub

Dependencies

numpy
numba
python>=3.6

Installation

If you want to install pyDVC to an existing Python virtual environment, simply run pip install pyDVC to install pyDVC and its dependencies.

If you want to set up a dedicated virtual environment for pyDVC, follow the instructions below, which assume you already have Python >= 3.6 installed on some sort of UNIX system which is accessible via python3.

  1. Create a folder to put your new virtual environment in:
    mkdir env_pyDVC
    
  2. Create a virtual environment using your system Python:
    python3 -m venv ./env_pyDVC
    
  3. Activate your new virtual environment:
    source ./env_pyDVC/bin/activate
    
  4. Install pyDVC with pip inside your new virtual environment:
    pip install pyDVC
    

Usage

import numpy as np
from pyDVC import tessellate

# Generate 1000 particles
n_particles = 1000

# Give each particle a random 3D position from -0.5 to 0.5 in x, y and z
positions = np.random.rand(n_particles, 3) - 0.5

# Give each particle a random radius to use as the weight
weights = np.random.rand(n_particles) * 0.05

# Define the bounds of the tessellation
bounds = np.array([
    [-0.5, 0.5],
    [-0.5, 0.5],
    [-0.5, 0.5]
])

# Define the number of cells (grid points) along each axis
n_cells = 100

# The bounding box side length is 1 (-0.5 to 0.5), so the size of each cell is 1/n_cells
cell_length = 1/n_cells

# Call the tessellation
ownership_array = tessellate(positions, bounds, cell_length, weights)

# Print the result
print(ownership_array)

References

[1] Velic, May and Moresi (2009). A Fast Robust Algorithm for Computing Discrete Voronoi Diagrams. J Math Model Algor. 8. 343-355. http://dx.doi.org/10.1007/s10852-008-9097-6

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydvc-0.0.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyDVC-0.0.4-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pydvc-0.0.4.tar.gz.

File metadata

  • Download URL: pydvc-0.0.4.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pydvc-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9560184223e62da352fd9e38e69e8da50ba464223f9a23043f0667dbdfbdc8d2
MD5 beba5cdff1e74d28ae54367ccb29e043
BLAKE2b-256 a1937281995c6be8a07ccfdc4dbcafec28a81a5442b4c6b70fa5b4012232c898

See more details on using hashes here.

File details

Details for the file pyDVC-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyDVC-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyDVC-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ab35bc47de3067e534119d914593ff2aedb4d7f4aa4a506d86474b137f26b9c0
MD5 4d584dda928fcbf602904b0416b3a291
BLAKE2b-256 5efa0d91dca87133cd1163b1e4957db74e79035dcaccd6ddf7fbffe3e6f1450f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page