Clear Filters
Clear Filters

Remeshing points on curved line

18 views (last 30 days)
Rene on 20 Mar 2013
I have the arclength coordinates S1, S2, S3 ... SN of N = 551 points along a curved line.
I would like to now "squeeze" in 6,001 points (without increasing the total length) and determine the new arclength coordinates S1, S2, S3 ... SM (M = 6,001).
I don't want to consider the obvious solution of dividing up the total length evenly unless I have to. Rather, I ideally want to keep as many of the original points fixed as possible.
Thank you!
Rene on 20 Mar 2013
Thanks for your reply.
Each arclength coordinate is a single number. Basically, I have a catenary in 1-D and so Sn described the distance from the top to point n along the catenary.
The Sn's are not equally spaced. For each intermediate point, I think interpolation would be fine. Ideally, I add more points where the Sn's are already finely spaced and fewer where they are more coarse. So we preserve the density of points as in the original.
Here is what a set of the original points look like
Distance from Top [ft] 0.0000 0.5142 1.0284 1.5426 1.9602 2.4768 2.9910 3.5052 4.0194 4.5336 5.0478 5.4654
Wouter on 20 Mar 2013
In that case you could just use interp1 I guess.

Sign in to comment.

Accepted Answer

Matt Tearle
Matt Tearle on 20 Mar 2013
If I understand the problem correctly, you have an array of m monotonically increasing, but unequally spaced, values. You want an array of n (> m) values than include the original m data points, but fill in the gaps between them.
I don't see a particularly nice solution -- even interpolation is tricky because you still want to keep the unequally spaced points.
Here's one possibility: take the m data points as m of the n points in your result, and distribute the remaining n - m points equally between the m - 1 spaces between the m data points. Given that you want to maintain the same density, equal distribution would do that fairly well. In that case, you need about k = (n-m)/(m-1) points between each pair of data points. Of course, that probably won't be an integer, so one solution would be to round that value down, leaving you with between 0 and m-1 leftover points to distribute. Here's my solution, distributing them to the biggest spaces between the data points:
%%Make some data
m = 31; % number of data points
n = 82; % number of points to interpolate onto
x = sort(rand(m,1));
%%Figure out the number of points between each data point
% Start with even distribution, rounded down
numbetween = floor((n-m)/(m-1));
% Make a vector to use with linspace (add 2 to include the endpoints)
k = 2 + numbetween*ones(m-1,1);
% Distribute the leftovers to the largest spaces
dx = diff(x);
[~,idx] = sort(dx,'descend');
numleftover = n - m - (m-1)*numbetween;
% Add one to the largest NUMLEFTOVER spaces
k(idx(1:numleftover)) = k(idx(1:numleftover)) + 1;
%%Make interpolated data
y = zeros(n,1);
% Loop over the m-1 spaces between the data points
i1 = 1;
for j = 1:(m-1)
% Add k points between x(j) and x(j+1)
i2 = i1 + k(j) - 1;
% Remember that k had 2 added to it, to account for the endpoints when
% using linspace
y(i1:i2) = linspace(x(j),x(j+1),k(j));
i1 = i2;
% Note that y(i2) will be overwritten next time through the loop, but
% it will get the same value (x(j+1)) anyway
%%Visualize the results
(I'm using x for what you called S, and I just realized I have m and n reversed from what you had, sorry!)

More Answers (1)

Wouter on 20 Mar 2013
Edited: Wouter on 20 Mar 2013
If it is a straight line with evenly spaced points you could do this:
S % original S; % Nx2 matrix
from_value = S(1); % first point, assuming S is sorted
to_value = S(end); % last point
new_S = [linspace(from_value,to_value,length(S)+6001)]; % new S is 6001 points larger
However if the S is a curve, it is a bit more difficult; you would need to fit a polygon or a spline which decribes your current curve and then resample it using 6001 more points.
Rene on 20 Mar 2013
Thanks! So if it is a catenary I could just use the analytical equations for catenaries. Or if I have enough points, the spline should be a good representation of the analytical formula, right?
So how would what you wrote above change as far as new_S?
Wouter on 20 Mar 2013
Edited: Wouter on 20 Mar 2013
I would indeed prefer the use of an analytical formula. if you don't have it, turn to spline fitting.
ps: I changed the answer above for 1D case.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!