From 1d9ca181a25a78fe06cdd834c478a34b65c87908 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 12 Apr 2021 22:34:13 -0400 Subject: [PATCH] PNS: Use existing seg direction if both DP segs are parallel --- pcbnew/router/pns_diff_pair.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 9d11b391f2..a6f5d2df46 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -125,6 +125,19 @@ void DP_PRIMITIVE_PAIR::CursorOrientation( const VECTOR2I& aCursorPos, VECTOR2I& { aP = m_primP->Anchor( 1 ); aN = m_primN->Anchor( 1 ); + + // If both segments are parallel, use that as the direction. Otherwise, fall back on the + // direction perpendicular to the anchor points. + const SEG& segP = static_cast( m_primP )->Seg(); + const SEG& segN = static_cast( m_primN )->Seg(); + + if( ( segP.B != segP.A ) && ( segN.B != segN.A ) && segP.ApproxParallel( segN ) ) + { + aMidpoint = ( aP + aN ) / 2; + aDirection = segP.B - segP.A; + aDirection = aDirection.Resize( ( aP - aN ).EuclideanNorm() ); + return; + } } else {