3D-Hausdorff-Distance-Calculator
is a Python tool designed to calculate the Hausdorff distance between two 3D models provided in STL format. The Hausdorff distance is a measure of the maximum discrepancy between two sets of points, making it useful for comparing 3D shapes, particularly when evaluating the fidelity of 3D printed objects to their original designs.
Note
The calculation will differ depending on the orientation of the model, so be sure to calculate with the same orientation.
- Load and process STL files to extract 3D mesh data.
- Calculate the Hausdorff distance between two 3D models.
- Useful for quality control in 3D printing, scanning, and reverse engineering.
- Python 3.7+
- numpy
- scipy
- numpy-stl
You can install the required packages using pip
:
pip install numpy scipy numpy-stl
For macOS users, it is recommended to use miniforge to create a clean Anaconda environment for running the script. Follow these steps to set up the environment:
-
Install Miniforge: follow the instructions on the Miniforge GitHub page
-
Create a new conda environment: Create a New Conda Environment:
conda create -n hausdorff-env python=3.9
- Activate the new environment:
conda activate hausdorff-env
- Install the required packages:
pip install numpy scipy numpy-stl
- Place your STL files in the same directory as the script.
- Run the Python script to calculate the Hausdorff distance:
python main.py
You can use the provided sample STL files to test the script. The cube.stl
and sphere_[mesh_size].stl
files contain two simple 3D models for testing the Hausdorff distance calculation.
- cube.stl and cube.stl
Hausdorff Distance : 0.0
- cube.stl and sphere_3840.stl
Hausdorff Distance : 25.00000704946435
- sphere3480.stl and sphere_28560.stl
Hausdorff Distance : 1.7884412788761033
- sphere_9024.stl and sphere_28560.stl: takes a few miniutes to calculate
Hausdorff Distance : 1.105467263395086