geometry: added SHAPE_SEGMENT::Is45Degree() method

This commit is contained in:
Tomasz Wlostowski 2023-01-08 23:32:46 +01:00
parent b222e4fd07
commit 4d208bac49
2 changed files with 17 additions and 0 deletions

View File

@ -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:

View File

@ -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;
}