2

Given an ordered list of points, I want to draw a smooth curve that passes through all of them. Each part of the curve can either be horizontal, vertical, or an arc with given radius r (all arcs will have the same radius). The transitions should be smooth, i.e., the heading at the end of one part should be the same as the heading at the beginning of the next part. There can be any number of arcs or straight line segments between any two consecutive input points.

It's sort of like a train track that should run orthogonally or along sections with fixed curvature.

Is there a good algorithm to construct such a curve? (or, in cases where such a line is not possible, I would like to know that.)

I looked into Bezier curves, but that seems like overkill and I couldn't find a good way to enforce my constraints.

Mzzzzzz
  • 4,770
  • 7
  • 30
  • 47

1 Answers1

2

What you are asking for above implies to me that you seek tangent continuity of your curve across points (similar to a spline with tangent continuity at knots). The train track analogy at least conveys this requirement. Given the strict limitations of straight lines, and fixed radius circular arcs I am fairly certain that you will not be able to do this. Why not consider a spline interpolation of your points if you require such smoothness instead? To see why consider the following image:

possible data point configuration

Consider replacing the line segment between B and C with a circular arc. You can do it to make the join continuous, but to make it tangent continuous, you would need a great deal of good fortune as there is only one circle that is tangent continuous to the line segment AB that also touches point C. The chances of that circle having tangent at C matching the tangent of line CD is remote. It is possible that your data will line up like this but you cannot rely on it.

If I have misunderstood your question please let me know and I will adjust the answer.

mathematician1975
  • 21,161
  • 6
  • 59
  • 101
  • Thanks, I should have mentioned this: the points will not be dense relative to the given radius r, so in most cases this type of layout should be possible. – Mzzzzzz Jul 06 '12 at 14:50
  • 2
    Even so, you will struggle to get tangent continuity unless your points satisfy some very rigid criteria. You might fit a curve that looks like it is tangent continuous, but I doubt it will be. But only you can decide if that is good enough for your needs. Good luck! – mathematician1975 Jul 06 '12 at 14:52
  • Ahh, I think I see what I need to clarify: between each pair of points, you can have multiple straight segments or arcs. For example, in your image, you could start with a vertical line upward from A, an arc of 90 degrees towards B, then a horizontal line towards B. Then from B, you can start with a horizontal segment, then arc downward towards C, and so on. Sorry for the text description, but I don't think I can add an image in my comment. – Mzzzzzz Jul 12 '12 at 15:53
  • @marcopolo1010 I see what you mean now. You want to generate your own curve from straight line and arc such that the resulting construct interpolates your data. Well I would imagine it is possible, but a potential problem is that such a configuration is unlikely to be unique - i can already imagine many such curves possible just for the image above. Really I would go for a spline interpolant unless you really must have only arcs and lines. I certainly have never heard of an algorithm that does what you would like but good luck all the same! – mathematician1975 Jul 12 '12 at 16:01
  • My guess is the OP is running a CNC tool that can only do arcs and straight lines thus his requirement. – bradgonesurfing Feb 19 '13 at 06:12