Fix accuracy of tuning path calculation when measuring arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8401
This commit is contained in:
parent
1201ab5cac
commit
f30ebbde33
|
@ -148,6 +148,11 @@ public:
|
|||
double GetStartAngle() const;
|
||||
double GetEndAngle() const;
|
||||
|
||||
/**
|
||||
* @return the length of the arc shape
|
||||
*/
|
||||
double GetLength() const;
|
||||
|
||||
/**
|
||||
* Constructs a SHAPE_LINE_CHAIN of segments from a given arc
|
||||
* @param aAccuracy maximum divergence from true arc given in internal units
|
||||
|
|
|
@ -386,6 +386,15 @@ VECTOR2I SHAPE_ARC::GetCenter() const
|
|||
}
|
||||
|
||||
|
||||
double SHAPE_ARC::GetLength() const
|
||||
{
|
||||
double radius = GetRadius();
|
||||
double includedAngle = std::abs( GetCentralAngle() );
|
||||
|
||||
return radius * M_PI * includedAngle / 180.0;
|
||||
}
|
||||
|
||||
|
||||
double SHAPE_ARC::GetCentralAngle() const
|
||||
{
|
||||
VECTOR2I center = GetCenter();
|
||||
|
|
|
@ -234,7 +234,17 @@ long long int SHAPE_LINE_CHAIN::Length() const
|
|||
long long int l = 0;
|
||||
|
||||
for( int i = 0; i < SegmentCount(); i++ )
|
||||
l += CSegment( i ).Length();
|
||||
{
|
||||
// Only include segments that aren't part of arc shapes
|
||||
if( m_shapes[i] == SHAPE_IS_PT || m_shapes[i + 1] == SHAPE_IS_PT ||
|
||||
( m_shapes[i] != m_shapes[i + 1] ) )
|
||||
{
|
||||
l += CSegment( i ).Length();
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < ArcCount(); i++ )
|
||||
l += CArcs()[i].GetLength();
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue