simkit.shape_outlines#

2D outline generators and Triangle-based meshing from closed polylines.

Functions#

shape_mesh(→ Tuple[numpy.ndarray, numpy.ndarray, ...)

Triangulate a closed outline into a surface mesh.

arrow_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Closed polyline outline of an arrow shape.

circle_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Closed polyline approximating a circle.

ellipse_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Closed polyline with approximately uniform arc-length spacing on an ellipse.

rectangle_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Axis-aligned rectangle outline.

plus_sign_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Plus-sign outline (12 vertices).

star_sign_outline(→ Tuple[numpy.ndarray, numpy.ndarray])

Star outline with alternating inner and outer vertices.

Module Contents#

simkit.shape_outlines.shape_mesh(outline_func: Callable[Ellipsis, Tuple[numpy.ndarray, numpy.ndarray]], flags: str = 'qa0.1', *args: Any, **kwargs: Any) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Triangulate a closed outline into a surface mesh.

Parameters:
  • outline_func (callable) – Function returning (Xs, Es) boundary vertices and edges.

  • flags (str, optional) – Flags passed to igl.triangle.triangulate.

  • *args – Forwarded to outline_func.

  • **kwargs – Forwarded to outline_func.

Returns:

  • X (np.ndarray (nv, 2)) – Interior mesh vertices.

  • F (np.ndarray (nf, 3)) – Triangle faces.

  • Xs (np.ndarray) – Boundary vertices from the outline.

  • Es (np.ndarray) – Boundary edges from the outline.

simkit.shape_outlines.arrow_outline(height_body: float = 1, width_body: float = 0.15, width_head: float = 0.3, height_head: float = 0.3) Tuple[numpy.ndarray, numpy.ndarray]#

Closed polyline outline of an arrow shape.

Parameters:
  • height_body (float, optional) – Shaft height and width.

  • width_body (float, optional) – Shaft height and width.

  • width_head (float, optional) – Head width and height above the shaft.

  • height_head (float, optional) – Head width and height above the shaft.

Returns:

  • X (np.ndarray (7, 2)) – Outline vertices.

  • E (np.ndarray (7, 2)) – Closed edge list.

simkit.shape_outlines.circle_outline(radius: float = 1.0, n: int = 100) Tuple[numpy.ndarray, numpy.ndarray]#

Closed polyline approximating a circle.

Parameters:
  • radius (float, optional) – Circle radius.

  • n (int, optional) – Number of vertices on the boundary.

Returns:

  • X (np.ndarray (n, 2)) – Outline vertices.

  • E (np.ndarray (n, 2)) – Closed edge list.

simkit.shape_outlines.ellipse_outline(a: float = 1, b: float = 0.5, n: int = 100) Tuple[numpy.ndarray, numpy.ndarray]#

Closed polyline with approximately uniform arc-length spacing on an ellipse.

Parameters:
  • a (float, optional) – Semi-axis lengths.

  • b (float, optional) – Semi-axis lengths.

  • n (int, optional) – Number of boundary samples.

Returns:

  • X (np.ndarray (n, 2)) – Outline vertices.

  • E (np.ndarray (n, 2)) – Closed edge list.

simkit.shape_outlines.rectangle_outline(small: float = 0.5, large: float = 2) Tuple[numpy.ndarray, numpy.ndarray]#

Axis-aligned rectangle outline.

Parameters:
  • small (float, optional) – Half-heights along the short and long sides.

  • large (float, optional) – Half-heights along the short and long sides.

Returns:

  • X (np.ndarray (4, 2)) – Corner vertices.

  • E (np.ndarray (4, 2)) – Closed edge list.

simkit.shape_outlines.plus_sign_outline(small: float = 0.5, large: float = 2) Tuple[numpy.ndarray, numpy.ndarray]#

Plus-sign outline (12 vertices).

Parameters:
  • small (float, optional) – Inner and outer extent of the arms (requires small < large).

  • large (float, optional) – Inner and outer extent of the arms (requires small < large).

Returns:

  • X (np.ndarray (12, 2)) – Outline vertices.

  • E (np.ndarray (12, 2)) – Closed edge list.

simkit.shape_outlines.star_sign_outline(small: float = 0.5, large: float = 5, legs: int = 10) Tuple[numpy.ndarray, numpy.ndarray]#

Star outline with alternating inner and outer vertices.

Parameters:
  • small (float, optional) – Inner and outer radii of the star tips.

  • large (float, optional) – Inner and outer radii of the star tips.

  • legs (int, optional) – Number of star points.

Returns:

  • X (np.ndarray (3*legs, 2)) – Outline vertices.

  • E (np.ndarray (3*legs, 2)) – Closed edge list.