float factorX, factorY;
getResizeFactors( factorX, factorY );
- return (m_rCurve.getMinDist( (int)(x / factorX),
- (int)(y / factorY) ) < m_thickness );
+ return (m_rCurve.getMinDist( (int)(x / factorX), (int)(y / factorY),
+ factorX, factorY ) < m_thickness );
}
}
-float Bezier::getMinDist( int x, int y ) const
+float Bezier::getMinDist( int x, int y, float xScale, float yScale ) const
{
int nearest = findNearestPoint( x, y );
- return sqrt( (double)((m_leftVect[nearest] - x) * (m_leftVect[nearest] - x) +
- (m_topVect[nearest] - y) * (m_topVect[nearest] - y)) );
+ double xDist = xScale * (m_leftVect[nearest] - x);
+ double yDist = yScale * (m_topVect[nearest] - y);
+ return sqrt( xDist * xDist + yDist * yDist );
}
/// from (x, y)
float getNearestPercent( int x, int y ) const;
- /// Return the distance of (x, y) to the curve
- float getMinDist( int x, int y ) const;
+ /// Return the distance of (x, y) to the curve, corrected
+ /// by the (optional) given scale factors
+ float getMinDist( int x, int y, float xScale = 1.0f,
+ float yScale = 1.0f ) const;
/// Get the coordinates of the point at t percent of
/// the curve (t must be between 0 and 1)