All Projects → InteractiveComputerGraphics → TriangleMeshDistance

InteractiveComputerGraphics / TriangleMeshDistance

Licence: MIT License
Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to TriangleMeshDistance

intersection-wasm
Mesh-Mesh and Triangle-Triangle Intersection tests based on the algorithm by Tomas Akenine-Möller
Stars: ✭ 17 (-69.09%)
Mutual labels:  triangle, collision-detection, mesh
Three Mesh Bvh
A BVH implementation to speed up raycasting against three.js meshes.
Stars: ✭ 302 (+449.09%)
Mutual labels:  geometry, distance, mesh
Geokit
Geo-Toolkit for PHP.
Stars: ✭ 223 (+305.45%)
Mutual labels:  geometry, distance
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 (-45.45%)
Mutual labels:  simulation, collision-detection
Complete street rule
The Complete Street Rule for ArcGIS CityEngine is a scenario oriented design tool intended to enable users to quickly create procedurally generated multimodal streets.
Stars: ✭ 81 (+47.27%)
Mutual labels:  simulation, geometry
Hole fixer
Demo implementation of smoothly filling holes in 3D meshes using surface fairing
Stars: ✭ 165 (+200%)
Mutual labels:  geometry, mesh
Matgeom
Matlab geometry toolbox for 2D/3D geometric computing
Stars: ✭ 168 (+205.45%)
Mutual labels:  geometry, mesh
Reactphysics3d
Open source C++ physics engine library in 3D
Stars: ✭ 730 (+1227.27%)
Mutual labels:  simulation, collision-detection
Plexus
Polygonal mesh processing.
Stars: ✭ 90 (+63.64%)
Mutual labels:  geometry, mesh
classy blocks
Python classes for easier creation of OpenFOAM's blockMesh dictionaries.
Stars: ✭ 53 (-3.64%)
Mutual labels:  geometry, mesh
IsoMesh
IsoMesh is a group of related tools for Unity for converting meshes into signed distance field data, raymarching signed distance fields, and extracting signed distance field data back to meshes via surface nets or dual contouring.
Stars: ✭ 178 (+223.64%)
Mutual labels:  sdf, signed-distance-fields
Building Blocks
A voxel library for real-time applications.
Stars: ✭ 140 (+154.55%)
Mutual labels:  geometry, mesh
Polylidar
Polylidar3D - Fast polygon extraction from 3D Data
Stars: ✭ 106 (+92.73%)
Mutual labels:  geometry, mesh
Cheap Ruler Go
📏 cheapruler in Go: fast geodesic measurements
Stars: ✭ 176 (+220%)
Mutual labels:  geometry, distance
Trimesh
Python library for loading and using triangular meshes.
Stars: ✭ 1,303 (+2269.09%)
Mutual labels:  geometry, mesh
Dyn4j
Java Collision Detection and Physics Engine
Stars: ✭ 317 (+476.36%)
Mutual labels:  simulation, collision-detection
femio
FEM I/O tool
Stars: ✭ 15 (-72.73%)
Mutual labels:  simulation, mesh
Tinyply
🌍 C++11 ply 3d mesh format importer & exporter
Stars: ✭ 358 (+550.91%)
Mutual labels:  geometry, mesh
Pas Coogeo
Pas-CooGeo is coordinate geometry library for Pascal.
Stars: ✭ 25 (-54.55%)
Mutual labels:  geometry, distance
Gismo
G+Smo (pronounced gismo or gizmo) is a C++ library for isogeometric analysis (IGA). Geometry plus simulation modules aims at the seamless integration of Computer-aided Design (CAD) and Finite Element Analysis (FEA).
Stars: ✭ 152 (+176.36%)
Mutual labels:  simulation, geometry

TriangleMeshDistance

Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh.

The distance computation to the triangle collection is accelerated with a sphere bounding volume hierarchy. The sign of the distance is resolved with the method presented in "Generating Signed Distance Fields From Triangle Meshes" by Bærentzen, Andreas & Aanæs, Henrik. (2002).

Assuming triangle normals point outwards from the enclosed volume, the sign of the distance will be positive outside and negative inside.

Example

// Declare mesh vertices and triangles
std::vector<std::array<double, 3>> vertices;
std::vector<std::array<int, 3>> triangles;

// (... fill the `vertices` and `triangles` with the mesh data ...)

// Initialize TriangleMeshDistance
tmd::TriangleMeshDistance mesh_distance(vertices, triangles);

// Query TriangleMeshDistance
tmd::Result result = mesh_distance.signed_distance({ x, y, z });

// Print result
std::cout << "Signed distance: " << result.distance << std::endl;
std::cout << "Nearest point: " << result.nearest_point << std::endl;
std::cout << "Nearest entity: " << result.nearest_entity << std::endl;
std::cout << "Nearest triangle index: " << result.triangle_id << std::endl;

What you need to know about TriangleMeshDistance

  • The input triangle mesh must be fully connected and watertight. Triangle soups and meshes with holes will return the correct distance but the sign will be undefined.
  • Triangle winding (consistent normals orientation) is not verified. The input mesh is required to have consistent normals.
  • TriangleMeshDistance keeps a copy of the vertex and triangle data.
  • The pseudonormals required to compute signed distances are calculated and stored at building time.
  • TriangleMeshDistance can be declared empty and constructed multiple times with different meshes. If the new mesh needs less memory than the curent one, memory allocations will be avoided.

Projects using TriangleMeshDistance

  • Discregrid - A static C++ library for the generation of discrete functions on a box-shaped domain. This is especially suited for the discretization of signed distance fields.
  • PBD - A C++ library for physically-based simulation of rigid bodies, deformables, cloth and fluids using Position-Based Dynamics.
  • SPlisHSPlasH - A C++ library for the physically-based simulation of fluids using Smoothed Particle Hydrodynamics.
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].