KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ORTHO_ITEM_REALIGNER Class Reference

This is a relatively straight-forward implementation of the ITEM_REALIGNER_BASE that should handle most practical cases. More...

#include <item_realignment.h>

Inheritance diagram for ORTHO_ITEM_REALIGNER:
ITEM_REALIGNER_BASE

Public Member Functions

std::optional< TRANSFORMGetTransform (const std::vector< VECTOR2I > &aPtsA, const std::vector< VECTOR2I > &aPtsB) const override
 Compute the best fit transform to align the two sets of points.
 

Detailed Description

This is a relatively straight-forward implementation of the ITEM_REALIGNER_BASE that should handle most practical cases.

Basically, it computes a baseline between two matching points. This gives the approximate rotation, which is then snapped to a multiple of 90 degrees. After rotation, the translation is computed by a best fit between the two sets of points.

By constraining the baseline rotation to 90 degree increments, this avoids various ways the result gets numerically strange. For example if one baseline pad is adjusted by a small amount, even if the footprint isn't rotated, the baseline may shift by a small angle. This doesn't mean we should rotate the footprint.

Definition at line 79 of file item_realignment.h.

Member Function Documentation

◆ GetTransform()

std::optional< ITEM_REALIGNER_BASE::TRANSFORM > ORTHO_ITEM_REALIGNER::GetTransform ( const std::vector< VECTOR2I > & aPtsA,
const std::vector< VECTOR2I > & aPtsB ) const
overridevirtual

Compute the best fit transform to align the two sets of points.

The point lists have to be the same length.

Parameters
aPtsAThe "old" points
aPtsBThe "new" points
Returns
The transform to apply to the NEW points to best align them to the old points. Rotations are to be applied around the origin.

Implements ITEM_REALIGNER_BASE.

Definition at line 45 of file item_realignment.cpp.

References epsilon, VECTOR2< T >::EuclideanNorm(), RotatePoint(), and Snap90Degrees().

Referenced by ComputeFootprintShift().


The documentation for this class was generated from the following files: