mesh#
- Spline.mesh(radius=None, step_t=0.1, step_angle=5, mesh_type='surface', cap_ends=False, frame='bishop', initial_vector=None)#
Create a 3D mesh around the spline curve.
This method generates a mesh surrounding the spline, with the distance from the spline controlled by the radius parameter. The mesh can be either a surface mesh with triangular cells or a volume mesh with tetrahedral cells. The orientation of the mesh is determined using either the Frenet-Serret or Bishop frame.
Parameters#
- radiusfloat or callable, optional
Defines the distance from the spline to the mesh surface. Can be:
A float for a constant radius.
A callable function that takes the spline parameter t and the polar angle in the normal plane as arguments and returns a float.
If None, the mesh will follow the spline without an offset. Default is None.
- step_tfloat, optional
Step size for the spline parameter t, controlling the resolution along the curve. Smaller values increase mesh resolution. Default is 0.1.
- step_anglefloat, optional
Step size for the polar angle (in degrees), controlling the resolution around the spline. Smaller values increase mesh resolution. Default is 5.
- mesh_typestr, optional
Specifies the type of mesh to create:
“surface”: A surface mesh with triangular cells.
“volume”: A volume mesh with tetrahedral cells.
Default is “surface”.
- cap_endsbool, optional
If True, the ends of an open surface mesh are capped with orthogonal planes. Ignored for closed splines or volume meshes. Default is False.
- framestr, optional
The frame to use for orientation of the mesh: - “frenet”: Uses the Frenet-Serret frame. - “bishop”: Uses the Bishop frame, requiring an initial_vector. See
splinebox.spline_curves.moving_frame(). Default is “bishop”.- initial_vectornumpy array or None, optional
For the Bishop frame, an initial vector that defines the orientation of the frame at the start of the spline (t[0]). This vector must be orthogonal to the tangent at t[0]. Ignored for the Frenet frame. If None, a suitable initial vector is computed automatically. Default is None.
Returns#
- pointsnumpy array
A 2D array of shape (N, 3), where N is the number of mesh points. Each row represents the (x, y, z) coordinates of a point in the mesh.
- connectivitynumpy array
A 2D array of shape (M, K), where M is the number of elements in the mesh and K is the number of vertices per element (3 for surface meshes and 4 for volume meshes). Each row contains the indices of points that form an element.
Raises#
- NotImplementedError
If the spline is not defined in 3D, as meshes are only supported for 3D splines.
Notes#
Surface meshes are useful for visualization, while volume meshes are typically used in simulations and finite element analysis.
For open splines, capping the ends (cap_ends=True) creates closed surfaces, which may be useful for some applications.
The Bishop frame is recommended for curves with inflection points or straight segments where the Frenet frame is undefined.
When radius is callable, the Bishop frame is recommend to avoid “drift” of the polar angle around the curve.
Examples#
Create a surface mesh with constant radius:
>>> points, connectivity = spline.mesh(radius=0.5, step_t=0.1, step_angle=10, mesh_type="surface")
Create a volume mesh with variable radius:
>>> def radius_function(t, angle): >>> return 0.5 + 0.2 * np.sin(np.radians(angle)) >>> points, connectivity = spline.mesh(radius=radius_function, mesh_type="volume")