You are here: Start » AVL.NET » Function Reference » Path » Path Spatial Transforms » AVL.FitPathToPath

AVL.FitPathToPath

Rotates and shifts a path to minimize average distance between its points and a reference path.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void FitPathToPath
(
	AvlNet.Path inPath,
	AvlNet.Path inReferencePath,
	AvlNet.PathOrientationAlignment inPathOrientationAlignment,
	int inIterations,
	float inFirstShift,
	float inFirstRotation,
	AvlNet.Path outPath,
	out AvlNet.CoordinateSystem2D outAlignment,
	out float outPathDistance
)

Parameters

Name Type Range Default Description
inPathAvlNet.PathPath to be aligned.
inReferencePathAvlNet.PathPath to align to.
inPathOrientationAlignmentAvlNet.PathOrientationAlignmentEllipticAxesDetermines how to align paths orientation before the main algorithm. Default value: EllipticAxes.
inIterationsint<1, INF>5Number of algorithm steps. Default value: 5.
inFirstShiftfloat10.0fMagnitude of possible shift at the first step in pixels. Default value: 10.0f.
inFirstRotationfloat10.0fMagnitude of possible rotation at the first step in degrees. Default value: 10.0f.
outPathAvlNet.PathAligned path.
outAlignmentAvlNet.CoordinateSystem2DThe coordinate system that geometrical objects defined in the context of the path should be aligned to.
outPathDistancefloatAverage distance of characteristic points of the input path from the reference path.

Description

The operations repeatedly performs shifts and rotations on the inPath minimizing the average distance between its characteristic points and inReferencePath.

Initially the inPath is shifted so that its mass center is equals the mass center of inReferencePath. Then the alignment is performed in inIterations steps. At each step the algorithm considers:

  1. Shifts of the processed path in four major directions by ShiftMagnitude pixels
  2. Rotations of the processed path in clockwise and counter-clockwise direction by RotationMagnitude degrees

At each substep the operation performs shift or rotation that produces the best distance minimization results. The initial value of ShiftMagnitude is inFirstShift and at each step it is divided by 2. Analogically the initial value of RotationMagnitude is inFirstRotation and at each step it is divided by 2.

Examples

FitPathToPath run on the sample paths with inIterations = 5, inFirstShift = 10, inFirstRotation = 10. The inReferencePath plotted in grey, the inPath/outPath in black.

Errors

List of possible exceptions:

Error type Description
DomainError Empty path on input in FitPathToPath.

See also