This project calculates the vertex-wise Gaussian curvature of a 3D triangular mesh using Python and is presented in the form of a Jupyter Notebook. Gaussian curvature helps in understanding the local shape of a surface, such as whether a surface region is convex or concave.
The notebook reads point cloud data in the form of a triangular mesh and calculates Gaussian curvature at each vertex.
- Mesh Loading: Uses
libigl
for reading the triangular mesh. - Mesh Visualization: Utilizes
meshplot
to visualize the mesh and curvature. - Custom Curvature Calculation: The notebook contains a custom implementation for Gaussian curvature calculation without using external curvature functions.
- Color Mapping: Gaussian curvature values are visualized with a colormap applied to the mesh surface.
To run the notebook, you need to install the following dependencies:
- Python 3.x
- Required libraries:
igl
(for mesh processing)meshplot
(for 3D visualization)numpy
(for mathematical operations)
The algorithm iterates through each triangle in the mesh and computes the internal angles at each vertex using the cosine rule. Then, it calculates the corresponding Gaussian curvature values for each vertex based on the angular deficits and the areas of the surrounding triangles.
-
Side Lengths Calculation:
The lengths of the sides of the triangle are calculated using the Euclidean distance formula. -
Angle Calculation:
Internal angles at each vertex are computed using the cosine rule. -
Area Calculation:
The area of each triangle is calculated using the sine of one of its angles and the lengths of the sides. -
Curvature Calculation:
The Gaussian curvature at each vertex is calculated as: K = (2π - sum of angles at vertex) / (area of surrounding triangles)
├── gaussian_curvature.ipynb # Jupyter notebook with the curvature calculation
├── igea.ply # Sample 3D triangular mesh (make sure this is in the same directory)
├── README.md # This readme file
The Gaussian curvature is visualized using meshplot
by mapping the curvature values to a color scale. The notebook contains a function that plots the mesh and colors each vertex based on its Gaussian curvature value.
Example color mapping visualization:
colors = mp.utils.get_colors(g, colormap='viridis', normalize=False, vmin=-200, vmax=200)
mp.plot(vert, tri, colors)