kimath: fix regression in BuildInitialTrace()/CalcArcCenter causing incorrect arcs in routed traces
This commit is contained in:
parent
cfac770664
commit
42e53ee8e9
|
@ -144,7 +144,7 @@ const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace( const VECTOR2I& aP0, con
|
||||||
{
|
{
|
||||||
// Positive tangentLength, diagonal start: arc goes at the start
|
// Positive tangentLength, diagonal start: arc goes at the start
|
||||||
arcEndpoint = aP1 - mp0.Resize( tangentLength );
|
arcEndpoint = aP1 - mp0.Resize( tangentLength );
|
||||||
arc.ConstructFromStartEndAngle( aP0, arcEndpoint, ANGLE_45 * rotationSign );
|
arc.ConstructFromStartEndAngle( aP0, arcEndpoint, - ANGLE_45 * rotationSign );
|
||||||
|
|
||||||
if( arc.GetP0() == arc.GetP1() )
|
if( arc.GetP0() == arc.GetP1() )
|
||||||
pl.Append( aP0 );
|
pl.Append( aP0 );
|
||||||
|
@ -157,7 +157,7 @@ const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace( const VECTOR2I& aP0, con
|
||||||
{
|
{
|
||||||
// Negative tangentLength, diagonal start: arc goes at the end
|
// Negative tangentLength, diagonal start: arc goes at the end
|
||||||
arcEndpoint = aP0 + mp1.Resize( std::abs( tangentLength ) );
|
arcEndpoint = aP0 + mp1.Resize( std::abs( tangentLength ) );
|
||||||
arc.ConstructFromStartEndAngle( arcEndpoint, aP1, ANGLE_45 * rotationSign );
|
arc.ConstructFromStartEndAngle( arcEndpoint, aP1, - ANGLE_45 * rotationSign );
|
||||||
|
|
||||||
pl.Append( aP0 );
|
pl.Append( aP0 );
|
||||||
|
|
||||||
|
@ -191,7 +191,8 @@ const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace( const VECTOR2I& aP0, con
|
||||||
{
|
{
|
||||||
// Negative tangentLength: arc goes at the start
|
// Negative tangentLength: arc goes at the start
|
||||||
VECTOR2I arcCenter = aP0 + centerDir.Resize( arcRadius );
|
VECTOR2I arcCenter = aP0 + centerDir.Resize( arcRadius );
|
||||||
SHAPE_ARC ca( arcCenter, aP0, ANGLE_45 * rotationSign );
|
SHAPE_ARC ca( arcCenter, aP0, -ANGLE_45 * rotationSign );
|
||||||
|
|
||||||
|
|
||||||
// Constructing with a center can lead to imprecise endpoint. We need to guarantee
|
// Constructing with a center can lead to imprecise endpoint. We need to guarantee
|
||||||
// tangency of the endpoint.
|
// tangency of the endpoint.
|
||||||
|
@ -201,12 +202,12 @@ const SHAPE_LINE_CHAIN DIRECTION_45::BuildInitialTrace( const VECTOR2I& aP0, con
|
||||||
if( std::abs( endpoint.y - aP1.y ) < SHAPE_ARC::MIN_PRECISION_IU )
|
if( std::abs( endpoint.y - aP1.y ) < SHAPE_ARC::MIN_PRECISION_IU )
|
||||||
{
|
{
|
||||||
VECTOR2I fixedEnd( endpoint.x, aP1.y );
|
VECTOR2I fixedEnd( endpoint.x, aP1.y );
|
||||||
ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, ANGLE_45 * rotationSign );
|
ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, - ANGLE_45 * rotationSign );
|
||||||
}
|
}
|
||||||
else if( std::abs( endpoint.x - aP1.x ) < SHAPE_ARC::MIN_PRECISION_IU )
|
else if( std::abs( endpoint.x - aP1.x ) < SHAPE_ARC::MIN_PRECISION_IU )
|
||||||
{
|
{
|
||||||
VECTOR2I fixedEnd( aP1.x, endpoint.y );
|
VECTOR2I fixedEnd( aP1.x, endpoint.y );
|
||||||
ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, ANGLE_45 * rotationSign );
|
ca.ConstructFromStartEndAngle( ca.GetP0(), fixedEnd, - ANGLE_45 * rotationSign );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ca.GetP0() == ca.GetP1() )
|
if( ca.GetP0() == ca.GetP1() )
|
||||||
|
|
|
@ -314,17 +314,23 @@ const VECTOR2D CalcArcCenter( const VECTOR2D& aStart, const VECTOR2D& aEnd,
|
||||||
if( angle > ANGLE_180 )
|
if( angle > ANGLE_180 )
|
||||||
{
|
{
|
||||||
std::swap( start, end );
|
std::swap( start, end );
|
||||||
angle = ANGLE_360 - angle;
|
angle = ANGLE_180 - angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
double chord = ( start - end ).EuclideanNorm();
|
double chord = ( start - end ).EuclideanNorm();
|
||||||
double r = ( chord / 2.0 ) / ( angle / 2.0 ).Sin();
|
double r = ( chord / 2.0 ) / ( angle / 2.0 ).Sin();
|
||||||
|
double d_squared = r * r - chord* chord / 4.0;
|
||||||
|
double d = 0.0;
|
||||||
|
|
||||||
VECTOR2D vec = end - start;
|
if( d_squared > 0.0 )
|
||||||
vec = vec.Resize( r );
|
d = sqrt( d_squared );
|
||||||
RotatePoint( vec, -( ANGLE_180 - angle ) / 2 );
|
|
||||||
|
|
||||||
return VECTOR2D( start + vec );
|
VECTOR2D vec2 = (end - start).Resize( d );
|
||||||
|
VECTOR2D vc = (end - start).Resize( chord / 2 );
|
||||||
|
|
||||||
|
RotatePoint( vec2, ANGLE_90 );
|
||||||
|
|
||||||
|
return VECTOR2D( start + vc + vec2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue