circle_through_points
Functioncircle_through_points(
states: list[State],
p1: Point2D,
p2: Point2D,
p3: Point2D,
rotation: float = 0,
clockwise: bool = True,
alignment: ElementAlignment = <ElementAlignment.PRESERVE: 'preserve'>,
element_rotation_offset: float = 0,
angles: list[float] | None = None,
radius_fn: Optional[Callable[[int, float], float]] = None,
element_rotation_offset_fn: Optional[Callable[[float], float]] = None
) -> list[State]
Arrange states in a circular formation passing through three given points.
Calculates the circumcircle (circle passing through three points) and arranges states along it. This is useful when you know specific points the circle should pass through rather than its center and radius.
Parameters
-
states - List of states to arrange.
-
p1 - First point on the circumcircle.
-
p2 - Second point on the circumcircle.
-
p3 - Third point on the circumcircle.
-
rotation - Rotation offset in degrees.
-
clockwise - If True, arrange clockwise; if False, counterclockwise.
-
alignment - How to align each element relative to the circle.
-
element_rotation_offset - Additional rotation in degrees added to the alignment base.
-
angles - Optional list of specific angles in degrees for each element.
-
radius_fn - Function that takes (index, default_radius) and returns custom radius.
-
element_rotation_offset_fn - Function that takes position angle and returns rotation offset.
-
Raises -
ValueError - If the three points are collinear (no unique circle)
-
ValueError - If any two points are identical
Examples
# Circle through three points forming a triangle
circle_through_points(states, 0, 100, 100, 0, 0, -100)
# Right triangle points
circle_through_points(states, 0, 0, 100, 0, 0, 100)