Re: reconstruct curve from set of points




"Maarten van Reeuwijk" <maarten@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:285d7$44e5cba5$82a1bcd4$10647@xxxxxxxxxxxxxxxxxxx
Maarten van Reeuwijk wrote:

Say I have a set of points (xs, ys) which represent an inwards spiraling
curve:

s = linspace(0, 6*pi, 500)
y = exp(-0.1 * s) .* cos(s);
x = exp(-0.1 * s) .* sin(s);

[xs, ix] = sort(x);
ys = y(ix);
plot(xs, ys);

How can I sort (xs, ys), such that the distance between neighboring
points
is minimized? In other words, how to I reconstruct (s, x, y) from (xs,
ys)?

TIA, Maarten



Nobody has an idea?

xs./ys is equal to tan(s). Use ATAN2 to retrieve the angle s0 in the range
[-pi, pi] from the xs-ys pairings. Now divide xs by sin(s0) and ys by
cos(s0), take the log of the results, and divide by -0.1. These tell you
the value of s on the interval [0, 6*pi] that was used to compute each
element of xs and ys. From there it's easy to just recompute x and y. I
tried it and the norm of the difference between the computed and actual
vector of s values was on the order of 1e-12 or so.

--
Steve Lord
slord@xxxxxxxxxxxxx


.



Relevant Pages


Loading