Clarify atan2 overloads

In the C++ standard, this function is only defined for floating point
types, and integers cannot be implicitly converted. Using explicit
conversions avoids a GCC specific extension to the standard library.
This commit is contained in:
Simon Richter 2016-01-17 10:59:24 -05:00 committed by Chris Pavlina
parent ef582c07f3
commit ff4febc7a8
7 changed files with 11 additions and 10 deletions

View File

@ -310,7 +310,7 @@ double ArcTangente( int dy, int dx )
}
// Of course dy and dx are treated as double
return RAD2DECIDEG( atan2( dy, dx ) );
return RAD2DECIDEG( atan2( (double) dy, (double) dx ) );
}

View File

@ -755,7 +755,7 @@ void GERBVIEW_FRAME::UpdateStatusBar()
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
// atan2 in the 0,0 case returns 0
theta = RAD2DEG( atan2( -dy, dx ) );
theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
ro = hypot( dx, dy );
wxString formatter;

View File

@ -298,7 +298,7 @@ typename VECTOR2<T>::extended_type VECTOR2<T>::SquaredEuclideanNorm() const
template <class T>
double VECTOR2<T>::Angle() const
{
return atan2( y, x );
return atan2( (double) y, (double) x );
}

View File

@ -252,7 +252,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
// Calculate dimension value
measure = KiROUND( hypot( deltax, deltay ) );
angle = atan2( deltay, deltax );
angle = atan2( (double)deltay, (double)deltax );
// Calculation of parameters X and Y dimensions of the arrows and lines.
hx = hy = ii;

View File

@ -166,7 +166,7 @@ public:
{
wxPoint delta( m_featureLineDO - m_featureLineGO );
return atan2( delta.y, delta.x );
return atan2( (double)delta.y, (double)delta.x );
}
/**

View File

@ -391,8 +391,8 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) );
// angle counter-clockwise from 3'o-clock
const double deg = RAD2DEG( atan2( m_Start.y - m_End.y,
m_End.x - m_Start.x ) );
const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
(double)( m_End.x - m_Start.x ) ) );
msg.Printf( wxT( "%.1f" ), deg );
aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) );
}
@ -564,7 +564,8 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
case S_ARC:
radius = hypot( (double)( GetEnd().x - GetStart().x ),
(double)( GetEnd().y - GetStart().y ) );
theta = std::atan2( GetEnd().y - GetStart().y , GetEnd().x - GetStart().x );
theta = std::atan2( (double)( GetEnd().y - GetStart().y ),
(double)( GetEnd().x - GetStart().x ) );
//Approximate the arc with two lines. This should be accurate enough for selection.
p1.x = radius * std::cos( theta + M_PI/4 ) + GetStart().x;

View File

@ -690,7 +690,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue,
if( delta.y ) // lower and upper segment is horizontal
{
// Calculate angle of left (or right) segment with vertical axis
angle = atan2( m_DeltaSize.y, m_Size.y );
angle = atan2( (double) m_DeltaSize.y, (double) m_Size.y );
// left and right sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the horizontal axis
@ -706,7 +706,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue,
else if( delta.x ) // left and right segment is vertical
{
// Calculate angle of lower (or upper) segment with horizontal axis
angle = atan2( m_DeltaSize.x, m_Size.x );
angle = atan2( (double) m_DeltaSize.x, (double) m_Size.x );
// lower and upper sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the vertical axis