svg_path/encounters
Combined continuous-overlap and isolated point-intersection queries.
This module composes the existing svg_path/overlaps and
svg_path/intersections results without changing their payload types.
Types
Continuous overlaps and point intersections reported for one query.
pub type Encounters(overlap, intersection) {
Encounters(
overlaps: List(overlap),
intersections: List(intersection),
)
}
Constructors
-
Encounters( overlaps: List(overlap), intersections: List(intersection), )
Values
pub fn path(
left: svg_path.Path,
right: svg_path.Path,
) -> Result(
Encounters(overlaps.PathOverlap, svg_path.PathIntersection),
svg_path.Error,
)
Return overlap intervals and point intersections between two paths.
pub fn path_with(
left: svg_path.Path,
right: svg_path.Path,
options options: intersections.IntersectionOptions,
) -> Result(
Encounters(overlaps.PathOverlap, svg_path.PathIntersection),
svg_path.Error,
)
Return path encounters using explicit intersection options.
pub fn segment(
left: svg_path.Segment,
right: svg_path.Segment,
) -> Result(
Encounters(
overlaps.SegmentOverlap,
svg_path.SegmentIntersection,
),
svg_path.Error,
)
Return overlap intervals and point intersections between two segments.
Detected overlap intervals are returned alongside isolated parameter-pair intersections. For overlapping segments, the point search partitions the parameter domains at overlap boundaries and skips corresponding overlap windows. It also checks self-intersections for off-diagonal parameter pairs that reach the same point without following the overlap correspondence.
Point intersections explained by an overlap correspondence are removed;
the remaining intersections are deduplicated and sorted by left_t.
pub fn segment_subpath(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
) -> Result(
Encounters(
overlaps.SegmentSubpathOverlap,
#(svg_path.Point, Float, List(svg_path.SubpathParameter)),
),
svg_path.Error,
)
Return overlap intervals and point intersections between a standalone segment and a subpath.
pub fn segment_subpath_with(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
options options: intersections.IntersectionOptions,
) -> Result(
Encounters(
overlaps.SegmentSubpathOverlap,
#(svg_path.Point, Float, List(svg_path.SubpathParameter)),
),
svg_path.Error,
)
Return segment-subpath encounters using explicit intersection options.
pub fn segment_with(
left: svg_path.Segment,
right: svg_path.Segment,
options options: intersections.IntersectionOptions,
) -> Result(
Encounters(
overlaps.SegmentOverlap,
svg_path.SegmentIntersection,
),
svg_path.Error,
)
Return segment encounters using explicit intersection options.
options.tolerance is also passed unchanged to overlap detection.
pub fn subpath(
left: svg_path.Subpath,
right: svg_path.Subpath,
) -> Result(
Encounters(
overlaps.SubpathOverlap,
svg_path.SubpathIntersection,
),
svg_path.Error,
)
Return overlap intervals and point intersections between two subpaths.
Point intersections are collected from every constituent segment pair.
Overlap-boundary intersections are retained; use
subpath_remove_redundant_intersections to derive
a filtered view.
pub fn subpath_remove_redundant_intersections(
encounters: Encounters(
overlaps.SubpathOverlap,
svg_path.SubpathIntersection,
),
left_subpath: svg_path.Subpath,
right_subpath: svg_path.Subpath,
tolerance: Float,
) -> Result(
Encounters(
overlaps.SubpathOverlap,
svg_path.SubpathIntersection,
),
svg_path.Error,
)
Remove point-intersection parameters fully accounted for by the continuous overlaps in an existing subpath encounter result. The overlaps are unchanged.
This is an optional derived view. The ordinary subpath encounter functions return their complete, unfiltered point-intersection results.
For each intersection record, a left parameter is removed only if every right parameter in that record is paired with it by some reported overlap. Different pairs may be accounted for by different overlaps. Right parameters are tested symmetrically against the original left list, not the filtered one. A record is removed only when both parameter lists become empty.
A pair is accounted for by an overlap when its piecewise-affine parameter
correspondence matches in both directions. Each input address may first be
clamped onto the overlap if it is at most tolerance away along its subpath.
Mapping that clamped address through the overlap must then land at most
tolerance from the original opposite address, again along that subpath.
These checks use arc length, not Euclidean point distance or local parameter
distance. Closed subpaths use the shorter of the two traversal distances.
tolerance must be finite and positive; underlying geometry errors propagate.
Thus merely sharing a point with an overlap is insufficient. For example, if a record has left addresses A and B and right address C, and only A/C are accounted for by an overlap, A is removed but B and C remain: B/C still represents a point intersection not described by the overlaps.
pub fn subpath_with(
left: svg_path.Subpath,
right: svg_path.Subpath,
options options: intersections.IntersectionOptions,
) -> Result(
Encounters(
overlaps.SubpathOverlap,
svg_path.SubpathIntersection,
),
svg_path.Error,
)
Return subpath encounters using explicit intersection options.
options.tolerance is passed unchanged to overlap detection.