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

后端 未结 3 513
清酒与你
清酒与你 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 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)

提交回复
热议问题