Grasshopper

algorithmic modeling for Rhino

Hi there,

Trying to sort curves.

So I have a group of straight lines that are arranged in a radial manner and I'd like to have them sorted so that one curve comes after its nearest curve to the right or left. So that say for example, if I  interpolated the end point of each curve, I'd get a nice and simple elipse that doesn't bend all over the place as it tries to connect points that are completely out of order (which is seen on the first image, the green line). Does that make sense? Ideally the curves would be listed in a nice clockwise or counter clockwise order as seen in the second image.

One thing I tried was to sort them based on the distance of their end points to their Closest Point on a slightly spiraling curve...but it's hard to control precisely.

Any ideas?

Thanks

Views: 7570

Replies to This Discussion

Hi Benjamin,

I had the same issue once. you can do it like this:

- draw a circle with the center in the center of you ellipse/rectangle passing through you lines (or near them doesn't matter)
- make sure, that start and end points of the circle are in the position where you want your first and last item in the sorted list of lines
-make sure that the defined direction of the circle is as you desire (direction of sorting)
-use closest point command between the lines and the circle.
now these intersection points have an assigned d-value on the circle
sort the lines due to the d-value (increasing or decreasing)

voila

cheers, Benjamin

Hey Benjamin,


Thanks for the reply.

I tried following your steps, but regarding the "closest point command", I don't believe I'm able to use it for various curves. In my version of grasshopper it seems I need to input two sets of points into the closest point command.

Am I perhaps not following you correctly?

Thanks again,

Benjamin

Hey, okay you already got it.
Stupid me, sorry my explanation was incomplete. you could use the start or end points of your lines to find the closest point of them on the circle (since the closest point on the circle always creates a line with the actual starting point that is perpendicular to the circles tangent in this point, the size of the circle doesn't even matter)
then sort the lines according to the d-value of these points.

but anyway..
see you

Benjamin

Figure out a simple solution that works quite well for this situation, silly of me not to have seen this earlier:
I used the angle component to calculate the angle between each line and the X vector (or Y) ON the XY plane (that was important, if you don't define the plane of the angles it doesn't quite work). And then just sorted curves by the angle values...pretty simple.

Hi,

here we go:

Let me know if it works.

cheers, Raul

Thanks guys!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service