python - Sort points in 2D space to make a spline -


i have sequence of points distributed in 2d space. represent shape not ordered. so, can plot them points give idea of shape, if plot line connecting them, miss shape because order of points not right order of connection.

i'm wondering, how can put them in right order such that, if connect them 1 one in sequence, spline showing shape represent? found , tried convex hull in matlab no results. shape complex, example star , convex hull shape simplified (many points not taken account). help!

edit image. i've randomly created 1 show possible case, parts coming shape, , points can have different distances.

i've tried convex hull function in matlab, that's get. every time contour have "sharp corner", miss , final shape not i'm looking for. also, matlab function has no parameter set change convex hull result (at least can't see in help).

hull = convhull(coords(:,1),coords(:,2)); plot(coords(hull,1),coords(hull,2),'.r');

enter image description here

you need somehow order points, can in sequence; in case of drawing example, points can ordered using minimal distance, next -not yet used- point, starting @ 1 end (you'll have provide end).

then can draw spline, maybe using chaikin's algorithm curves locally approximate bezier curve.

you need start working on this, , post question code, if having difficulties.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -