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 {