35 Line( QPointF p1, QPointF p2 )
37 , mIncreasing(
false )
49 mIncreasing = ( p2.y() > p1.y() );
54 mTangent = ( p2.y() - p1.y() ) / ( p2.x() - p1.x() );
55 mIncreasing = ( p2.x() > p1.x() );
64 double a = ( mVertical ? M_PI_2 : std::atan( mTangent ) );
72 QPointF diffForInterval(
double interval )
const
75 return ( mIncreasing ? QPointF( 0, interval ) : QPointF( 0, -interval ) );
77 double alpha = std::atan( mTangent );
78 double dx = std::cos( alpha ) * interval;
79 double dy = std::sin( alpha ) * interval;
80 return ( mIncreasing ? QPointF( dx, dy ) : QPointF( -dx, -dy ) );
83 double length()
const {
return mLength; }
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).