Unify SHAPE_ARC clockwise calc.

We don't really need the extra angle calculations
This commit is contained in:
Seth Hillbrand 2024-05-30 14:19:57 -07:00
parent 1c9e96c89a
commit 429625e311
2 changed files with 14 additions and 12 deletions

View File

@ -150,8 +150,6 @@ public:
*/
int Intersect( const SHAPE_ARC& aArc, std::vector<VECTOR2I>* aIpsBuffer ) const;
bool IsClockwise() const;
void SetWidth( int aWidth )
{
m_width = aWidth;
@ -250,13 +248,23 @@ public:
void TransformToPolygon( SHAPE_POLY_SET& aBuffer, int aError,
ERROR_LOC aErrorLoc ) const override;
private:
bool ccw( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) const
/**
* @return true if the arc is counter-clockwise.
*/
bool IsCCW() const
{
return ( ecoord{ aC.y } - aA.y ) * ( ecoord{ aB.x } - aA.x ) >
( ecoord{ aB.y } - aA.y ) * ( ecoord{ aC.x } - aA.x );
VECTOR2I v1 = m_end - m_mid;
VECTOR2I v2 = m_start - m_mid;
return v1.Cross( v2 ) > 0;
}
bool IsClockwise() const
{
return !IsCCW();
}
private:
void update_values();
bool sliceContainsPoint( const VECTOR2I& p ) const;

View File

@ -396,12 +396,6 @@ const BOX2I SHAPE_ARC::BBox( int aClearance ) const
}
bool SHAPE_ARC::IsClockwise() const
{
return GetCentralAngle() < ANGLE_0;
}
VECTOR2I SHAPE_ARC::NearestPoint( const VECTOR2I& aP ) const
{
const static int s_epsilon = 8;