2D SDFs


sdf_circle(co, radius)

Circle defined by its radius.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • radius (scalar_like_type) –

    Radius of the circle.

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_box_2d(co, size)

Rectangle defined by its side lengths.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • size (array_like_type) –

    side lengths of the rectangle (a, b).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_segment_2d(co, a, b)

Line segment defined by its end points.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • a (array_like_type) –

    Vector defining the position of the start point (D = 3,).

  • b (array_like_type) –

    Vector defining the position of the end point (D = 3,).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_rounded_box_2d(co, size, rounding)

Rectangle defined by its side lengths.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • size (array_like_type) –

    side lengths of the rectangle (a, b).

  • rounding (array_like_type) –

    rounding radii for each of the corners (r1, r2, r3, r4).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_triangle_2d(co, p0, p1, p2)

Triangle defined by the three vertices.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • p0 (array_like_type) –

    Vector defining the position of the first vertex (D = 3,).

  • p1 (array_like_type) –

    Vector defining the position of the second vertex (D = 3,).

  • p2 (array_like_type) –

    Vector defining the position of the third vertex (D = 3,).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_arc(co, radius, start_angle, end_angle)

Arc defined by the radius and the angles of both ends.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • radius (scalar_like_type) –

    Radius of the arc.

  • start_angle (scalar_like_type) –

    Angle of one end with respect to the x-axis.

  • end_angle (scalar_like_type) –

    Angle of the other end with respect to the x-axis.

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_sector(co, radius, angle_1, angle_2)

Sector defined by the radius of the circle and two angles.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • radius (scalar_like_type) –

    Radius of the circle.

  • angle_1 (scalar_like_type) –

    First angle defining the sector.

  • angle_2 (scalar_like_type) –

    Second angle defining the sector.

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_inf_sector(co, angle_1, angle_2)

Sector of infinite radius defined by two angles.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • angle_1 (scalar_like_type) –

    First angle defining the sector.

  • angle_2 (scalar_like_type) –

    Second angle defining the sector.

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_ngon(co, radius, n)

N-sided regular polygon, defined by the outer radius and the number of sides.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • radius (scalar_like_type) –

    Outer radius of the regular polygon.

  • n (int) –

    Number of sides of the regular polygon.

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_segmented_line_2d(co, points)

Segmented line connecting the provided points.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • points (array_like_type) –

    Points to connect (D = 3, M).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_closed_segmented_line_2d(co, points)

Closed segmented line connecting the provided points.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • points (array_like_type) –

    Points to connect (D = 3, M).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

sdf_polygon_2d(co, points)

Convex polygon with vertices at the provided coordinate points.

Parameters:
  • co (array_like_type) –

    coordinates of points on which the SDF is evaluated. Shape must be (D, N), where D is the dimension of the coordinate system (D = 3), N is the number of coordinate points.

  • points (array_like_type) –

    Points to connect (D = 3, M).

Returns:
  • ndarray

    SDF, with shape (N,), evaluated at the provided coordinate points.

check_convex_all(vs)

Checks if a polygon is convex.

Parameters:
  • vs (ndarray) –

    Coordinates of the vertices with shape (D >= 2, N), where N is the number of vertices.

Returns: Convexity of each vertex.

interior_convex(co, points)

Partitions the coordinate system into the interior (-1) and exterior (+1) of a convex polygon.

Parameters:
  • co (ndarray) –

    Point cloud of coordinates with shape (D >= 2, N); D - number of dimensions; N - number of points in the point cloud.

  • points (ndarray) –

    Coordinates of the vertices with shape (D >= 2, N), where N is the number of vertices.

Returns: Map of the interior and exterior of the polygon (N,).