Creating least deviated poly-lines out of a given list of points

Hi Guys! I have this list of points. I want to make polylines from my list of points which are roughly following the path of another given polylines( e.g. as straight as possible); Does anyone here know I can do that?

Thanks! :slight_smile:

How can a polygon be “straight”?
Do you have any picture, or sample data to work on with?

For now I can imagine using your base polygon to sort points (with curve closest point component) and redraw the polyline passing through all of them…

Hi Riccardo! Thanks for replying :slight_smile: sorry I mistakenly wrote polygon instead of polyline!

sure, so here you can see the point list which is the vertices of my initial mesh.
What I am trying to do is to find a way to create polylines out of these points which are having the least deviation from a straight line!

For example in this picture, the yellow ones are the examples of least deviation ( which I want) and the blue one is a less straight one ( which I want to avoid)

I am using Ivy to generate the paths (polylines)on the mesh graph, so if maybe you know a way to get the straight polylines in ivy please let me know!

I think logically I need to somehow measure the angle between the possible lines which can be made from neighbor points in each step, and pick the line with the higher angle. and this should be done in a loop which eliminates the already used points. But I am not sure how to do it with grasshopper or ivy !

Shortestwalk could be a way. Search on food4rhino

Hi Laurent! Thanks for the reply. :slight_smile:
The problem is in this case shortest path is not necessarily the most straight path!

Are you sure? Seems counterintuitive.

1 Like

Hi niloofar,
the answer to your question is simple.
all you have to do is first partition the list of points as per their x coordinate value and then further sorting them as per their Y coordinate value…

see this least deviated (10.0 KB) attached file… Cheers.

1 Like

Sorry i missed the replies here.
Try this:

  • scale your point list in Y only , shrinking them
  • do delanuary connections
  • scale back to original size

Now you have a mesh with long triangles on Y axis.
This might be useful…