geometry: added SHAPE_SEGMENT::Is45Degree() method
This commit is contained in:
parent
b222e4fd07
commit
4d208bac49
|
@ -157,6 +157,8 @@ public:
|
|||
m_seg.B += aVector;
|
||||
}
|
||||
|
||||
bool Is45Degree( EDA_ANGLE aTollerance = EDA_ANGLE( 1.0, DEGREES_T ) ) const;
|
||||
|
||||
virtual const std::string Format( bool aCplusPlus = true ) const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -87,3 +87,18 @@ const std::string SHAPE_CIRCLE::Format( bool aCplusPlus ) const
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
bool SHAPE_SEGMENT::Is45Degree( EDA_ANGLE aTollerance ) const
|
||||
{
|
||||
EDA_ANGLE mag = EDA_ANGLE( m_seg.A - m_seg.B ).Normalize180();
|
||||
|
||||
double f = fmod( mag.AsDegrees(), 45.0 );
|
||||
double d = aTollerance.AsDegrees();
|
||||
|
||||
if( f >= 45.0 - d || f <= d )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue