Interpolate arbitrary curve to regular (x,y) grid
3 views (last 30 days)
Show older comments
Hello,
I ran into a problem that I cannot seem to solve in an elegant way.
Say, I have a spiral-like curve which I want to map onto a regular grid (constant dx and dy values). The curve is described by a large amount of points which I want to reduce to a much smaller amount of (roughly equidistant) points.
Since many points share the same x- or y-values, however, I cannot use e.g. John D'Errico's interparc tool.
Currently, my approach is as follows:
- Calculate the length of each line segment
- Generate an equidistant line with the desired number of points and a total length equal to my spiral-like curve
- Use dsearchn with my original curve and the equidistant line as inputs to determine which indices of the original curve to keep
- Use dsearchn again with my (x,y) grid and the remaining curve from the previous step as inputs to find the grid points that are closest to the remaining curve
However, this approach has 2 problems:
- dsearchn does not take into account uniqueness of points: some of curve points map onto the same grid point. This is something I want to avoid.
- The shape of the original curve is only roughly preserved (fair enough), but some points are pretty much inbetween 2 grid points (nearly the same distance) and the other point would preserve the original shape much better.
I am aware that mapping a pretty smooth curve to a relatively coarse Cartesian grid may give problems, but especially the first problem is one I really want to solve and I'm pretty sure there must be a way.
Does anyone have an idea?
Thanks!
3 Comments
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!