Whereas compute_max_error_ratio() checks for itself that each data point is near some point on the curve, this function checks that each point on the curve is near some data point (or near some point on the polyline defined by the data points, or something like that: we allow for a "reasonable curviness" from such a polyline). "Reasonable curviness" means we draw a circle centred at the midpoint of a..b, of radius proportional to the length a  b, and require that each point on the segment of bezCurve between the parameters of a and b be within that circle. If any point P on the bezCurve segment is outside of that allowable region (circle), then we return some metric that increases with the distance from P to the circle. Given that this is a fairly arbitrary criterion for finding appropriate places for sharp corners, we test only one point on bezCurve, namely the point on bezCurve with parameter halfway between our estimated parameters for a and b. (Alternatives are taking the farthest of a few parameters between those of a and b, or even using a variant of NewtonRaphsonFindRoot() for finding the maximum rather than minimum distance.)
Definition at line 976 of file bezierutils.cpp. References bezier_pt(), and distance(). Referenced by compute_max_error_ratio(). { Point const P = bezier_pt(3, bezCurve, u); double const dist = distance((a+b)*.5, P); if (dist < tolerance) { return 0; } double const allowed = distance(a, b) + tolerance; return dist / allowed; /** \todo * effic: Hooks are very rare. We could start by comparing * distsq, only resorting to the more expensive L2 in cases of * uncertainty. */ }
