From f532057d0543327794a01d6aaf13edad45d54160 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 29 Apr 2016 11:37:33 +0200 Subject: [PATCH] Fix incompatibility between basic_gal (which used angles in degrees in rotation) and other gal layers (which used radians in rotation). Rotation angles are now in radians. Fix erroneous optimization in VECTOR2::Rotate (which was made for angles in degrees): Angles are in radians, and only 0 rd rotation is skipped ( case very frequent, especially in eeschema) --- common/common.cpp | 2 +- common/drawtxt.cpp | 3 ++- include/basic_gal.h | 2 +- include/math/vector2d.h | 15 +++++---------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index edb5282ce4..a7eeb06c26 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -180,7 +180,7 @@ wxString GetUnitsLabel( EDA_UNITS_T aUnit ) break; case DEGREES: - wxASSERT( false ); + label = _( "degrees" ); break; } diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index eee2339567..3fbe4909e3 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -168,7 +168,8 @@ void DrawGraphicText( EDA_RECT* aClipBox, basic_gal.m_DC = aDC; basic_gal.m_Color = aColor; basic_gal.SetClipBox( aClipBox ); - basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient ); + + basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 ); } void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC, diff --git a/include/basic_gal.h b/include/basic_gal.h index 02c5a5c434..2ca3e34c3b 100644 --- a/include/basic_gal.h +++ b/include/basic_gal.h @@ -135,7 +135,7 @@ public: */ virtual void Rotate( double aAngle ) { - m_transform.m_rotAngle = aAngle * M_PI/1800; + m_transform.m_rotAngle = aAngle; m_transform.m_rotCenter = m_transform.m_moveOffset; } diff --git a/include/math/vector2d.h b/include/math/vector2d.h index b9ca1d22ce..e919ba9f9b 100644 --- a/include/math/vector2d.h +++ b/include/math/vector2d.h @@ -355,22 +355,17 @@ VECTOR2& VECTOR2::operator-=( const T& aScalar ) } +/** + * Rotate a VECTOR2 by aAngle. + * @param aAngle = rotation angle in radians + */ template VECTOR2 VECTOR2::Rotate( double aAngle ) const { - // fast calculation of some rotations, very frequently found + // Avoid 0 radian rotation, case very frequently found if( aAngle == 0.0 ) return VECTOR2 ( T( x ), T( y ) ); - if( aAngle == 90.0 ) - return VECTOR2 ( T( -y ), T( x ) ); - - if( aAngle == -90.0 ) - return VECTOR2 ( T( y ), T( -x ) ); - - if( aAngle == 180.0 || aAngle == -180.0 ) - return VECTOR2 ( T( -x ), T( -y ) ); - double sa = sin( aAngle ); double ca = cos( aAngle );