SHAPE_ARC::GetCentralAngle(): ensure a 360 deg arc angle is always returned as 360 deg.

An arc having the same start and end points can be 0 or 360 deg arc.
In Kicad it is always 360 deg arc (i.e. a circle)
Fixes #13182
https://gitlab.com/kicad/code/kicad/issues/13182
This commit is contained in:
jean-pierre charras 2022-12-17 14:44:53 +01:00
parent ec1d81a012
commit 1047e7143a
1 changed files with 6 additions and 0 deletions

View File

@ -447,6 +447,12 @@ double SHAPE_ARC::GetLength() const
EDA_ANGLE SHAPE_ARC::GetCentralAngle() const
{
// Arcs with same start and end points can be 0 deg or 360 deg arcs.
// However, they are expected to be circles.
// So return 360 degrees as central arc:
if( m_start == m_end )
return ANGLE_360;
VECTOR2I center = GetCenter();
EDA_ANGLE angle1 = EDA_ANGLE( m_mid - center ) - EDA_ANGLE( m_start - center );
EDA_ANGLE angle2 = EDA_ANGLE( m_end - center ) - EDA_ANGLE( m_mid - center );