Re-remove KiROUND from header

Moves routines requiring KiROUND (and util.h by extension) to the cpp
file
This commit is contained in:
Seth Hillbrand 2021-06-02 17:12:33 -07:00
parent 5306ba4d55
commit 059f79dfdb
2 changed files with 28 additions and 20 deletions

View File

@ -237,10 +237,7 @@ public:
* @param aSeg other segment
* @return minimum distance
*/
int Distance( const SEG& aSeg ) const
{
return KiROUND( sqrt( SquaredDistance( aSeg ) ) );
}
int Distance( const SEG& aSeg ) const;
ecoord SquaredDistance( const VECTOR2I& aP ) const
{
@ -253,10 +250,7 @@ public:
* @param aP the point
* @return minimum distance
*/
int Distance( const VECTOR2I& aP ) const
{
return KiROUND( sqrt( SquaredDistance( aP ) ) );
}
int Distance( const VECTOR2I& aP ) const;
void CanonicalCoefs( ecoord& qA, ecoord& qB, ecoord& qC ) const
{
@ -405,17 +399,6 @@ private:
int m_index;
};
inline int SEG::LineDistance( const VECTOR2I& aP, bool aDetermineSide ) const
{
ecoord p = ecoord{ A.y } - B.y;
ecoord q = ecoord{ B.x } - A.x;
ecoord r = -p * A.x - q * A.y;
ecoord dist = KiROUND( ( p * aP.x + q * aP.y + r ) / sqrt( p * p + q * q ) );
return aDetermineSide ? dist : std::abs( dist );
}
inline SEG::ecoord SEG::TCoef( const VECTOR2I& aP ) const
{
VECTOR2I d = B - A;

View File

@ -279,4 +279,29 @@ VECTOR2I SEG::LineProject( const VECTOR2I& aP ) const
int yp = rescale( t, ecoord{ d.y }, l_squared );
return A + VECTOR2I( xp, yp );
}
}
int SEG::Distance( const SEG& aSeg ) const
{
return KiROUND( sqrt( SquaredDistance( aSeg ) ) );
}
int SEG::Distance( const VECTOR2I& aP ) const
{
return KiROUND( sqrt( SquaredDistance( aP ) ) );
}
int SEG::LineDistance( const VECTOR2I& aP, bool aDetermineSide ) const
{
ecoord p = ecoord{ A.y } - B.y;
ecoord q = ecoord{ B.x } - A.x;
ecoord r = -p * A.x - q * A.y;
ecoord dist = KiROUND( ( p * aP.x + q * aP.y + r ) / sqrt( p * p + q * q ) );
return aDetermineSide ? dist : std::abs( dist );
}