All Projects → rdeits → AdaptiveDistanceFields.jl

rdeits / AdaptiveDistanceFields.jl

Licence: other
Adaptively sampled distance fields in Julia

Programming Languages

Jupyter Notebook
11667 projects
julia
2034 projects

Projects that are alternatives of or similar to AdaptiveDistanceFields.jl

ludigraphix.github.io
Documentation for Ludigraphix
Stars: ✭ 21 (-4.55%)
Mutual labels:  geometry
CGoGN 2
n-dimensional Meshes with Combinatorial Maps
Stars: ✭ 19 (-13.64%)
Mutual labels:  geometry
SeeThere
iOS app for identifying a location through the camera.
Stars: ✭ 18 (-18.18%)
Mutual labels:  geometry
curve-shortening-demo
Visualize curve shortening flow in your browser.
Stars: ✭ 19 (-13.64%)
Mutual labels:  geometry
macuahuitl
The "Macuahuitl" Generative Art Toolbox
Stars: ✭ 68 (+209.09%)
Mutual labels:  geometry
GeoJSON4EntityFramework
Create GeoJSON from Entity Framework Spatial Data or WKT
Stars: ✭ 18 (-18.18%)
Mutual labels:  geometry
pcc geo cnn
Learning Convolutional Transforms for Point Cloud Geometry Compression
Stars: ✭ 44 (+100%)
Mutual labels:  geometry
geometry sketcher
Constraint-based geometry sketcher for blender
Stars: ✭ 1,119 (+4986.36%)
Mutual labels:  geometry
imgui
Dear ImGui Addons Branch = plain unmodified dear imgui plus some extra addon.
Stars: ✭ 348 (+1481.82%)
Mutual labels:  signed-distance-field
sdf3d
3D Signed Distance Field
Stars: ✭ 16 (-27.27%)
Mutual labels:  signed-distance-field
euclid.js
2D Euclidean geometry classes, utilities, and drawing tools
Stars: ✭ 69 (+213.64%)
Mutual labels:  geometry
BodyParts3D
Clone of the BodyParts3D/Anatomography 3D model files
Stars: ✭ 32 (+45.45%)
Mutual labels:  geometry
MidcurveNN
Computation of Midcurve of Thin Polygons using Neural Networks
Stars: ✭ 19 (-13.64%)
Mutual labels:  geometry
Vector-Tile-Spark-Process
🌏 Clip geographic data into MVT files based on Apache Spark
Stars: ✭ 16 (-27.27%)
Mutual labels:  geometry
geometer
A simple drawing program to replicate construction with a compass and straightedge
Stars: ✭ 19 (-13.64%)
Mutual labels:  geometry
BasisFunctionExpansions.jl
Basis Function Expansions for Julia
Stars: ✭ 19 (-13.64%)
Mutual labels:  function-approximation
delaunator-rs
Fast 2D Delaunay triangulation in Rust. A port of Delaunator.
Stars: ✭ 115 (+422.73%)
Mutual labels:  geometry
CGAL.jl
CGAL meets Julia
Stars: ✭ 21 (-4.55%)
Mutual labels:  geometry
vos whatsapp
vangav open source - whatsapp; generated using vangav backend:
Stars: ✭ 14 (-36.36%)
Mutual labels:  geometry
pyprt
Python bindings for the "Procedural Runtime" (PRT) of CityEngine by Esri.
Stars: ✭ 36 (+63.64%)
Mutual labels:  geometry

AdaptiveDistanceFields

Build Status codecov

This package implements the adaptively sampled distance fields (ADFs) introduced by Frisken et al. [1]. An ADF represents an arbitrary signed distance function by locally approximating that function with a bilinear interpolation over a quadtree (in 2D) or a trilinear interpolation over an octree (in 3D). When the ADF is created, each cell in the tree is subdivided until the multilinear approximation is a sufficiently close match to the real signed distance function over that cell.

The quadtree and octree data structures and the general adaptive sampling framework are provided by RegionTrees.jl. This package adds the ADF interpolation functions using Interpolations.jl.

[1] Sarah F. Frisken, Ronald N. Perry, and Thouis R. Jones. "Adaptively Sampled Distance Fields: A General Representation of Shape for Computer Graphics". SIGGRAPH 2000.

Usage

Check out the examples folder for additional demonstrations.

To construct the adaptively sampled distance field, you need to at least provide the true signed distance function (typically one which is very expensive to compute) and a range over which to approximate it:

using AdaptiveDistanceFields
using StaticArrays

# Define our true signed distance function
true_signed_distance(x) = norm(x - SVector(0, 0))

# Approximate the signed distance function over the 
# range [-1, 1] in x and y:
origin = SVector(-1, -1)
widths = SVector(2, 2)
adf = AdaptiveDistanceField(true_signed_distance, origin, widths)

# Now we can call the adaptive distance field instead 
# of the original function
adf(SVector(0.6, 0.75))

The accuracy of the approximation can be controlled with the atol and rtol parameters, which set absolute and relative distance error tolerance, respectively:

rtol = 1e-2
atol = 1e-2
adf = AdaptiveDistanceField(true_signed_distance, origin, widths, rtol, atol)

The meanings of rtol and atol are equivalent to those used by the built-in isapprox(): a cell is divided if norm(true - approximate) <= atol + rtol*max(norm(true), norm(approximate)), evaluated at the center of the cell and and the center of each of its faces.

Using meshes

The EnhancedGJK.jl package provides tools for computing the signed distance between convex bodies. In particular, it provides the ReferenceDistance.signed_distance function to compute the distance from a mesh to a point using a slow but straightforward algorithm. That particular method is ideal for adaptive approximation:

julia> Pkg.add("EnhancedGJK")

julia> using MeshIO

julia> using FileIO

julia> using BenchmarkTools

julia> mesh = load(joinpath(Pkg.dir("EnhancedGJK"), "test", "meshes", "base_link.obj"))

HomogenousMesh(
    normals: 52xGeometryTypes.Normal{3,Float32},     vertices: 52xFixedSizeArrays.Point{3,Float32},     faces: 100xGeometryTypes.Face{3,UInt32,-1}, )


julia> adf = AdaptiveDistanceField(ReferenceDistance.signed_distance(mesh),
                                   SVector(-4., -4, -4), SVector(8., 8, 8),
                                   0.05, 0.05)
(::AdaptiveDistanceField) (generic function with 1 method)

julia> p = SVector(0.2, 0.1, 0.15)
3-element StaticArrays.SVector{3,Float64}:
 0.2
 0.1
 0.15

julia> @benchmark(ConvexMesh.signed_distance($mesh, $p))
BenchmarkTools.Trial:
  memory estimate:  1.94 KiB
  allocs estimate:  8
  --------------
  minimum time:     10.346 μs (0.00% GC)
  median time:      10.678 μs (0.00% GC)
  mean time:        11.914 μs (2.06% GC)
  maximum time:     2.510 ms (97.94% GC)
  --------------
  samples:          10000
  evals/sample:     1
  time tolerance:   5.00%
  memory tolerance: 1.00%

julia> @benchmark($adf($p))
BenchmarkTools.Trial:
  memory estimate:  64 bytes
  allocs estimate:  4
  --------------
  minimum time:     145.978 ns (0.00% GC)
  median time:      148.954 ns (0.00% GC)
  mean time:        161.464 ns (2.11% GC)
  maximum time:     1.786 μs (89.29% GC)
  --------------
  samples:          10000
  evals/sample:     832
  time tolerance:   5.00%
  memory tolerance: 1.00%
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].