mymesh.primitives.Torus#
- mymesh.primitives.Torus(center, R, r, axis=2, theta_resolution=20, phi_resolution=20, radial_resolution=10, ElemType=None, Type='surf')[source]#
Generate a torus 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.
R (scalar) – The major axis of the torus. This is the distance from the center of the torus to the center of the circular tube.
r (scalar) – The minor axis of the torus. This is the radius of the circular tube.
axis (int) – Axis of revolution of the torus. 0, 1, or 2 for x, y, z, respectively, by default 2
theta_resolution (int, optional) – Number of circular cross sections rotated about the axis, by default 20.
phi_resolution (int, optional) – Number of circumferential points for each circle section, by default 20.
radial_resolution (int, optional) – Number of radial points from center to edge of the circular cross section, by default 10. Only relevant if Type=’vol’.
ElemType (str, optional) – Specify the element type of the mesh. This can either be ‘quad’ for a quadrilateral mesh or ‘tri’ for a triangular mesh, by default None. If ‘quad’ is specified, there will still be some triangles at z axis “poles”.
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:
Mesh object containing the cylinder mesh.
- Return type:
sphere, mymesh.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
torus = primitives.Torus([0,0,0], 1, .25, phi_resolution=50, ElemType='quad') torus.plot(bgcolor='w', show_edges=True)