| 71 | } |
| 72 | |
| 73 | static float CaculateCubicLength(const BezierPoint* points, float distance, unsigned minT, |
| 74 | unsigned maxT, const float& precision) { |
| 75 | if (TSpanBigEnough(maxT - minT) && CubicTooCurvy(points, precision)) { |
| 76 | auto halfT = (minT + maxT) >> 1; |
| 77 | auto p1 = InterpolatePoint(points[0], points[1], 0.5); |
| 78 | auto bc = InterpolatePoint(points[1], points[2], 0.5); |
| 79 | auto p5 = InterpolatePoint(points[2], points[3], 0.5); |
| 80 | auto p2 = InterpolatePoint(p1, bc, 0.5); |
| 81 | auto p4 = InterpolatePoint(bc, p5, 0.5); |
| 82 | auto p3 = InterpolatePoint(p2, p4, 0.5); |
| 83 | BezierPoint result[7] = {points[0], p1, p2, p3, p4, p5, points[3]}; |
| 84 | distance = CaculateCubicLength(result, distance, minT, halfT, precision); |
| 85 | distance = CaculateCubicLength(&result[3], distance, halfT, maxT, precision); |
| 86 | } else { |
| 87 | distance += Distance(points[0], points[3]); |
| 88 | } |
| 89 | return distance; |
| 90 | } |
| 91 | |
| 92 | static bool PointOnLine(const float x1, const float y1, const float x2, const float y2, |
| 93 | const float x3, const float y3, const float& precision) { |
no test coverage detected