Intersections¶
Find intersection points between geometric objects.
API Reference¶
geolet.primitives.intersections.api.Intersection
¶
Intersection(obj1: Intersectable, obj2: Intersectable, *, label: str = '', index: int = 0, label_dir: str = 'NE', color: str = 'black') -> IntersectionPoint
Create an intersection point between two AsyPath objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj1
|
Intersectable
|
First geometric object (Segment, Circle, Line, etc.). |
required |
obj2
|
Intersectable
|
Second geometric object (Segment, Circle, Line, etc.). |
required |
label
|
str
|
Display name for the intersection point. Omit for hidden. |
''
|
index
|
int
|
Which intersection point (0 or 1) when multiple exist. |
0
|
label_dir
|
str
|
Direction to place label relative to point. |
'NE'
|
color
|
str
|
Asymptote color name. |
'black'
|
Returns:
| Type | Description |
|---|---|
IntersectionPoint
|
An intersection point drawable. |
geolet.primitives.intersections.api.TangentPoint
¶
TangentPoint(point: PointT, circle: CircleT, *, index: int = 0, label: str = '', label_dir: str = 'NE', color: str = 'black') -> IntersectionPoint
Create the point where a tangent line touches a circle.
This is a composition of Tangent and Intersection - it creates a tangent line from the point to the circle, then finds where that tangent touches the circle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
PointT
|
External point from which tangent is drawn. |
required |
circle
|
CircleT
|
The circle to draw tangent to. |
required |
index
|
int
|
Which tangent point (0 or 1) when two exist. |
0
|
label
|
str
|
Display name for the tangent point. Omit for hidden. |
''
|
label_dir
|
str
|
Direction to place label relative to point. |
'NE'
|
color
|
str
|
Asymptote color name. |
'black'
|
Returns:
| Type | Description |
|---|---|
IntersectionPoint
|
The point of tangency as an intersection point. |
Example
O = Point("O", 0, 0) c = CircleWithRadius(O, 2) P = Point("P", 4, 0) T1 = TangentPoint(P, c, index=0, label="T_1") T2 = TangentPoint(P, c, index=1, label="T_2")
Examples¶
Line-Line Intersection¶
from geolet import Point, Line, Intersection, autofigure
@autofigure
def line_intersection():
A = Point("A", 0, 0, label_dir="SW")
B = Point("B", 4, 2, label_dir="NE")
C = Point("C", 0, 2, label_dir="NW")
D = Point("D", 4, 0, label_dir="SE")
line1 = Line(A, B, color="blue")
line2 = Line(C, D, color="red")
Intersection(line1, line2, label="P", color="purple")
Circle-Line Intersection¶
from geolet import Point, Line, CircleWithRadius, Intersection, autofigure
@autofigure
def circle_line_intersection():
O = Point("O", 0, 0, label_dir="SW")
c = CircleWithRadius(O, 2, color="blue")
A = Point("A", -3, -1, label_dir="W")
B = Point("B", 3, 1, label_dir="E")
line = Line(A, B, color="red")
# Two intersection points
Intersection(c, line, index=0, label="P", label_dir="NE")
Intersection(c, line, index=1, label="Q", label_dir="SW")
Circle-Circle Intersection¶
from geolet import Point, CircleWithRadius, Intersection, autofigure
@autofigure
def circle_circle_intersection():
O1 = Point("O_1", 0, 0, label_dir="SW")
O2 = Point("O_2", 2, 0, label_dir="SE")
c1 = CircleWithRadius(O1, 2, color="blue")
c2 = CircleWithRadius(O2, 2, color="red")
Intersection(c1, c2, index=0, label="P", label_dir="N")
Intersection(c1, c2, index=1, label="Q", label_dir="S")
Tangent Points¶
from geolet import Point, CircleWithRadius, TangentPoint, Tangent, autofigure
@autofigure
def tangent_points():
O = Point("O", 0, 0, label_dir="SW")
c = CircleWithRadius(O, 2, color="blue")
P = Point("P", 4, 0, label_dir="E")
# Tangent lines
Tangent(P, c, index=0, color="gray", style="dashed")
Tangent(P, c, index=1, color="gray", style="dashed")
# Points of tangency
TangentPoint(P, c, index=0, label="T_1", color="red")
TangentPoint(P, c, index=1, label="T_2", color="red")