shapes.sphere#
- shapes.sphere(radius=1.0, center=(0.0, 0.0, 0.0), long_div=36, lat_div=18)#
Create a triangular mesh approximating a sphere.
Parameters#
- radiusfloat, optional
Radius of the sphere. Must be > 0. Default is 1.0.
- centerarray_like of shape (3,), optional
Coordinates of the sphere center. Default is (0.0, 0.0, 0.0).
- long_divint, optional
Number of subdivisions along the longitudinal direction (around the sphere’s vertical axis). Must be >= 3. Default is 36.
- lat_divint, optional
Number of subdivisions along the latitudinal direction (from pole to pole). Must be >= 2. Default is 18.
Returns#
- Mesh
A triangular surface mesh representing the sphere (
eltype='tri3').
Examples#
>>> S = sphere(radius=2.0, long_div=24, lat_div=12) >>> print(S) Mesh: n_nodes: 266, n_elems: 528, plexitude: 3, level: 2, eltype: tri3 BBox: [-2. -2. -2.], [2. 2. 2.] Size: [4. 4. 4.] Length: 0.0 Area: 49.55 >>> np.isclose(S.enclosed_volume(), 32.564, rtol=1e-3, atol=1e-6) True