InteractiveComputerGraphics / Discregrid

Licence: mit
A static C++ library for the generation of discrete functions on a box-shaped domain. This is especially suited for the generation of signed distance fields.

Projects that are alternatives of or similar to Discregrid

WordCloud.jl
word cloud generator in julia
Stars: ✭ 66 (-56.86%)
Mutual labels:  collision-detection
Dyn4j
Java Collision Detection and Physics Engine
Stars: ✭ 317 (+107.19%)
Mutual labels:  collision-detection
Reactphysics3d
Open source C++ physics engine library in 3D
Stars: ✭ 730 (+377.12%)
Mutual labels:  collision-detection
Pancake
Lightweight, Fast, Easy-to-use HTML5 2D game framework!
Stars: ✭ 79 (-48.37%)
Mutual labels:  collision-detection
P5.collide2d
A collision detection library for 2D geometry in p5.js
Stars: ✭ 296 (+93.46%)
Mutual labels:  collision-detection
Exengine
A C99 3D game engine
Stars: ✭ 391 (+155.56%)
Mutual labels:  collision-detection
unity-animated-convexhull
Realtime fast convexhull generator for Unity
Stars: ✭ 40 (-73.86%)
Mutual labels:  collision-detection
Spatial Collision Datastructures
Benchmark of various spatial data structures for collision detection.
Stars: ✭ 96 (-37.25%)
Mutual labels:  collision-detection
Bounce
Bounce is a 3D physics engine for games.
Stars: ✭ 300 (+96.08%)
Mutual labels:  collision-detection
Fcl
Flexible Collision Library
Stars: ✭ 701 (+358.17%)
Mutual labels:  collision-detection
collision2d
A simple Go library for performing 2D collision detection based on sat-js
Stars: ✭ 64 (-58.17%)
Mutual labels:  collision-detection
Cute headers
Collection of cross-platform one-file C/C++ libraries with no dependencies, primarily used for games
Stars: ✭ 3,274 (+2039.87%)
Mutual labels:  collision-detection
Awesome Collision Detection
😎 A curated list of awesome collision detection libraries and resources
Stars: ✭ 444 (+190.2%)
Mutual labels:  collision-detection
SmartTrafficIntersection
Another AI toy project, of a traffic intersection controlled by a Reinforcement Learning AI agent to optimize traffic flow in an intersection of vehicles or pedestrians
Stars: ✭ 30 (-80.39%)
Mutual labels:  collision-detection
Rappids
Rectangular Pyramid Partitioning using Integrated Depth Sensors (RAPPIDS): A Fast Planner for Multicopter Navigation
Stars: ✭ 17 (-88.89%)
Mutual labels:  collision-detection
TriangleMeshDistance
Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh
Stars: ✭ 55 (-64.05%)
Mutual labels:  collision-detection
Rl
The Robotics Library (RL) is a self-contained C++ library for rigid body kinematics and dynamics, motion planning, and control.
Stars: ✭ 391 (+155.56%)
Mutual labels:  collision-detection
Collision Rs
A collision extension to cgmath
Stars: ✭ 101 (-33.99%)
Mutual labels:  collision-detection
Leaflet.layergroup.collision
Leaflet plugin for uncluttering L.Markers using basic collision detection.
Stars: ✭ 82 (-46.41%)
Mutual labels:  collision-detection
Gjk.c
Gilbert-Johnson-Keerthi (GJK) collision detection algorithm in 200 lines of clean plain C
Stars: ✭ 660 (+331.37%)
Mutual labels:  collision-detection

Discregrid

  

Figure 1: Left: Slice of a three-dimensional discrete signed distance field of the Stanford dragon. Right: Density map for SPH boundary handling of Stanford dragon.

Discregrid is a static C++ library for the parallel discretization of (preferably smooth) functions on regular grids. The library generates a (cubic) polynomial discretization given a box-shaped domain, a grid resolution, and a function that maps a three-dimensional position in space to a real scalar value. In the current implementation isoparametric cubic polynomials of Serendipity type for the cell-wise discretization are employed. The coefficient vector for the discrete polynomial basis is computed using regular sampling of the input function at the higher-order grid's nodes. However, I plan to provide a spatially adaptive version of the cubic discretization and moreover an implementation of the hp-adaptive discretization algorithm described in [KDBB17]. The algorithm to generate the discretization is moreover fully parallelized using OpenMP and especially well-suited for the discretization of signed distance functions. The library moreover provides the functionality to serialize and deserialize the a generated discrete grid.

Besides the library the project includes three executable programs that serve the following purposes:

  • GenerateSDF: Computes a discrete (cubic) signed distance field from a triangle mesh in OBJ format.
  • DiscreteFieldToBitmap: Generates an image in bitmap format of a two-dimensional slice of a previously computed discretization.
  • GenerateDensityMap: Generates a density map according to the approach presented in [KB17] from a previously generated discrete signed distance field using the widely adopted cubic spline kernel. The program can be easily extended to work with other kernel function by simply replacing the implementation in sph_kernel.hpp.

Author: Dan Koschier, License: MIT

Libraries using Discregrid

  • PBD - A C++ library for physically-based simulation of rigid bodies, deformables, cloth and fluids using Position-Based Dynamics. Discregrid is used to compute discrete signed distance fields of rigid objects for collision handling purposes.
  • SPlisHSPlasH - A C++ library for the physically-based simulation of fluids using Smoothed Particle Hydrodynamics. Discregrid is used to compute density maps according to my paper [KB17] for boundary handling.

Build Instructions

This project is based on CMake. Simply generate project, Makefiles, etc. using CMake and compile the project with the compiler of your choice. The code was tested with the following configurations:

  • Windows 10 64-bit, CMake 3.8, Visual Studio 2017
  • Debian 9 64-bit, CMake 3.8, GCC 6.3.

Usage

In order to use the library, the main header has to be included and the static library has to be compiled and linked against the client program. In this regard a find script for CMake is provided, i.e. FindDiscregrid.cmake. The main header can be included as follows:

#include <Discregrid/All>

A base class for the data structure that generates and holds a discretization of a function f: R^3 -> R can be constructed as follows:

// Firstly, create a domain on which a discretization will be generated.
Eigen::AlignedBox3d domain;
// Then specify domain extents using e.g. domain.extend(...).
// Secondly, specify a grid resolution.
std::array<unsigned int, 3> resolution = {{10, 10, 10}}
// Finally, instantiate the grid.
Discregrid::CubicLagrangeDiscreteGrid discrete_grid(domain, resolution);

Then, an arbitrary number of functions can be discretized on the initiated grid:

Discregrid::DiscreteGrid::ContinuousFunction func1 = ...;
Discregrid::DiscreteGrid::ContinuousFunction func2 = ...;

auto df_index1 = discrete_grid.addFunction(func1);
auto df_index2 = discrete_grid.addFunction(func2);

Optionally, only coefficients at nodes fulfilling a certain predicate can be generated by specifying the predicate:

Discregrid::DiscreteGrid::ContinuousFunction func3 = ...;
auto df_index3 = discrete_grid.addFunction(func3, false, [&](Vector3d const& x)
{
	...
	// Return true if a certain criterion for the node location x is fulfilled, e.g.
	return x.y() > 0.0;
});

A value of a discrete field can be evaluated by interpolation. Additionally, the gradient at the given query point can be computed if desired.

auto val1 = sdf->interpolate(df_index1, {0.1, 0.2, 0.3});
Eigen::Vector3d grad2;
auto val2 = sdf->interpolate(df_index2, {0.3, 0.2, 0.1}, &grad2);

If a discretization of the input function is only required in certain regions of the given domain, the discretization can be reduced resulting in a sparsely populated grid to save memory:

discrete_grid.reduce_field(df_index1, [](Eigen::Vector3d const& x, double v)
{
	// E.g.
	return x.x() < 0.0 && v > 0.0;
});

Here x represents the location of sample point in the grid and v represents the sampled value of the input function. If the predicated function evaluates to true the sample point is kept but discarded otherwise.

Optionally, the data structure can be serialized and deserialized via

discrete_grid.save(filename);
discrete_grid.load(filename); // or
discrete_grid = Discregrid::CubicLagrangeDiscreteGrid(filename);

References

  • [KDBB17] D. Koschier, C. Deul, M. Brand and J. Bender, 2017. "An hp-Adaptive Discretization Algorithm for Signed Distance Field Generation", IEEE Transactions on Visualiztion and Computer Graphics 23, 10, 2208-2221.
  • [KB17] D. Koschier and J. Bender, 2017. "Density Maps for Improved SPH Boundary Handling", ACM SIGGRAPH/Eurographics Symposium on Computer Animation, 1-10.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].