svg_path/overlaps
Continuous coincident intervals between path traversals.
Every returned overlap is represented as one or more SegmentOverlap
correspondences. Within each piece, the left and right segment parameters
have one affine, monotone relationship. Multiply traced or non-monotone
coincident geometry that cannot satisfy this contract returns
svg_path.NonAffineOverlapCorrespondence; normalize or linearize those
segments before overlap detection.
A supplied tolerance is non-negative. It is used as a Euclidean distance
in path coordinates when testing coincidence and, during interval merging,
as a normalized segment-parameter tolerance. Invalid negative tolerances
return svg_path.InvalidOverlapTolerance.
Opposite-parameter lookup is exact with respect to a returned overlap. It
accepts exact segment-end aliases and canonicalizes the returned address,
but it does not snap nearby parameters or move them geometrically. The
tolerance-based arc-length clamping used by encounter filtering belongs to
svg_path/encounters, not this module.
Types
One continuous overlap between a specific ordered pair of path subpaths.
correspondence preserves the complete piecewise-affine parameter map.
pub type PathOverlap {
PathOverlap(
left_subpath_index: Int,
right_subpath_index: Int,
correspondence: SubpathOverlap,
)
}
Constructors
-
PathOverlap( left_subpath_index: Int, right_subpath_index: Int, correspondence: SubpathOverlap, )
One non-zero-length overlap interval between the same ordered pair of segments. The left parameters and points follow the left segment’s traversal. The right parameters retain the corresponding traversal direction and may therefore decrease.
The four endpoint parameters define an affine correspondence throughout
the overlap. For any parameter between left_from and left_to, linearly
interpolating between right_from and right_to identifies the same
geometric point on the right segment, within the overlap tolerance.
pub type SegmentOverlap {
SegmentOverlap(
left_from: Float,
left_to: Float,
right_from: Float,
right_to: Float,
start: svg_path.Point,
end: svg_path.Point,
)
}
Constructors
-
SegmentOverlap( left_from: Float, left_to: Float, right_from: Float, right_to: Float, start: svg_path.Point, end: svg_path.Point, )
One continuous overlap between a standalone segment and a subpath.
pieces follows the standalone segment’s traversal and preserves the full
piecewise-affine parameter correspondence to the subpath.
pub type SegmentSubpathOverlap {
SegmentSubpathOverlap(
start: svg_path.Point,
end: svg_path.Point,
pieces: List(SegmentSubpathOverlapPiece),
)
}
Constructors
-
SegmentSubpathOverlap( start: svg_path.Point, end: svg_path.Point, pieces: List(SegmentSubpathOverlapPiece), )
One affine piece of a continuous overlap between a standalone segment and a subpath traversal.
pub type SegmentSubpathOverlapPiece {
SegmentSubpathOverlapPiece(
subpath_segment_index: Int,
correspondence: SegmentOverlap,
)
}
Constructors
-
SegmentSubpathOverlapPiece( subpath_segment_index: Int, correspondence: SegmentOverlap, )
One continuous overlap between two subpath traversals.
pieces is non-empty for values returned by this module. It follows the
left subpath’s traversal and supplies the complete piecewise-affine
parameter correspondence to the right subpath.
pub type SubpathOverlap {
SubpathOverlap(
start: svg_path.Point,
end: svg_path.Point,
pieces: List(SubpathOverlapPiece),
)
}
Constructors
-
SubpathOverlap( start: svg_path.Point, end: svg_path.Point, pieces: List(SubpathOverlapPiece), )
One affine piece of a continuous overlap between two subpath traversals.
pub type SubpathOverlapPiece {
SubpathOverlapPiece(
left_segment_index: Int,
right_segment_index: Int,
correspondence: SegmentOverlap,
)
}
Constructors
-
SubpathOverlapPiece( left_segment_index: Int, right_segment_index: Int, correspondence: SegmentOverlap, )
Values
pub fn path(
left: svg_path.Path,
right: svg_path.Path,
) -> Result(List(PathOverlap), svg_path.Error)
Return overlaps between two paths.
pub fn path_overlap_left_end(
overlap: PathOverlap,
) -> option.Option(svg_path.PathParameter)
Last parameter of a path overlap on the left path traversal.
pub fn path_overlap_left_parameter(
overlap: PathOverlap,
right_parameter: svg_path.PathParameter,
left_path: svg_path.Path,
right_path: svg_path.Path,
) -> Result(option.Option(svg_path.PathParameter), svg_path.Error)
Map a right-path address to its exact opposite left-path address.
pub fn path_overlap_left_start(
overlap: PathOverlap,
) -> option.Option(svg_path.PathParameter)
First parameter of a path overlap on the left path traversal.
pub fn path_overlap_right_end(
overlap: PathOverlap,
) -> option.Option(svg_path.PathParameter)
Last parameter of a path overlap on the right path traversal.
pub fn path_overlap_right_parameter(
overlap: PathOverlap,
left_parameter: svg_path.PathParameter,
left_path: svg_path.Path,
right_path: svg_path.Path,
) -> Result(option.Option(svg_path.PathParameter), svg_path.Error)
Map a left-path address to its exact opposite right-path address.
pub fn path_overlap_right_start(
overlap: PathOverlap,
) -> option.Option(svg_path.PathParameter)
First parameter of a path overlap on the right path traversal.
pub fn path_with(
left: svg_path.Path,
right: svg_path.Path,
tolerance tolerance: Float,
) -> Result(List(PathOverlap), svg_path.Error)
Return path overlaps using an explicit non-negative tolerance.
Results retain the complete subpath correspondence and the two source subpath indices. Continuous overlaps never join across subpath boundaries. The tolerance has the module-wide geometric and normalized-parameter meaning.
pub fn segment(
left: svg_path.Segment,
right: svg_path.Segment,
) -> Result(List(SegmentOverlap), svg_path.Error)
Find overlap intervals using the shared five-sample policy.
Coincident portions whose parameter correspondence is not affine return
svg_path.NonAffineOverlapCorrespondence. Normalize or linearize
degenerate and multiply traced segments before retrying those cases.
pub fn segment_overlap_left_parameter(
overlap: SegmentOverlap,
right_parameter: Float,
) -> Float
Map a right-segment parameter through an overlap’s inverse affine correspondence.
For overlap values returned by this module, parameters between
right_from and right_to map to coincident points on the left segment.
pub fn segment_overlap_right_parameter(
overlap: SegmentOverlap,
left_parameter: Float,
) -> Float
Map a left-segment parameter through an overlap’s affine correspondence.
For overlap values returned by this module, parameters in the closed
left_from..left_to interval map to coincident points on the right segment.
pub fn segment_subpath(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
) -> Result(List(SegmentSubpathOverlap), svg_path.Error)
Return overlaps between a standalone segment and a subpath.
pub fn segment_subpath_overlap_segment_end(
overlap: SegmentSubpathOverlap,
) -> option.Option(Float)
Last parameter of a segment-subpath overlap on the standalone segment.
pub fn segment_subpath_overlap_segment_parameter(
overlap: SegmentSubpathOverlap,
subpath_parameter: svg_path.SubpathParameter,
segment: svg_path.Segment,
subpath: svg_path.Subpath,
) -> Result(option.Option(Float), svg_path.Error)
Map a subpath address to its exact opposite standalone-segment parameter.
pub fn segment_subpath_overlap_segment_start(
overlap: SegmentSubpathOverlap,
) -> option.Option(Float)
First parameter of a segment-subpath overlap on the standalone segment.
pub fn segment_subpath_overlap_subpath_end(
overlap: SegmentSubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
Last parameter of a segment-subpath overlap on the subpath traversal.
pub fn segment_subpath_overlap_subpath_parameter(
overlap: SegmentSubpathOverlap,
segment_parameter: Float,
segment: svg_path.Segment,
subpath: svg_path.Subpath,
) -> Result(
option.Option(svg_path.SubpathParameter),
svg_path.Error,
)
Map a standalone-segment parameter to its exact opposite subpath address.
pub fn segment_subpath_overlap_subpath_start(
overlap: SegmentSubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
First parameter of a segment-subpath overlap on the subpath traversal.
pub fn segment_subpath_with(
segment: svg_path.Segment,
subpath: svg_path.Subpath,
tolerance tolerance: Float,
) -> Result(List(SegmentSubpathOverlap), svg_path.Error)
Return segment-subpath overlaps using an explicit geometric tolerance.
Overlaps follow the standalone segment’s traversal. Adjacent constituent
segment overlaps are joined when their parameter correspondences connect.
tolerance has the module-wide geometric and normalized-parameter meaning.
pub fn segment_with(
left: svg_path.Segment,
right: svg_path.Segment,
tolerance tolerance: Float,
) -> Result(List(SegmentOverlap), svg_path.Error)
Find segment overlaps using an explicit non-negative tolerance.
The tolerance is measured in path-coordinate distance for coincidence tests and in normalized segment parameters while merging candidates.
pub fn subpath(
left: svg_path.Subpath,
right: svg_path.Subpath,
) -> Result(List(SubpathOverlap), svg_path.Error)
Return continuous overlaps between two subpath traversals.
Each result follows the left traversal and contains its complete piecewise-affine correspondence to the right traversal.
pub fn subpath_overlap_left_end(
overlap: SubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
Last parameter of a subpath overlap on the left traversal.
pub fn subpath_overlap_left_parameter(
overlap: SubpathOverlap,
right_parameter: svg_path.SubpathParameter,
left_subpath left_subpath: svg_path.Subpath,
right_subpath right_subpath: svg_path.Subpath,
) -> Result(
option.Option(svg_path.SubpathParameter),
svg_path.Error,
)
Map a right-subpath address through an overlap’s exact correspondence.
The right subpath is used to recognize exact equivalent input addresses. The returned address is exactly canonicalized against the left subpath. This function does not snap parameters or otherwise move them geometrically.
pub fn subpath_overlap_left_start(
overlap: SubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
First parameter of a subpath overlap on the left traversal.
pub fn subpath_overlap_right_end(
overlap: SubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
Last corresponding parameter on the right traversal.
pub fn subpath_overlap_right_parameter(
overlap: SubpathOverlap,
left_parameter: svg_path.SubpathParameter,
left_subpath left_subpath: svg_path.Subpath,
right_subpath right_subpath: svg_path.Subpath,
) -> Result(
option.Option(svg_path.SubpathParameter),
svg_path.Error,
)
Map a left-subpath address through an overlap’s exact correspondence.
The left subpath is used to recognize exact equivalent input addresses. The returned address is exactly canonicalized against the right subpath. This function does not snap parameters or otherwise move them geometrically.
pub fn subpath_overlap_right_start(
overlap: SubpathOverlap,
) -> option.Option(svg_path.SubpathParameter)
First corresponding parameter on the right traversal.
pub fn subpath_with(
left: svg_path.Subpath,
right: svg_path.Subpath,
tolerance tolerance: Float,
) -> Result(List(SubpathOverlap), svg_path.Error)
Return subpath overlaps using an explicit non-negative tolerance.
The tolerance has the module-wide geometric and normalized-parameter meaning. Continuous pieces may cross segment boundaries but never join across a discontinuity in either traversal.