From 0218b782f40712b38409001607378bb7a49e6394 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 18 Jan 2022 02:20:36 +0000 Subject: [PATCH] Angle cleanup in Eagle importer. --- .../sch_plugins/eagle/sch_eagle_plugin.cpp | 4 +-- pcbnew/plugins/eagle/eagle_plugin.cpp | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index ae58da78dc..721cb797d6 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -1783,8 +1783,8 @@ LIB_SHAPE* SCH_EAGLE_PLUGIN::loadSymbolRectangle( std::unique_ptr& a VECTOR2I end( rectangle->GetEnd() ); VECTOR2I center( rectangle->GetCenter() ); - RotatePoint( pos, center, rect.rot->degrees * 10 ); - RotatePoint( end, center, rect.rot->degrees * 10 ); + RotatePoint( pos, center, EDA_ANGLE( rect.rot->degrees, DEGREES_T ) ); + RotatePoint( end, center, EDA_ANGLE( rect.rot->degrees, DEGREES_T ) ); rectangle->SetPosition( pos ); rectangle->SetEnd( end ); diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index 3d1ae04efc..e2b6be2d05 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -873,14 +873,16 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) setKeepoutSettingsToZone( zone, c.layer ); - // approximate circle as polygon with a edge every 10 degree - VECTOR2I center( kicad_x( c.x ), kicad_y( c.y ) ); - int outlineRadius = radius + ( width / 2 ); + // approximate circle as polygon + VECTOR2I center( kicad_x( c.x ), kicad_y( c.y ) ); + int outlineRadius = radius + ( width / 2 ); + int segsInCircle = GetArcToSegmentCount( outlineRadius, ARC_HIGH_DEF, FULL_CIRCLE ); + EDA_ANGLE delta = ANGLE_360 / segsInCircle; - for( int angle = 0; angle < 360; angle += 10 ) + for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta ) { VECTOR2I rotatedPoint( outlineRadius, 0 ); - RotatePoint( rotatedPoint, angle * 10. ); + RotatePoint( rotatedPoint, angle ); zone->AppendCorner( center + rotatedPoint, -1 ); } @@ -888,11 +890,13 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) { zone->NewHole(); int innerRadius = radius - ( width / 2 ); + segsInCircle = GetArcToSegmentCount( innerRadius, ARC_HIGH_DEF, FULL_CIRCLE ); + delta = ANGLE_360 / segsInCircle; - for( int angle = 0; angle < 360; angle += 10 ) + for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta ) { VECTOR2I rotatedPoint( innerRadius, 0 ); - RotatePoint( rotatedPoint, angle * 10. ); + RotatePoint( rotatedPoint, angle ); zone->AppendCorner( center + rotatedPoint, 0 ); } } @@ -2220,14 +2224,16 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons setKeepoutSettingsToZone( zone, e.layer ); - // approximate circle as polygon with a edge every 10 degree - VECTOR2I center( kicad_x( e.x ), kicad_y( e.y ) ); - int outlineRadius = radius + ( width / 2 ); + // approximate circle as polygon + VECTOR2I center( kicad_x( e.x ), kicad_y( e.y ) ); + int outlineRadius = radius + ( width / 2 ); + int segsInCircle = GetArcToSegmentCount( outlineRadius, ARC_HIGH_DEF, FULL_CIRCLE ); + EDA_ANGLE delta = ANGLE_360 / segsInCircle; - for( int angle = 0; angle < 360; angle += 10 ) + for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta ) { VECTOR2I rotatedPoint( outlineRadius, 0 ); - RotatePoint( rotatedPoint, angle * 10. ); + RotatePoint( rotatedPoint, angle ); zone->AppendCorner( center + rotatedPoint, -1 ); } @@ -2235,11 +2241,13 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons { zone->NewHole(); int innerRadius = radius - ( width / 2 ); + segsInCircle = GetArcToSegmentCount( innerRadius, ARC_HIGH_DEF, FULL_CIRCLE ); + delta = ANGLE_360 / segsInCircle; - for( int angle = 0; angle < 360; angle += 10 ) + for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta ) { VECTOR2I rotatedPoint( innerRadius, 0 ); - RotatePoint( rotatedPoint, angle * 10. ); + RotatePoint( rotatedPoint, angle ); zone->AppendCorner( center + rotatedPoint, 0 ); } }