Approximate a curve with a limited number of line segments and arcs of circles

后端 未结 3 502
清酒与你
清酒与你 2020-12-18 09:29

Is there any algorithm that would allow to approximate a path on the x-y plane (i.e. an ordered suite of points defined by x and y) with a limited number of line segments an

相关标签:
3条回答
  • 2020-12-18 09:56

    A typical constraint when approximating a given curve by some other curve is to bound the approximate curve to an epsilon-hose within the original curve (in terms if Minkowski sum with a disk of fixed radius epsilon).

    For G1- or C2-continuous approximation (which people from CNC/CAD like) with biarcs (and a straight-line segment could be seen as an arc with infinite radius) former colleagues of mine developed an algorithm that gives solutions like this [click to enlarge]:

    The above picture is taken from the project website: https://www.cosy.sbg.ac.at/~held/projects/apx/apx.html

    The algorithm is fast, that is, it runs in O(n log n) time and is based on the generalized Voronoi diagram. However, it does not give an approximation with the exact minimum number of elements. If you look for the theoretical optimum I would refer to a paper by Drysdale et al., Approximation of an Open Polygonal Curve with a Minimum Number of Circular Arcs and Biarcs, CGTA, 2008.

    0 讨论(0)
  • 2020-12-18 10:10

    the C1 requirement demands the you must have alternating straights and arcs. Also realize if you permit a sufficient number of segments you can trivially fit every pair of points with a straight and use a tiny arc to satisfy slope continuity.

    I'd suggest this algorithm,

    1 best fit with a set of (specified N) straight segments. (surely there are well developed algorithms for that.)

    2 consider the straight segments fixed and at each joint place an arc. Treating each joint individually i think you have a tractable problem to find the optimum arc center/radius to satisfy continuity and improve the fit.

    3 now that you are pretty close attempt to consider all arc centers and radii (segments being defined by tangency) as a global optimization problem. This of course blows up if N is large.

    0 讨论(0)
  • 2020-12-18 10:19

    so you got a point cloud ... for such Usually points close together are considered connected so:

    1. you need to add info about what points are close to which ones

      points close only to 2 neighbors signaling interior of curve/line. Only one neighbor means endpoint of curve/lines and more then 2 means intersection or too close almost or parallel lines/curves. No neighbors means either noise or just a dot.

    2. group path segments together

      This is called connected component analysis. So you need to form polylines from your neighbor info table.

    3. detect linear path chunks

      these have the same slope among neighboring segments so you can join them to single line.

    4. fit the rest with curves

    Here related QAs:

    • Finding holes in 2d point sets?
    • Algorithms: Ellipse matching
    • How approximation search works see the sublinks there are quite a bit of examples of fitting
    • Trace a shape into a polygon of max n sides

    [Edit1] simple line detection from #3 on your data

    I used 5.0 deg angle change as threshold for lines and also minimal size fo detected line as 50 samples (too lazy to compute length assuming constant point density). The result looks like this:

    dots are detected line endpoints, green lines are the detected lines and white "lines" are the curves so I do not see any problem with this approach for now.

    Now the problem is with the points left (curves) I think there should be also geometric approach for this as it is just circular arcs so something like this

    • Formula to draw arcs ending in straight lines, Y as a function of X, starting slope, ending slope, starting point and arc radius?

    And this might help too:

    • Circular approximation of polygon (or its part)
    0 讨论(0)
提交回复
热议问题