newton.utils.create_cylinder_mesh#

newton.utils.create_cylinder_mesh(radius, half_height, up_axis=1, segments=default_num_segments, top_radius=None)[source]#

Create a cylinder or truncated cone mesh.

Generates vertices and triangle indices for a cylindrical shape with optional different top and bottom radii (creating a truncated cone when different). Includes circular caps at both ends.

Parameters:
  • radius (float) – Radius of the bottom circular face.

  • half_height (float) – Half the total height of the cylinder (distance from center to top/bottom face).

  • up_axis (int) – Axis along which the cylinder extends (0=X, 1=Y, 2=Z). Defaults to 1 (Y-axis).

  • segments (int) – Number of segments around the circumference. Defaults to default_num_segments.

  • top_radius (float, optional) – Radius of the top circular face. If None, uses same radius as bottom (true cylinder). If different, creates a truncated cone.

Returns:

A tuple containing:
  • vertices (np.ndarray): Float32 array of shape (N, 8) where each vertex contains [x, y, z, nx, ny, nz, u, v] (position, normal, UV coords).

  • indices (np.ndarray): Uint32 array of triangle indices for rendering.

Return type:

tuple[np.ndarray, np.ndarray]

Raises:

ValueError – If up_axis is not 0, 1, or 2.