How to generate equispaced interpolating values

前端 未结 5 505
既然无缘
既然无缘 2020-12-25 08:01

I have a list of (x,y) values that are not uniformly spaced. Here is the archive used in this question.

I am able to interpolate between the values but what I get ar

5条回答
  •  有刺的猬
    2020-12-25 08:41

    It IS possible to generate equidistant points along the curve. But there must be more definition of what you want for a real answer. Sorry, but the code I've written for this task is in MATLAB, but I can describe the general ideas. There are three possibilities.

    First, are the points to be truly equidistant from the neighbors in terms of a simple Euclidean distance? To do so would involve finding the intersection at any point on the curve with a circle of a fixed radius. Then just step along the curve.

    Next, if you intend distance to mean distance along the curve itself, if the curve is a piecewise linear one, the problem is again easy to do. Just step along the curve, since distance on a line segment is easy to measure.

    Finally, if you intend for the curve to be a cubic spline, again this is not incredibly difficult, but is a bit more work. Here the trick is to:

    • Compute the piecewise linear arclength from point to point along the curve. Call it t.
    • Generate a pair of cubic splines, x(t), y(t).
    • Differentiate x and y as functions of t. Since these are cubic segments, this is easy. The derivative functions will be piecewise quadratic.
    • Use an ode solver to move along the curve, integrating the differential arclength function. In MATLAB, ODE45 worked nicely.

    Thus, one integrates

    sqrt((x')^2 + (y')^2)
    

    Again, in MATLAB, ODE45 can be set to identify those locations where the function crosses certain specified points.

    If your MATLAB skills are up to the task, you can look at the code in interparc for more explanation. It is reasonably well commented code.

提交回复
热议问题