svg_path/congruency

Directional semantic congruency checks for path geometry.

Congruency means that a translation, rotation, and uniform scale maps the source geometry to the target geometry within a tolerance. Reflection and shear are not allowed.

These checks compare ordered semantic structure, not rendered shape. Segment constructors must match, subpaths and paths must have matching ordered structure, and closed subpaths are not cycled to search for another starting segment.

Values

pub fn path(
  source source: svg_path.Path,
  target target: svg_path.Path,
  tolerance tolerance: Float,
) -> Result(transform.Matrix, Nil)

Find a translation, rotation, and uniform scale mapping one path to another path.

Path subpaths must match in order. Each subpath comparison ignores the subpath closed field. Closed subpaths are not cycled, no alternate starting segment is attempted, and subpaths are not reordered.

pub fn points(
  source source: List(vec2.Vec2(Float)),
  target target: List(vec2.Vec2(Float)),
  tolerance tolerance: Float,
) -> Result(transform.Matrix, Nil)

Find a translation, rotation, and uniform scale mapping one ordered point list to another.

Empty lists and lists with different lengths return Error(Nil). A one-point source list uses a translation. For two or more source points, the candidate transform is built from a triple-sweep source point pair and the target points at the corresponding positions, then every mapped source point is checked against the corresponding target point.

pub fn segment(
  source source: svg_path.Segment,
  target target: svg_path.Segment,
  tolerance tolerance: Float,
) -> Result(transform.Matrix, Nil)

Find a translation, rotation, and uniform scale mapping one segment to another segment of the same constructor.

This is a directional, tolerance-based check. Ok(transform) means the returned transform maps source to target within tolerance under this module’s semantic segment comparison. Error(Nil) means no such transform was found.

Segment congruency is intentionally not visual-shape congruency. A segment only matches a target segment built with the same constructor, even if two different constructors would render the same geometry.

pub fn subpath(
  source source: svg_path.Subpath,
  target target: svg_path.Subpath,
  tolerance tolerance: Float,
) -> Result(transform.Matrix, Nil)

Find a translation, rotation, and uniform scale mapping one subpath to another subpath.

The subpath closed field is ignored. Segment constructors must match in order. Closed subpaths are not cycled, and no alternate starting segment is attempted.

Search Document