Giter Club home page Giter Club logo

poisson-disk-sampler-demo's Introduction

C++ demo code for the Poisson disk sampler in geometry-central.

gui screencap

The algorithm takes in a mesh and Poisson disk-samples the surface so that sampled points are distributed evenly in 3D space. Technically, Poisson disk sampling on surfaces should ensure that points are at least a certain geodesic distance away from each other. But for the purposes of visualization, it can be better to use extrinsic distance of the embedded surface instead, since this will ensure that the sampling looks even -- two points could have a large geodesic distance between them but be very near each other in 3D space, which might lead to a visually crowded image. Using 3D distance also speeds up the sampling process.

Currently the algorithm only works on manifold meshes.

The algorithm has a few parameters that roughly correspond to the algorithm of Bridson's 2007 Fast Poisson Disk Sampling in Arbitrary Dimensions:

  • rCoef corresponds to the minimum distance between samples, expressed as a multiple of the mean edge length. The actual minimum distance is computed as r = rCoef * meanEdgeLength.
  • kCandidates = the number of candidate points chosen from the (r,2r)-annulus around each sample.

Additionally, you can specify points around samples should be avoided. By default, samples will avoid these points with the same radius r used in the rest of the algorithm. You can optionally specify a "radius of avoidance" for these points, where the radius of avoidance is given in multiples of r. The radius of avoidance can be further be specified to be a radius in 3D space, or a radius in terms of distance along the surface. The former will produce a radius of avoidance that will appear perfectly round and is likely more visually pleasing, but for very large radii may occlude samples from opposite sides of the mesh. The latter will restrict the radius of avoidance to only be along the surface, but such a metric ball will not appear perfectly round, especially in areas with very large and sudden changes in curvature.

Cloning and building

git clone --recursive https://github.com/nzfeng/poisson-disk-sampler-demo.git
cd poisson-disk-sampler-demo
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
./bin/poisson_disk /path/to/your/mesh.obj

poisson-disk-sampler-demo's People

Contributors

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