# [metapost] Pen stroking and tight curves

xiolyxioly xiolyxioly at yahoo.com
Mon Oct 22 03:31:03 CEST 2012

```It seems to me that the methods being proposed are all somewhat heuiristic. I don't think it's very difficult to do this "rigorously".

How about this ...

The curvature of a Bezier cubic curve R(t) is a continuous function. We are looking for "tight" regions where it's value is less than the pen radius (P). So, first we find the points where R(t) = P . This involves finding all the zeros t1, ..., tn of the real-valued function R(t) - P. Numerical methods will be required, but these are well-known, readily available, reliable, fast. I can't prove it, but my intuition says there won't be more than 4 of these points on any given cubic. Maybe. Then we divide the original curve at t1, ..., tn. Then we cycle through the resulting segments, keeping the ones where R>P, and discarding the ones with R<P. There will be nasty numerical problems if R(t) is roughly equal to P over the entire length of the original curve, but that's not very likely.

People in CAD/CAM do this sort of computation all the time. It's called "removing loops from offset curves" or something like that. The problem of moving an NC milling cutter around a tight corner is exactly the same as moving a pen. I'll find some references, if anyone is interested.

I have similar thoughts on the problem of detecting inflexions. Again, it's just a problem of finding the zeros of a real-valued function. I think there can be no more than 2 inflexions on a Bezier cubic. Again, CAD systems frequently do this computation, so code exists.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/metapost/attachments/20121021/5ddd5513/attachment.html>
```

More information about the metapost mailing list