EuclideanAligner

Euclidean distance alignment for open ↔ closed shapes

For open shapes (like lines), we minimize total Euclidean distance rather than angular distance. This preserves intuitive left-right or start-end correspondence. Algorithm: 1. Apply shape rotations to both vertex lists 2. Identify which shape is open and which is closed 3. Try all possible rotations of the closed shape 4. For each rotation, calculate total Euclidean distance between all vertex pairs (using specified norm) 5. Select rotation that minimizes total distance 6. Return original vertices with selected offset applied 7. Ensure last vertex equals first vertex for closed shape (closure) Performance: O(n²) - tries n offsets, evaluates n vertex pairs each

Constructor

EuclideanAligner(
    norm: Union[str, AlignmentNorm, EuclideanDistanceFn] = <AlignmentNorm.L1: 'l1'>
)

Initialize Euclidean aligner with distance norm.

Parameters

norm
Distance metric for alignment - "l1" or AlignmentNorm.L1: Sum of Euclidean distances (default) - "l2" or AlignmentNorm.L2: Root mean square Euclidean distance - "linf" or AlignmentNorm.LINF: Maximum Euclidean distance - Callable: Custom distance function(verts1, verts2, offset) -> float

Methods

align

align(
    verts1: Points2D,
    verts2: Points2D,
    context: AlignmentContext,
    rotation_target: Optional[float] = None
) -> Tuple[Points2D, Points2D]