interpolating the 2d line to make the new coordinates equi-distant
12 views (last 30 days)
I have a 2d line which is a x and y vector. I would like to interpolate that line such that the new x, y coordinates are uniformly distributed along the line. I mean I get a line which the x and y coordinate are equi-distance. As if we are moving along this curve with constant speed.
Is there any way to do this? I would appreciate if you could help me out in this.
Sven on 12 Feb 2013
Hi Payam, try this:
pathXY = [0 0; 1 1; 10 2; 12 3]
stepLengths = sqrt(sum(diff(pathXY,,1).^2,2))
stepLengths = [0; stepLengths] % add the starting point
cumulativeLen = cumsum(stepLengths)
finalStepLocs = linspace(0,cumulativeLen(end), 100)
finalPathXY = interp1(cumulativeLen, pathXY, finalStepLocs)
Is that what you were looking for?