Grasshopper

algorithmic modeling for Rhino

Hello all,

I am using the "sort points" component. From my understanding if there are multiple points with the same X value it will then move on to the Y. 

lets say my list looks like this before I run it through the "sort points" component 

(3,4,5)

(3,2,6)

(3,1,7)

(3,8,4)

after the  "sort points" component it should look like this. Correct? 

(3,1,7)

(3,2,6)

(3,4,5)

(3,8,4)

If what I have done above is correct could someone please help me with why my sorted points are not doing this.

Thank you for your help

Views: 2343

Attachments:

Replies to This Discussion

 From my understanding if there are multiple points with the same X value it will then move on to the Y. 

This is not the case.

Have a read of this: http://www.grasshopper3d.com/forum/topics/how-can-i-sort-in-two-dim...

Thank you for the quick reply. This makes sense.

Actually Sort Points works exactly like you described. If there are two points with the same X, then they are sorted by Y. If they also have the same Y, then they are sorted by Z. If they are completely coincident then the final order of the points in the sorted list is undefined.

--

David Rutten

david@mcneel.com

If this is then the case how come some of the points did not get sorted in the Y column?

The file you posted doesn't seem to load. Which object is supposed to get selected in the first Geometry Parameter? Can you please just post the points using a single point parameter and internalize them?

In the meantime, it might not work because the coordinate you see is rounded to 6 decimal places. Hence 3.6 for the x coordinate might be anything between 3.5999995 and 3.6000004. If there's even a tiny difference between x's, it will still affect the sorting even though the points seem to be coincident when looked at through a Panel.

--

David Rutten

david@mcneel.com

Sorry for the problem with the loading. I normally do not write my scripts this way. I am helping a friend.

The new Grasshopper file has all of the geometry internalized. The numbers are not exactly the same but the problem is still there. 

I do not think the rounding of the number is a problem in this situation because the points are being generated from a flat plane. This is good to know for in the future. 

I have found a way using sort list to work around this. But I still find if odd that the points are not sorting correctly. Most likely something on my end.

Thank you for taking a look at this.

Steven

Attachments:

I do not think the rounding of the number is a problem in this situation because the points are being generated from a flat plane. This is good to know for in the future.

Almost everything to do with floating point numbers is subject to a tiny amount of noise or inaccuracy in computing. It takes a while for these inaccuracies to get big enough to be seen at the 7th decimal place, but it can happen. In addition to intrinsic inaccuracies, there are also often tolerances involved. A tolerance is basically a value that allows Rhino to treat a near-miss as a hit (or two very close hits as a single one). Although this is a vital property of many algorithms, tolerances too introduce inaccuracies that tend to be several orders of magnitude larger than inaccuracies due to computation.

I used a formatting function with the 'R' option ('R' stands for 'Roundtrip', meaning it will format a number in such a way as to allow for a lossless round trip between number, text and back to number). As you can see some of the x's are indeed subtly different i the 15th and 16th decimal places.

--

David Rutten

david@mcneel.com

Thank you for thanking the time to answer this question I know you are busy. This is very good to know for in the future.

Thanks again

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service