Geometry helpers¶
Points, lines and polygon geometry helpers (BOSL2 geometry.scad).
-
pybosl2.geometry.circle_circle_tangents(radius1=
None, center1=None, radius2=None, center2=None, diameter1=None, diameter2=None)[source]¶ Tangent lines between two circles.
Computes up to four common tangent lines: two external tangents plus, when the circles do not overlap, two internal (crossing) tangents.
- Parameters:¶
- radius1 : float | None¶
Radius of the first circle (mutually exclusive with diameter1).
- center1 : Point | None¶
Centre point of the first circle.
- radius2 : float | None¶
Radius of the second circle (mutually exclusive with diameter2).
- center2 : Point | None¶
Centre point of the second circle.
- diameter1 : float | None¶
Diameter of the first circle.
- diameter2 : float | None¶
Diameter of the second circle.
- Returns:¶
A list of
(point_on_circle1, point_on_circle2)Pointtuples. Returns up to 4 entries (2 external + 2 internal), 2 entries when only external tangents exist, or an empty list when no tangent can be drawn.- Return type:¶
list[tuple[Point, Point]]
-
pybosl2.geometry.general_line_intersection(line1, line2, eps=
1e-09)[source]¶ Intersection point of two infinite lines.
Computes the intersection of the lines through line1 and line2. Returns parametric positions so the caller can check segment bounds.
-
pybosl2.geometry.is_collinear(point1, point2, point3, eps=
1e-09)[source]¶ Return True if three points lie on a common line (works in 2-D or 3-D).
- pybosl2.geometry.line_closest_point(segment, query_point)[source]¶
Closest point on a bounded segment to a query point.
Projects query_point onto the infinite line through the segment and then clamps the parameter to the segment’s bounds using
numpy.clip().