Grasshopper

algorithmic modeling for Rhino

Extract specific list items, sort according to points

Hi, 

I am trying to extract specific distance values which = 0 from a list and then to extract the points which correspond to them from a separate list. 

As some background; I have two sets of planar surfaces, each made up of many circles. For ease these are set 1 (circles in the front plane) and set 2 (circles at the back plane). I also have a viewpoint set in front of these planes. 

I have drawn lines from the viewpoint to the centre of each circle in the back plane. The aim is to find the circles in the front plane that sit on these lines (ie, where the line from the viewpoint passes through the centre of a circle in set 1 and the centre of a circle in set 2 and the line is straight). 

To do this the Curve CP component is finding the closest point on every line for every single centre point of a circle in set 1. Where these distance are 0 these points must sit on the line and therefore the straight line passes through all three of the key points.

The main issue: As seen from the screenshot below, when sorted and listed the Curve CP output is returning some values which are 0. (In this instance the branches 0 and 3 highlighted in red). I want to be able to 'pull' every value from the list which equals 0. I then want to take the points that correspond to each of these indexes and pull them from their list accordingly. So far I haven't figured out a way to return these exact results. 

Any help would be greatly appreciated, definition attached. Apologies if it is slightly hard to follow. I will do my best to clarify if necessary. Thanks, Tom  

Views: 2815

Attachments:

Replies to This Discussion

This is one way of doing it but something weird was happening... I think your zero values are actually very slightly greater than zero and have been rounded to zero.

When I rounded the values to 2 decimal places I could compare them to zero and then dispatch them into 2 lists according to the True or False result from the comparisson with zero.

If you don't round them it doesn't work so watch out that rounding to 2 decimal places does not produce errors!

Attachments:

Hi Martin, 

Thanks for the reply, this is one way of isolating the numbers which I need. I think in this instance, given what I'm attempting to do next I may have to find another workaround, but this certainly shows a way to extract specific values - thank you! 

Hi Tom,

Sorry it took a little while to get to this. I think you are after 'member index'. It will retrieve the indices in the list where 0 occurs. try also flattening the input. And then using list item you can retrieve the points.

Hope it helps

Andrei

Andrei

Attachments:

Hi Andrei, 

That's okay, thanks for the reply. The member index certainly gives me a way of finding the points I need however there's still something fundamentally wrong with the definition when I test it. I have attached another definition which shows how I'm trying to test it:

The aim was to find the centre points of the circles of set 1 (front) which intersect the lines drawn between the viewer and the centre of the circles of set 2 (back). Ie, two circle centres which lie on a straight line from the viewer. The grouped list component is showing the points from set 1 which have a corresponding distance 0 from the member index. It follows that these should be on the line, which they aren't from the screenshot below. Additionally a quick check using a surface / curve intersection component shows that none of the highlighted lines (listed with the same member index) intersect with the front layer of circles. 

I'm not sure where to take this, potentially need a different approach? Maybe somehow using intersections to check if the centres of the circles of set 1 cross with the lines between viewer and centre of circles on set 2? This in theory should be another way to do it but not quite sure how to set up that check. 

Any help greatly appreciated! Thanks for everything so far. Tom 

Attachments:

Hi Andrei, 

A second attempt at another way has gotten it a step closer I think.... I have drawn lines from the viewpoint to the centres of each circle on set 2. Then found the intersection of these lines with each of the surfaces that make up set 1. This appears to be working as when I move the viewpoint closer the 'pattern' (visible through the intersect surface and curve component) visibly decreases in size. The same happens when set 2 is moved further away from set 1. I already know that this is the desired effect. (moving the parameters in dark blue groups illustrate this).

I now just need to find a way to measure it, still aiming to find the centres of the constructed moiré pattern. I'm still hoping that this is where the three key points line up (viewpoint, cnr of circles in set 1, cnr of circles in set 2). Therefore I'm hoping to find an equality between some of the points found by the intersect surface and curve component and the points which define the centre of the circles in set 1. If any of these points are equal then they must be the centres of the moiré pattern. 

Therefore in the screenshot below I simply want to see if any of the point in 'List A' are also in 'List B'. I have had a look for similar things on the forums but cannot seem to find a way to do it. If this doesn't work I at least now have a visual representation of how these are working. Screenshot below and definition attached. 

Thanks, Tom 

Attachments:

Hi Tom,

Can you try the above? it means that item #5 from list 01 is also found in list 2 at #7. If you are not after the exact same point, you can use a distance calculator, compare it to a tollerance and then dispatch the lists.

Andrei

Thanks Andrei, 

After turning on the display for the cnr's of circles in set 1 and the surface / curve intersect points it's quite clear to see that my hypothesis of the moiré pattern centres lying on the same straight line is incorrect. 

Therefore I don't ever think that I'm going to get the accuracy I need to define the relationships between the distances and size of the moiré pattern as any kind of tangible number that has meaning. 

I think I'll settle for a visual representation that displays what is happening here. Thanks for all the help though, wouldn't have been able to get to this stage without exploring other routes. 

Tom 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service