Giter VIP home page Giter VIP logo

pydvc's Introduction

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

You can find an example Jupyter Notebook with some plotting on GitHub in examples/simple_example.ipynb A simpler example is below:

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

pydvc's People

Contributors

jadball avatar

Watchers

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