Geometry helpers¶
- bosl2.geometry.cross(a, b)[source]¶
3D cross product (returns an ndarray), or 2D cross product (returns a scalar).
- bosl2.geometry.is_collinear(a, b=None, c=None, eps=1e-09)[source]¶
True if points a, b, c lie on a common line (any dimension).
- Parameters:
eps (float)
- Return type:
bool
- bosl2.geometry.line_normal(p1, p2=None)[source]¶
Return the unit 2D normal (perpendicular, to the left) of the line through p1, p2.
- Return type:
- bosl2.geometry.line_closest_point(segment, pt)[source]¶
Closest point on the bounded segment = (a, b) to point pt.
- Return type:
- bosl2.geometry.pointlist_bounds(pts)[source]¶
Return [min_corner, max_corner] bounding box of a list of points, as a (2, dim) ndarray.
- Return type:
- bosl2.geometry.general_line_intersection(s1, s2, eps=1e-09)[source]¶
Intersection of infinite lines through segments s1=(a,b), s2=(c,diameter).
Returns [point, t, u] where t/u are the parametric positions of the intersection along s1/s2 (0 at the first point, 1 at the second), or None if the lines are parallel or coincident.
- Parameters:
eps (float)
- bosl2.geometry.circle_circle_tangents(radius1, cp1, radius2, cp2, diameter1=None, diameter2=None)[source]¶
Tangent lines between two circles (radius1, cp1) and (radius2, cp2).
Returns a list of up to 4 tangent lines, each a [point_on_circle1, point_on_circle2] pair: 2 external tangents plus 2 internal (crossing) tangents if the circles don’t overlap, or just the 2 external tangents if they do.
- Parameters:
radius1 (float)
radius2 (float)
diameter1 (float | None)
diameter2 (float | None)
- Return type:
list[list[list[float]]]