fault_mesh.utilities.meshing
Utilities for meshing from fault contours. This module contains functions for triangulating contours and generating meshes from them. Functions:
get_strike_dip_from_normal: Calculate strike and dip from a normal vector
fit_plane_to_points: Fit a plane to a set of 3D points using SVD
triangulate_contours: Triangulate contours and write to a file
Functions
|
|
|
Find best-fit plane through a set of points using SVD. |
|
Triangulate the contours and write to a file |
Module Contents
- fault_mesh.utilities.meshing.get_strike_dip_from_normal(normal_vector)
- Parameters:
normal_vector (numpy.ndarray) – The normal vector to the plane [nx, ny, nz]
- Returns:
A tuple containing (strike, dip) in degrees. Strike is measured 0-360 degrees clockwise from North. Dip is measured 0-90 degrees from horizontal.
- Return type:
tuple(float, float)
- Note:
Uses the right-hand rule convention for strike/dip measurements
- Example:
>>> normal = np.array([0, 0, 1]) >>> strike, dip = get_strike_dip_from_normal(normal) >>> print(strike, dip) 0.0, 0.0
- fault_mesh.utilities.meshing.fit_plane_to_points(points, eps=1e-05)
Find best-fit plane through a set of points using SVD.
This function fits a plane to a set of 3D points by computing the singular value decomposition (SVD) of the moment matrix. The plane passes through the centroid of all points, which improves stability.
- Parameters:
points (numpy.ndarray) – Array of 3D points with shape (n, 3) where n is the number of points.
eps (float) – Threshold to zero out very small components of the normal vector, default is 1.0e-5.
- Returns:
A tuple containing (plane_normal, plane_origin) plane_normal is the unit normal vector to the fitted plane (A, B, C) plane_origin is the centroid of the input points, used as the plane origin
- Return type:
tuple(numpy.ndarray, numpy.ndarray)
- Note:
The function uses SVD on a 3x3 covariance matrix rather than on the full point array, which is more computationally efficient. The returned normal vector is normalized and oriented so that the z-component is positive (when not zero).
- fault_mesh.utilities.meshing.triangulate_contours(contours, mesh_name, mesh_format='vtk', check_mesh=False, check_strike_dip=True)
Triangulate the contours and write to a file :param contours:
The contours to triangulate
- Parameters:
mesh_name (str) – The name of the mesh file to write to
mesh_format – The format of the mesh file to write to
check_mesh (bool) – Whether to check the mesh and plot it
check_strike_dip (bool) – Whether to check the strike and dip of the plane
contours (geopandas.GeoDataFrame)
- Returns:
None