12 VLine(float x1, float y1, float x2, float y2)
13 : mX1(x1), mY1(y1), mX2(x2), mY2(y2)
16 VLine(const VPointF &p1, const VPointF &p2)
17 : mX1(p1.x()), mY1(p1.y()), mX2(p2.x()), mY2(p2.y())
20 float length() const { return length(mX1, mY1, mX2, mY2);}
21 void splitAtLength(float length, VLine &left, VLine &right) const;
22 VPointF p1() const { return VPointF(mX1, mY1); }
23 VPointF p2() const { return VPointF(mX2, mY2); }
25 static float length(float x1, float y1, float x2, float y2);
34 // approximate sqrt(x*x + y*y) using alpha max plus beta min algorithm.
35 // With alpha = 1, beta = 3/8, giving results with the largest error less
36 // than 7% compared to the exact value.
37 inline float VLine::length(float x1, float y1, float x2, float y2)
45 return (x > y ? x + 0.375 * y : y + 0.375 * x);
48 inline void VLine::splitAtLength(float lengthAt, VLine &left, VLine &right) const
51 float dx = ((mX2 - mX1) / len) * lengthAt;
52 float dy = ((mY2 - mY1) / len) * lengthAt;
56 left.mX2 = left.mX1 + dx;
57 left.mY2 = left.mY1 + dy;