svg_path_editor.intersect#
Attributes#
Classes#
Common protocol for intersection results. |
|
Intersection of two parameterized lines. |
|
Degenerate “intersection” of coincident parametric lines. |
|
Fallback “around” configuration for two line segments. |
|
Intersection of a line with the interior of an elliptical arc. |
|
Intersection of a line with an arc’s tangent half-line. |
|
Fallback “around” configuration for a line and an arc. |
|
Intersection of two elliptical arcs. |
|
Intersection of the tangent half-lines of two arcs. |
|
Fallback “around” configuration when arcs neither meet nor converge. |
Functions#
|
Public intersection helper. |
|
Raw line-line intersection without segment clipping. |
|
Segment-segment intersection. |
|
Intersect a line segment with an elliptical arc and its tangents. |
|
Intersect two elliptical arcs. |
Module Contents#
- type svg_path_editor.intersect.Expr = 'sp.Expr'#
- type svg_path_editor.intersect.Symbol = 'sp.Symbol'#
- class svg_path_editor.intersect.Intersection[source]#
Bases:
ProtocolCommon protocol for intersection results.
- Variables:
intersection – The intersection point.
- svg_path_editor.intersect.intersect(a: Line, b: Line, *, d: decimal.Decimal | None = None, n: Precision | None = None) LineIntersection | LineCoincidentIntersection | LineAroundIntersection | None[source]#
- svg_path_editor.intersect.intersect(a: Line, b: ParametricEllipticalArc, *, d: decimal.Decimal | None = None, n: Precision | None = None) LineArcIntersection | LineArcExtIntersection | LineArcAroundIntersection | None
- svg_path_editor.intersect.intersect(a: ParametricEllipticalArc, b: Line, *, d: decimal.Decimal | None = None, n: Precision | None = None) LineArcIntersection | LineArcExtIntersection | LineArcAroundIntersection | None
- svg_path_editor.intersect.intersect(a: ParametricEllipticalArc, b: ParametricEllipticalArc, *, d: decimal.Decimal | None = None, n: Precision | None = None) ArcArcIntersection | ArcArcExtIntersection | ArcArcAroundIntersection | None
Public intersection helper.
Dispatches to the appropriate specialized routine using structural pattern matching on the argument types.
- Parameters:
a – First primitive (line or arc).
b – Second primitive (line or arc).
d – Optional offset distance used only in “around” fallbacks.
n – Optional precision for SymPy evaluations.
- Returns:
An intersection record or
Noneif nothing applicable is found.
- class svg_path_editor.intersect.LineIntersection[source]#
Intersection of two parameterized lines.
\[p_0 + (q_0 - p_0)\,t = p_1 + (q_1 - p_1)\,u.\]- Variables:
t – Parameter on the first line.
u – Parameter on the second line.
intersection – Common point.
- property swapped: Self#
Swap coordinates of the intersection point.
- Return type:
Self
- class svg_path_editor.intersect.LineCoincidentIntersection[source]#
Degenerate “intersection” of coincident parametric lines.
Used when two lines lie on top of each other. A single representative point is stored.
- Variables:
t – Chosen parameter on the first line.
u – Corresponding parameter on the second line.
intersection – Common endpoint on the coincident line.
- property swapped: Self#
Swap coordinates of the intersection point.
- Return type:
Self
- class svg_path_editor.intersect.LineAroundIntersection[source]#
Fallback “around” configuration for two line segments.
The segments neither meet nor their endpoint-endpoint connector lies on both segments. This synthesizes a connection via an intermediate point.
- Variables:
intersection – Midpoint of the constructed connection.
ante_intersection – End of the first segment.
post_intersection – Start of the second segment.
ante_extended – Offset from
ante_intersectionalong the first line.post_extended – Offset from
post_intersectionalong the second line.
- svg_path_editor.intersect.intersect_lines_raw(l0, l1, *, n=None)[source]#
Raw line-line intersection without segment clipping.
Solves for parameters \(t, u\) such that the two parametric lines meet. Returns
Nonewhen they are parallel and distinct.Degenerate collinear overlap is represented by picking the end of \(l_0\).
- Parameters:
- Return type:
- svg_path_editor.intersect.intersect_lines(l0, l1, *, d=None, n=None)[source]#
Segment-segment intersection.
Returns the line-line intersection if it lies within both segments, i.e. \(t, u ∈ [0, 1]\).
If no intersection exists and
dis given, returns aLineAroundIntersectionconstructed from the closest endpoints.- Parameters:
l0 (Line) – First line segment.
l1 (Line) – Second line segment.
d (decimal.Decimal | None) – Optional offset distance for constructing an “around” connector.
n (Precision | None) – Optional precision for
intersect_lines_raw().
- Return type:
LineIntersection | LineCoincidentIntersection | LineAroundIntersection | None
- class svg_path_editor.intersect.LineArcIntersection[source]#
Intersection of a line with the interior of an elliptical arc.
tis the line parameter,thetais the ellipse parameter in degrees.- Variables:
t – Parameter along the line segment.
theta – Angle parameter on the arc in degrees.
intersection – Common point.
- class svg_path_editor.intersect.LineArcExtIntersection[source]#
Intersection of a line with an arc’s tangent half-line.
Covers the half-lines defined by tangents at the arc endpoints:
ext="ante": tangent at start angle, extended backwards.ext="post": tangent at end angle, extended forwards.
- Variables:
t – Parameter along the line.
u – Parameter along the tangent half-line.
intersection – Common point of the line and tangent.
post_intersection – Endpoint of the arc used for the tangent.
theta – Angle of the tangent point in degrees.
ext – Which endpoint tangent is used (
"ante"or"post").
- ext: Literal['ante', 'post']#
- class svg_path_editor.intersect.LineArcAroundIntersection[source]#
Fallback “around” configuration for a line and an arc.
Used when the line segment does not intersect the arc or its endpoint tangent half-lines. Synthesizes a connection via offset points.
- Variables:
intersection – Midpoint of the constructed connection.
ante_intersection – End of the line or arc reached first.
post_intersection – Start of the following primitive.
ante_extended – Offset point from
ante_intersection.post_extended – Offset point from
post_intersection.
- svg_path_editor.intersect.intersect_line_arc(lin, arc, *, line_before_arc, d, n)[source]#
Intersect a line segment with an elliptical arc and its tangents.
Intersect the line with the full ellipse in ellipse-local coordinates.
Filter hits whose line-parameter and arc-angle lie on the segment/arc.
If none, intersect the appropriate endpoint tangent half-line.
If still none and
dis given, synthesize an “around” configuration.
The first valid solution encountered is returned.
- Parameters:
lin (Line) – Line segment.
arc (ParametricEllipticalArc) – Elliptical arc.
line_before_arc (bool) – If
True, the line precedes the arc in path order.d (decimal.Decimal | None) – Optional offset distance for an “around” configuration.
n (Precision | None) – Optional precision for internal SymPy calls.
- Return type:
LineArcIntersection | LineArcExtIntersection | LineArcAroundIntersection | None
- class svg_path_editor.intersect.ArcArcIntersection[source]#
Intersection of two elliptical arcs.
theta0andtheta1are the ellipse parameters at the common point on the first and second arc, respectively (in degrees).- Variables:
theta0 – Angle on the first arc in degrees.
theta1 – Angle on the second arc in degrees.
intersection – Common point.
- class svg_path_editor.intersect.ArcArcExtIntersection[source]#
Intersection of the tangent half-lines of two arcs.
tanduare the parameters along those half-lines.- Variables:
t – Parameter along the tangent from the first arc.
u – Parameter along the tangent from the second arc.
intersection – Intersection of the two tangent half-lines.
ante_intersection – Tangent point on the first arc.
post_intersection – Tangent point on the second arc.
- class svg_path_editor.intersect.ArcArcAroundIntersection[source]#
Fallback “around” configuration when arcs neither meet nor converge.
Used to synthesize a connection via offset tangent points.
- Variables:
intersection – Midpoint of the constructed connection.
ante_intersection – End of the first arc.
post_intersection – Start of the second arc.
ante_extended – Offset from
ante_intersection.post_extended – Offset from
post_intersection.
- svg_path_editor.intersect.intersect_arc_arc(arc0, arc1, *, d=None, n=None)[source]#
Intersect two elliptical arcs.
Compute the resultant of their implicit equations to eliminate \(y\).
Solve for candidate \(x\) and refine to \((x, y)\) intersection points.
Map to angular parameters on both arcs and check angle ranges.
If no interior intersection exists, intersect the endpoint tangents.
As a last resort, construct an “around” configuration using offsets.
- Parameters:
arc0 (ParametricEllipticalArc) – First elliptical arc.
arc1 (ParametricEllipticalArc) – Second elliptical arc.
d (decimal.Decimal | None) – Optional offset distance for an “around” configuration.
n (Precision | None) – Optional precision for internal SymPy roots.
- Returns:
Any of the arc-arc intersection variants, or
None.- Return type:
ArcArcIntersection | ArcArcExtIntersection | ArcArcAroundIntersection | None