mymesh.primitives.Sphere#
- mymesh.primitives.Sphere(center, radius, theta_resolution=20, phi_resolution=20, radial_resolution=10, ElemType=None, Type='surf')[source]#
Generate a sphere (or ellipsoid) The total number of points will be phi_resolution*(theta_resolution-2) + 2
- Parameters:
center (array_like) – Three element array of the coordinates of the center of the sphere.
radius (scalar or array_like) – The radius of the sphere. Radius can be specified as a scalar radius of the sphere or three element array of half-axes for an ellipsoid.
theta_resolution (int, optionalperpendicular) – Number of circular (or elliptical) cross sections sampled along the z axis, by default 20.
phi_resolution (int, optional) – Number of circumferential points for each cross section, by default 20.
radial_resolution (int, optional) – Number of radial points from center to edge, by default 10. Only relevant if Type=’vol’.
ElemType (str, optional) – Specify the element type of the mesh. If Type=’surf’ (default), ElemType can be ‘tri’, which will produce a purely triangular mesh or None, which will produce a quad-dominant mesh with some triangles. If Type=’vol’, ElemType can be ‘tet’, which will produce a purely tetrahedral mesh or None, which will produce a hex-dominant mesh with some tetrahedra. By default, None.
Type (str, optional) – Mesh type of the final mesh. This could be ‘surf’ for a surface mesh or ‘vol’ for a volumetric mesh, by default ‘surf’.
- Returns:
sphere, mymesh.mesh – Mesh object containing the cylinder mesh.
.. note:: – Due to the ability to unpack the mesh object to NodeCoords and NodeConn, the NodeCoords and NodeConn array can be returned directly (instead of the mesh object) by running:
NodeCoords, NodeConn = primitives.Sphere(...)
Examples
sphere = primitives.Sphere([0,0,0], 1) sphere.plot(bgcolor='w', show_edges=True)
ellipsoid = primitives.Sphere([0,0,0], (0.5,1,1.5), theta_resolution=20, phi_resolution=20) ellipsoid.plot(bgcolor='w', show_edges=True)