From 4eac8d7c6627de30541c5d9447296dec3a62f974 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 20 Jan 2022 20:54:22 +0000 Subject: [PATCH] Remove unit-less angles from geometry lib APIs. --- common/eda_shape.cpp | 6 +++--- gerbview/dcode.cpp | 11 ++++------- gerbview/dcode.h | 2 +- gerbview/rs274x.cpp | 2 +- libs/kimath/include/geometry/shape.h | 7 ++++--- libs/kimath/include/geometry/shape_arc.h | 4 ++-- libs/kimath/include/geometry/shape_circle.h | 9 ++++----- libs/kimath/include/geometry/shape_compound.h | 5 +++-- .../kimath/include/geometry/shape_line_chain.h | 6 +++--- libs/kimath/include/geometry/shape_null.h | 2 +- libs/kimath/include/geometry/shape_poly_set.h | 9 +++++---- libs/kimath/include/geometry/shape_rect.h | 11 +++++------ libs/kimath/include/geometry/shape_segment.h | 14 +++++--------- libs/kimath/include/geometry/shape_simple.h | 4 ++-- .../src/convert_basic_shapes_to_polygon.cpp | 10 +++++----- libs/kimath/src/geometry/shape_arc.cpp | 18 +++++------------- libs/kimath/src/geometry/shape_compound.cpp | 4 ++-- libs/kimath/src/geometry/shape_line_chain.cpp | 13 ++++--------- libs/kimath/src/geometry/shape_poly_set.cpp | 4 ++-- pcbnew/exporters/gerber_placefile_writer.cpp | 2 +- pcbnew/footprint.cpp | 2 +- pcbnew/fp_text.cpp | 2 +- pcbnew/pad.cpp | 6 +++--- pcbnew/pcb_dimension.cpp | 8 ++++---- pcbnew/plugins/altium/altium_pcb.cpp | 4 ++-- pcbnew/plugins/fabmaster/import_fabmaster.cpp | 4 ++-- pcbnew/teardrop/teardrop_utils.cpp | 5 ++--- pcbnew/zone.cpp | 4 ++-- pcbnew/zone_filler.cpp | 6 +++--- 29 files changed, 82 insertions(+), 102 deletions(-) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 4cda3ab5b5..3883d9fd4f 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -258,7 +258,7 @@ void EDA_SHAPE::rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) KI_FALLTHROUGH; case SHAPE_T::POLY: - m_poly.Rotate( -aAngle.AsRadians(), aRotCentre ); + m_poly.Rotate( aAngle, aRotCentre ); break; case SHAPE_T::BEZIER: @@ -880,7 +880,7 @@ bool EDA_SHAPE::hitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) VECTOR2I offset = getParentPosition(); SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); - poly.Rotate( -getParentOrientation().AsRadians() ); + poly.Rotate( getParentOrientation() ); poly.Move( offset ); int count = poly.GetPointCount(); @@ -1112,7 +1112,7 @@ std::vector EDA_SHAPE::MakeEffectiveShapes( bool aEdgeOnly ) const { SHAPE_LINE_CHAIN l = GetPolyShape().COutline( 0 ); - l.Rotate( -getParentOrientation().AsRadians() ); + l.Rotate( getParentOrientation() ); l.Move( getParentPosition() ); if( IsFilled() && !aEdgeOnly ) diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index e86904f599..c7bb3aa4c9 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -78,7 +78,7 @@ void D_CODE::Clear_D_CODE_Data() m_InUse = false; m_Defined = false; m_Macro = nullptr; - m_Rotation = 0.0; + m_Rotation = ANGLE_0; m_EdgesCount = 0; m_Polygon.RemoveAllContours(); } @@ -371,7 +371,7 @@ void D_CODE::ConvertShapeToPolygon() m_Polygon.Append( initialpos ); // close outline if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon. - m_Polygon.Rotate( -M_PI / 2 ); + m_Polygon.Rotate( ANGLE_90 ); addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos ); } @@ -399,11 +399,8 @@ void D_CODE::ConvertShapeToPolygon() addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos ); - if( m_Rotation ) // rotate polygonal shape: - { - double angle = m_Rotation * M_PI / 180; - m_Polygon.Rotate( angle, VECTOR2I( 0, 0 ) ); - } + if( !m_Rotation.IsZero() ) // rotate polygonal shape: + m_Polygon.Rotate( m_Rotation ); break; diff --git a/gerbview/dcode.h b/gerbview/dcode.h index 8947ac2ba4..4f8d21d96d 100644 --- a/gerbview/dcode.h +++ b/gerbview/dcode.h @@ -191,7 +191,7 @@ public: wxSize m_Drill; ///< dimension of the hole (if any) (drill file) APERTURE_DEF_HOLETYPE m_DrillShape; ///< shape of the hole (0 = no hole, round = 1, ///< rect = 2). - double m_Rotation; ///< shape rotation in degrees + EDA_ANGLE m_Rotation; ///< shape rotation int m_EdgesCount; ///< in aperture definition Polygon only: ///< number of edges for the polygon bool m_InUse; ///< false if the aperture (previously defined) diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index f04c7ba312..808416f45e 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -820,7 +820,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, if( *aText == 'X' ) { aText++; - dcode->m_Rotation = ReadDouble( aText ); + dcode->m_Rotation = EDA_ANGLE( ReadDouble( aText ), DEGREES_T ); } while( *aText == ' ' ) diff --git a/libs/kimath/include/geometry/shape.h b/libs/kimath/include/geometry/shape.h index 1768ec5587..508e938519 100644 --- a/libs/kimath/include/geometry/shape.h +++ b/libs/kimath/include/geometry/shape.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -220,9 +221,9 @@ public: /** * @param aCenter is the rotation center. - * @param aAngle rotation angle in radians. + * @param aAngle rotation angle. */ - virtual void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) = 0; + virtual void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) = 0; virtual void Move( const VECTOR2I& aVector ) = 0; diff --git a/libs/kimath/include/geometry/shape_arc.h b/libs/kimath/include/geometry/shape_arc.h index ec591a59a1..0d70fa22c3 100644 --- a/libs/kimath/include/geometry/shape_arc.h +++ b/libs/kimath/include/geometry/shape_arc.h @@ -170,9 +170,9 @@ public: * Rotate the arc by a given angle about a point. * * @param aCenter is the rotation center. - * @param aAngle rotation angle in radians. + * @param aAngle rotation angle. */ - void Rotate( double aAngle, const VECTOR2I& aCenter ) override; + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter ) override; void Mirror( bool aX = true, bool aY = false, const VECTOR2I& aVector = { 0, 0 } ); diff --git a/libs/kimath/include/geometry/shape_circle.h b/libs/kimath/include/geometry/shape_circle.h index 2467451616..3ea482b13d 100644 --- a/libs/kimath/include/geometry/shape_circle.h +++ b/libs/kimath/include/geometry/shape_circle.h @@ -3,7 +3,7 @@ * * Copyright (C) 2013 CERN * @author Tomasz Wlostowski - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -124,11 +125,9 @@ public: m_circle.Center += aVector; } - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { - m_circle.Center -= aCenter; - m_circle.Center = m_circle.Center.Rotate( aAngle ); - m_circle.Center += aCenter; + RotatePoint( m_circle.Center, aCenter, aAngle ); } bool IsSolid() const override diff --git a/libs/kimath/include/geometry/shape_compound.h b/libs/kimath/include/geometry/shape_compound.h index 9aab4ab8c3..337632403b 100644 --- a/libs/kimath/include/geometry/shape_compound.h +++ b/libs/kimath/include/geometry/shape_compound.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016-2020 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,6 +30,7 @@ #include #include #include +#include "eda_angle.h" class SHAPE_SIMPLE; @@ -107,7 +108,7 @@ public: return m_shapes.size(); } - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; bool IsSolid() const override; diff --git a/libs/kimath/include/geometry/shape_line_chain.h b/libs/kimath/include/geometry/shape_line_chain.h index 8f22f28bc8..35b3c8ee4b 100644 --- a/libs/kimath/include/geometry/shape_line_chain.h +++ b/libs/kimath/include/geometry/shape_line_chain.h @@ -3,7 +3,7 @@ * * Copyright (C) 2013 CERN * @author Tomasz Wlostowski - * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -748,9 +748,9 @@ public: * Rotate all vertices by a given angle. * * @param aCenter is the rotation center. - * @param aAngle is the rotation angle in radians. + * @param aAngle is the rotation angle. */ - void Rotate( double aAngle, const VECTOR2I& aCenter = VECTOR2I( 0, 0 ) ) override; + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; bool IsSolid() const override { diff --git a/libs/kimath/include/geometry/shape_null.h b/libs/kimath/include/geometry/shape_null.h index e9e39888cb..c520d505f3 100644 --- a/libs/kimath/include/geometry/shape_null.h +++ b/libs/kimath/include/geometry/shape_null.h @@ -67,7 +67,7 @@ public: { } - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { } diff --git a/libs/kimath/include/geometry/shape_poly_set.h b/libs/kimath/include/geometry/shape_poly_set.h index 4c9c7e40ec..aa2377eb4a 100644 --- a/libs/kimath/include/geometry/shape_poly_set.h +++ b/libs/kimath/include/geometry/shape_poly_set.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2019 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @author Alejandro García Montoro @@ -83,7 +83,8 @@ public: { } - virtual void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override {}; + virtual void Rotate( const EDA_ANGLE& aAngle, + const VECTOR2I& aCenter = { 0, 0 } ) override {}; virtual void Move( const VECTOR2I& aVector ) override {}; @@ -1063,9 +1064,9 @@ public: * Rotate all vertices by a given angle. * * @param aCenter is the rotation center. - * @param aAngle is the rotation angle in radians. + * @param aAngle is the rotation angle. */ - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override; /// @copydoc SHAPE::IsSolid() bool IsSolid() const override diff --git a/libs/kimath/include/geometry/shape_rect.h b/libs/kimath/include/geometry/shape_rect.h index d1198b92ec..66ad12db38 100644 --- a/libs/kimath/include/geometry/shape_rect.h +++ b/libs/kimath/include/geometry/shape_rect.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -32,6 +32,7 @@ #include #include #include +#include class SHAPE_RECT : public SHAPE { @@ -152,13 +153,11 @@ public: * the rectangle. If you might need to handle non-90° rotations then the SHAPE_RECT should * first be converted to a SHAPE_SIMPLE which can then be free-rotated. */ - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { - m_p0 -= aCenter; - m_p0 = m_p0.Rotate( aAngle ); - m_p0 += aCenter; + RotatePoint( m_p0, aCenter, aAngle ); - if( abs( sin( aAngle ) ) == 1 ) + if( abs( aAngle.Sin() ) == 1 ) std::swap( m_h, m_w ); } diff --git a/libs/kimath/include/geometry/shape_segment.h b/libs/kimath/include/geometry/shape_segment.h index ac3ddabdf3..4e5df58c79 100644 --- a/libs/kimath/include/geometry/shape_segment.h +++ b/libs/kimath/include/geometry/shape_segment.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -29,6 +30,7 @@ #include #include #include +#include #include @@ -143,16 +145,10 @@ public: return true; } - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { - m_seg.A -= aCenter; - m_seg.B -= aCenter; - - m_seg.A = m_seg.A.Rotate( aAngle ); - m_seg.B = m_seg.B.Rotate( aAngle ); - - m_seg.A += aCenter; - m_seg.B += aCenter; + RotatePoint( m_seg.A, aCenter, aAngle ); + RotatePoint( m_seg.B, aCenter, aAngle ); } void Move( const VECTOR2I& aVector ) override diff --git a/libs/kimath/include/geometry/shape_simple.h b/libs/kimath/include/geometry/shape_simple.h index 47f38533fe..18ac434473 100644 --- a/libs/kimath/include/geometry/shape_simple.h +++ b/libs/kimath/include/geometry/shape_simple.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -155,7 +155,7 @@ public: return m_points.Collide( aSeg, aClearance, aActual, aLocation ); } - void Rotate( double aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override + void Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter = { 0, 0 } ) override { m_points.Rotate( aAngle, aCenter ); } diff --git a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp index bc6229dc1b..447b9468b9 100644 --- a/libs/kimath/src/convert_basic_shapes_to_polygon.cpp +++ b/libs/kimath/src/convert_basic_shapes_to_polygon.cpp @@ -216,7 +216,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aSta // due to the shape of initial polygons // Rotate and move the polygon to its right location - polyshape.Rotate( delta_angle.AsRadians(), VECTOR2I( 0, 0 ) ); + polyshape.Rotate( -delta_angle ); polyshape.Move( startp ); aCornerBuffer.Append( polyshape); @@ -437,7 +437,7 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& CornerListToPolygon( outline, corners, aInflate, aError, aErrorLoc ); if( !aRotation.IsZero() ) - outline.Rotate( -aRotation.AsRadians(), VECTOR2I( 0, 0 ) ); + outline.Rotate( aRotation ); outline.Move( VECTOR2I( aPosition ) ); aCornerBuffer.Append( outline ); @@ -504,7 +504,7 @@ void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const CornerListToPolygon( outline, corners, aInflate, aError, aErrorLoc ); if( !aRotation.IsZero() ) - outline.Rotate( -aRotation.AsRadians(), VECTOR2I( 0, 0 ) ); + outline.Rotate( aRotation ); outline.Move( aPosition ); aCornerBuffer.Append( outline ); @@ -577,10 +577,10 @@ void TransformArcToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aStar EDA_ANGLE arc_angle_end = arc_angle_start + arc_angle; if( arc_angle_start != ANGLE_0 && arc_angle_start != ANGLE_180 ) - polyshape.Outline(0).Rotate( arc_angle_start.AsRadians(), aStart ); + polyshape.Outline(0).Rotate( -arc_angle_start, aStart ); if( arc_angle_end != ANGLE_0 && arc_angle_end != ANGLE_180 ) - polyshape.Outline(1).Rotate( arc_angle_end.AsRadians(), aEnd ); + polyshape.Outline(1).Rotate( -arc_angle_end, aEnd ); VECTOR2I center = arc.GetCenter(); int radius = arc.GetRadius(); diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index d678e92584..9851bf7ed2 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 CERN - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -522,19 +522,11 @@ void SHAPE_ARC::Move( const VECTOR2I& aVector ) } -void SHAPE_ARC::Rotate( double aAngle, const VECTOR2I& aCenter ) +void SHAPE_ARC::Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter ) { - m_start -= aCenter; - m_end -= aCenter; - m_mid -= aCenter; - - m_start = m_start.Rotate( aAngle ); - m_end = m_end.Rotate( aAngle ); - m_mid = m_mid.Rotate( aAngle ); - - m_start += aCenter; - m_end += aCenter; - m_mid += aCenter; + RotatePoint( m_start, aCenter, aAngle ); + RotatePoint( m_end, aCenter, aAngle ); + RotatePoint( m_mid, aCenter, aAngle ); update_bbox(); } diff --git a/libs/kimath/src/geometry/shape_compound.cpp b/libs/kimath/src/geometry/shape_compound.cpp index 87e0128b47..9b7df5642b 100644 --- a/libs/kimath/src/geometry/shape_compound.cpp +++ b/libs/kimath/src/geometry/shape_compound.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers + * Copyright (C) 2020-2022 KiCad Developers * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -102,7 +102,7 @@ int SHAPE_COMPOUND::Distance( const SEG& aSeg ) const } -void SHAPE_COMPOUND::Rotate( double aAngle, const VECTOR2I& aCenter ) +void SHAPE_COMPOUND::Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter ) { assert( false ); } diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index 9cb6b56017..dfc93efcb6 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -2,10 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2017 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. - * + * Copyright (C) 2013-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski - * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,6 +35,7 @@ #include // for BOX2I #include // for rescale #include // for VECTOR2, VECTOR2I +#include // for RotatePoint class SHAPE; @@ -419,14 +418,10 @@ bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance, int* aActual } -void SHAPE_LINE_CHAIN::Rotate( double aAngle, const VECTOR2I& aCenter ) +void SHAPE_LINE_CHAIN::Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter ) { for( VECTOR2I& pt : m_points ) - { - pt -= aCenter; - pt = pt.Rotate( aAngle ); - pt += aCenter; - } + RotatePoint( pt, aCenter, aAngle ); for( SHAPE_ARC& arc : m_arcs ) arc.Rotate( aAngle, aCenter ); diff --git a/libs/kimath/src/geometry/shape_poly_set.cpp b/libs/kimath/src/geometry/shape_poly_set.cpp index e2c6877839..91b836cb20 100644 --- a/libs/kimath/src/geometry/shape_poly_set.cpp +++ b/libs/kimath/src/geometry/shape_poly_set.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2019 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * @author Alejandro García Montoro * @@ -1838,7 +1838,7 @@ void SHAPE_POLY_SET::Mirror( bool aX, bool aY, const VECTOR2I& aRef ) } -void SHAPE_POLY_SET::Rotate( double aAngle, const VECTOR2I& aCenter ) +void SHAPE_POLY_SET::Rotate( const EDA_ANGLE& aAngle, const VECTOR2I& aCenter ) { for( POLYGON& poly : m_polys ) { diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp index 863437d912..321381902b 100644 --- a/pcbnew/exporters/gerber_placefile_writer.cpp +++ b/pcbnew/exporters/gerber_placefile_writer.cpp @@ -218,7 +218,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER poly.Append( bbox.GetRight(), y_sign*bbox.GetTop() ); poly.SetClosed( true ); - poly.Rotate( -footprint->GetOrientation().AsRadians(), VECTOR2I( 0, 0 ) ); + poly.Rotate( footprint->GetOrientation() ); poly.Move( footprint->GetPosition() ); plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata ); } diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 92c0ca33ba..7d9043991f 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1737,7 +1737,7 @@ void FOOTPRINT::SetOrientation( const EDA_ANGLE& aNewAngle ) m_visibleBBoxCacheTimeStamp = 0; m_textExcludedBBoxCacheTimeStamp = 0; - m_cachedHull.Rotate( - angleChange.AsRadians(), GetPosition() ); + m_cachedHull.Rotate( angleChange, GetPosition() ); } diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index b0f47736aa..e9185cebc4 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -488,7 +488,7 @@ void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffe const FOOTPRINT* parentFootprint = static_cast( m_parent ); if( parentFootprint ) - buffer.Rotate( GetDrawRotation().AsRadians(), GetTextPos() ); + buffer.Rotate( -GetDrawRotation(), GetTextPos() ); aCornerBuffer.Append( buffer ); } diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 75bdd7f80d..60e57aa72d 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -417,7 +417,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const corners.Append( half_size.x - trap_delta.y, -half_size.y + trap_delta.x ); corners.Append( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x ); - corners.Rotate( - m_orient.AsRadians() ); + corners.Rotate( m_orient ); corners.Move( shapePos ); // GAL renders rectangles faster than 4-point polygons so it's worth checking if our @@ -482,7 +482,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const { for( SHAPE* shape : primitive->MakeEffectiveShapes() ) { - shape->Rotate( - m_orient.AsRadians() ); + shape->Rotate( m_orient ); shape->Move( shapePos ); add( shape ); } @@ -1563,7 +1563,7 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, { SHAPE_POLY_SET outline; MergePrimitivesAsPolygon( &outline, aErrorLoc ); - outline.Rotate( - m_orient.AsRadians() ); + outline.Rotate( m_orient ); outline.Move( VECTOR2I( m_pos ) ); if( aClearanceValue ) diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 7e255d14b6..bc6ecd19ca 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -612,7 +612,7 @@ void PCB_DIM_ALIGNED::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); + polyBox.Rotate( m_text.GetTextAngle(), textBox.GetCenter() ); // The ideal crossbar, if the text doesn't collide SEG crossbar( m_crossBarStart, m_crossBarEnd ); @@ -794,7 +794,7 @@ void PCB_DIM_ORTHOGONAL::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); + polyBox.Rotate( m_text.GetTextAngle(), textBox.GetCenter() ); // The ideal crossbar, if the text doesn't collide SEG crossbar( m_crossBarStart, m_crossBarEnd ); @@ -978,7 +978,7 @@ void PCB_DIM_LEADER::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); + polyBox.Rotate( m_text.GetTextAngle(), textBox.GetCenter() ); VECTOR2I firstLine( m_end - m_start ); VECTOR2I start( m_start ); @@ -1170,7 +1170,7 @@ void PCB_DIM_RADIAL::updateGeometry() polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y ); polyBox.Append( textBox.GetEnd() ); polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y ); - polyBox.Rotate( -m_text.GetTextAngle().AsRadians(), textBox.GetCenter() ); + polyBox.Rotate( m_text.GetTextAngle(), textBox.GetCenter() ); VECTOR2I radial( m_end - m_start ); radial = radial.Resize( m_leaderLength ); diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 8d7f42c805..14fb825334 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -127,7 +127,7 @@ void ALTIUM_PCB::HelperShapeSetLocalCoord( PCB_SHAPE* aShape, uint16_t aComponen FOOTPRINT* fp = m_components.at( aComponent ); polyShape.Move( -fp->GetPosition() ); - polyShape.Rotate( -fp->GetOrientation().AsRadians() ); + polyShape.Rotate( fp->GetOrientation() ); } } } @@ -147,7 +147,7 @@ void ALTIUM_PCB::HelperShapeSetLocalCoord( FP_SHAPE* aShape ) if( fp ) { polyShape.Move( -fp->GetPosition() ); - polyShape.Rotate( -fp->GetOrientation().AsRadians() ); + polyShape.Rotate( fp->GetOrientation() ); } } } diff --git a/pcbnew/plugins/fabmaster/import_fabmaster.cpp b/pcbnew/plugins/fabmaster/import_fabmaster.cpp index 39e206e5a8..6df75f3184 100644 --- a/pcbnew/plugins/fabmaster/import_fabmaster.cpp +++ b/pcbnew/plugins/fabmaster/import_fabmaster.cpp @@ -2344,11 +2344,11 @@ bool FABMASTER::loadFootprints( BOARD* aBoard ) if( src->mirror ) { poly_outline.Mirror( false, true, VECTOR2I( 0, ( pin->pin_y - src->y ) ) ); - poly_outline.Rotate( ( -src->rotate + pin->rotation ) * M_PI / 180.0 ); + poly_outline.Rotate( EDA_ANGLE( src->rotate - pin->rotation, DEGREES_T ) ); } else { - poly_outline.Rotate( ( src->rotate - pin->rotation ) * M_PI / 180.0 ); + poly_outline.Rotate( EDA_ANGLE( -src->rotate + pin->rotation, DEGREES_T ) ); } newpad->AddPrimitivePoly( poly_outline, 0, true ); diff --git a/pcbnew/teardrop/teardrop_utils.cpp b/pcbnew/teardrop/teardrop_utils.cpp index b7e2eefef5..46e002ab5a 100644 --- a/pcbnew/teardrop/teardrop_utils.cpp +++ b/pcbnew/teardrop/teardrop_utils.cpp @@ -450,8 +450,7 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( TEARDROP_PARAMETERS* aCurrParams, VECTOR2I ref_on_track = ( aPts[0] + aPts[1] ) / 2; VECTOR2I teardrop_axis( aPts[3] - ref_on_track ); - double orient = teardrop_axis.Angle(); - teardrop_axis.Rotate( -orient ); + EDA_ANGLE orient( teardrop_axis ); int len = teardrop_axis.EuclideanNorm(); // Build the constraint polygon: a rectangle with @@ -466,7 +465,7 @@ bool TEARDROP_MANAGER::ComputePointsOnPadVia( TEARDROP_PARAMETERS* aCurrParams, clipping_rect.Append( len, halfsize ); clipping_rect.Append( len, - halfsize ); - clipping_rect.Rotate( orient ); + clipping_rect.Rotate( -orient ); clipping_rect.Move( ref_on_track ); // Clip the shape to the max allowed teadrop area diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 259b965010..dabf7bbc3e 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -685,12 +685,12 @@ void ZONE::MoveEdge( const VECTOR2I& offset, int aEdge ) void ZONE::Rotate( const VECTOR2I& aCentre, const EDA_ANGLE& aAngle ) { - m_Poly->Rotate( -aAngle.AsRadians(), VECTOR2I( aCentre ) ); + m_Poly->Rotate( aAngle, VECTOR2I( aCentre ) ); HatchBorder(); /* rotate filled areas: */ for( std::pair& pair : m_FilledPolysList ) - pair.second.Rotate( -aAngle.AsRadians(), aCentre ); + pair.second.Rotate( aAngle, aCentre ); for( std::pair >& pair : m_FillSegmList ) { diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index b6ccfd23d7..141c406379 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -1404,7 +1404,7 @@ void ZONE_FILLER::buildThermalSpokes( const ZONE* aZone, PCB_LAYER_ID aLayer, } // Rotate and move the spokes tho the right position - spoke.Rotate( - ( pad->GetOrientation() + spokesAngle ).AsRadians() ); + spoke.Rotate( pad->GetOrientation() + spokesAngle ); spoke.Move( shapePos ); spoke.SetClosed( true ); @@ -1436,7 +1436,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer // Use a area that contains the rotated bbox by orientation, and after rotate the result // by -orientation. if( !aZone->GetHatchOrientation().IsZero() ) - filledPolys.Rotate( aZone->GetHatchOrientation().AsRadians(), VECTOR2I( 0, 0 ) ); + filledPolys.Rotate( - aZone->GetHatchOrientation() ); BOX2I bbox = filledPolys.BBox( 0 ); @@ -1542,7 +1542,7 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer holes.Move( bbox.GetPosition() ); if( !aZone->GetHatchOrientation().IsZero() ) - holes.Rotate( -aZone->GetHatchOrientation().AsRadians(), VECTOR2I( 0, 0 ) ); + holes.Rotate( aZone->GetHatchOrientation() ); DUMP_POLYS_TO_COPPER_LAYER( holes, In10_Cu, "hatch-holes" );