If I want to draw a cubic bezier curve, I need to sample points on it and draw the resulting poly lines. One could sample the curve using De Casteljau algorithm and incrementing $t$ from 0 to 1 with a given interval. However depending on the length of the curve or how far away the control points are from each other, one might want to choose bigger or smaller sampling interval. Is there a good metric to calculate a satisfactory sampling interval? Would the the length of the poly lines formed by the control points of the bezier curve be considered a good metric? Or the length of the curve itself?
IIRC, Watt and Watt's "Advanced Animation and Rendering Techniques" (Chapter 3) has an interesting discussion on this (which I think is summarising the work of Clark https://dl.acm.org/doi/10.1145/965103.807440 ... but only the first page seems to be there :-( )
UPDATE: There is some text from Watt and Watt describing Clark's method available here:
If that's not to your taste, you could try the following: Take the Cubic Bezier cage - shown in green - with the curve in purple:
If you do a do a mid-point subdivision of the curve, you can measure the (squared) distance (red) from the centre of the straight line (blue) joining the original end points to the mid point of your curve. If this exceeds a threshold (some number of pixels), recurse, else stop.
I seem to recall that the difference between the straight-line approx and the curve drops by a factor of 4 (or was it 8??) with each subdivision, so it converges quite rapidly.
The maths to subdivide the 4 control points of any Cubic Bezier into 2 smaller Beziers is quite simple .. but I'd need to go and look it up ...
Update 2: See here for splitting a Bezier in 'twain'
Though, thinking about it, I'd say you might need to go one more step to account for this type of starting case:
$\begingroup$ Thanks for the suggestion! Can I ask if this technique you explained is used or documented anywhere? $\endgroup$ Jul 19, 2022 at 3:31
$\begingroup$ Well, I think the description in Watt and Watt (archive.org/details/…) of Clark's work might have a more direct approach in terms of how to compute an estimate of how much displacement there is between a line segment and a (subdivided) curve. OOH I've found an link. Will update the text above $\endgroup$– Simon FJul 19, 2022 at 13:51
tor how would you do it? $\endgroup$