Intersections¶
Find intersection points between geometric objects.
intersection¶
def intersection(
path1: Segment | Line | Circle,
path2: Segment | Line | Circle,
label: str = "",
*,
index: int = 0,
label_dir: str = "NE",
color: str = "black",
) -> Point
Create the intersection point of two paths.
When two paths intersect at multiple points (e.g., two circles, or a line and a circle), use index to select which intersection point you want.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
path1 |
Segment \| Line \| Circle |
required | First path (segment, line, or circle) |
path2 |
Segment \| Line \| Circle |
required | Second path (segment, line, or circle) |
label |
str |
"" |
Display label (empty for hidden point) |
index |
int |
0 |
Which intersection point (0 or 1 when multiple exist) |
label_dir |
str |
"NE" |
Direction for label placement |
color |
str |
"black" |
Color for the point |
Returns: A Point with Intersection construction.
Example: Segment Intersection¶
"""Segment intersection example - intersection of two segments."""
from geolet import autofigure, intersection, point, segment
@autofigure
def segment_intersection():
A = point(0, 0, "A", label_dir="SW")
B = point(3, 2, "B", label_dir="NE")
C = point(0, 2, "C", label_dir="NW")
D = point(3, 0, "D", label_dir="SE")
seg1 = segment(A, B)
seg2 = segment(C, D)
P = intersection(seg1, seg2, "P", label_dir="N", color="red")
Example: Circle-Circle Intersection¶
"""Circle-circle intersection example - where two circles intersect."""
from geolet import autofigure, circle, intersection, point
@autofigure
def circle_circle_intersection():
O1 = point(0, 0, "O_1", label_dir="S")
O2 = point(2.5, 0, "O_2", label_dir="S")
circle1 = circle(O1, 2.0, color="blue")
circle2 = circle(O2, 2.0, color="green")
P = intersection(circle1, circle2, "P", index=0, label_dir="N", color="red")
Q = intersection(circle1, circle2, "Q", index=1, label_dir="S", color="red")
Example: Circle-Segment Intersection¶
"""Circle-segment intersection example - where a segment crosses a circle."""
from geolet import autofigure, circle, intersection, point, segment
@autofigure
def circle_segment_intersection():
O = point(0, 0, "O", label_dir="S")
A = point(-3, -1, "A", label_dir="SW")
B = point(3, 1, "B", label_dir="NE")
circ = circle(O, 2.0, color="blue")
seg = segment(A, B, style="dashed")
P = intersection(circ, seg, "P", index=0, label_dir="NW", color="red")
Q = intersection(circ, seg, "Q", index=1, label_dir="SE", color="red")