Grasshopper

algorithmic modeling for Rhino

Sorting Points from 2 Lists based on their vicinity

I am trying to sort Points from 2 Lists based on their vicinity. I came across an older solution from David, but it is not working in my case. I have tried everything I came across but can not figure it out. I was wondering if someone had a solution for this problem

Views: 2286

Attachments:

Replies to This Discussion

Hi Peter,

This is great. Don't have much time to play today - but I will get back to you. Thanx Oliver

Hey Peter... Found some time to play with this for a while after all. Fist of all thanx for the wealth of information and work you provide. It does take some time to get up to speed with all this... Good learning experience for me... I was playing with some curves and came across this closed curve that does not calculate correctly... any idea why? Oliver... I internalized only 1 curve so that no vodka drinking Ducati driving speed daemon has to worry...

Attachments:

Elementary my dear Watson:

this thingy has no C1 .Discontinuity ... meaning that the GetNextDiscontinuity.C1_locus_continuous outputs bananas (the start + end that are the same since the thing is closed).

But if we ask for C2_locus_continuous instead we get:

Time for the V1B update it seems (with a new var: Hocus Pocus Locus [3 pts "scan" options to choose: i.e. bananas, dinosaur ears, or sardines? you tell me]).

Moral: Ducati Uber Alles

I assumed that it might have to do with the discontinuity - try to write this with a few intus... see attached - but I could not figure out to get the right curve division... the dark lord comes to the resuce... I take a look at your code and get back to you. BTW the brep inclusion answer hits the spot... Thanx Oliver

Attachments:

V1B works as follows:

1. If the thing is Polyline then nodes are taken the classic way.

2. If the thing is Curve and C1 Discontinuity yields more than 1 pt it stops there (but depending on case a Divide curve option could provide better "resolution").

3. If C1 yields 1 point > a C2 "scan" is attempted.

Added a mixed grill test case where copies of your latest test curve coexist with polylines.

Attachments:

ok... great solution to extend the code to check for other curve division if Continuity.C1_locus_continuous does not apply...

As with all your solution... It takes me some time to catch up - being a mobile phone using, harley riding... so let me dig through this and have a light bulb moment...

private Point3d FindCentroid (List<Curve> cList){
List<Point3d> crvStartPts = new List<Point3d>();
for(int i = 0; i < cList.Count;i++){
Curve c = cList[i];
Curve segment = c.DuplicateSegments()[0];
crvStartPts.Add(segment.PointAtStart);
}
Point3d centroid = crvStartPts[0];
for(int i = 1; i < crvStartPts.Count; i++)centroid += crvStartPts[i];
return centroid /= crvStartPts.Count;
}

V1C is specifically written for keeping your mind occupied when attempting some decent thingy: say a double forward.

Prerequisite:

Test the newly added centroidPolicy thingy, then go for a proper session:

Set-up:

Arrive at the spot properly equipped (carbon this, carbon that, proper brand names etc etc) paying attention to the vehicle on duty (if girls are around): say a Hummer H1 or some equivalent. Trim the gear (at the centroidPoint of List<Point3d> girlLocations = GetLocations(Girls, true, true, false)), pray and start doing things.

The puzzle: 

Why the 2 methods return different centroid points?

Attachments:

Oh my Lord.. this is it. Wow Let me wrap my head around this... great centroid calculation - What a puzzle... You are the man - if human at all. Thanx Oliver

Curve Ball - I hope this is not getting to far - test for the brave... Oliver

Attachments:

Elementary my dear Watson:

Introducing the strategy user option (as I said: a humble Divide curve by count Plan B should be always available) that works as follows:

1. If you have money for just one bike > get a (proper) Ducati

2. If you have lot's > get many (proper) Ducatis

3. If you live in the streets > hit a bank > get many (hmm) Ducatis

4. If you ride a Harley > apply for a free lobotomy.

5. If you fancy a Toyota Prius > choose a paid lobotomy.

Rather clear,  I guess

Attachments:

Logic slightly changed, progress report capability added (spot the auto "switch" in strategy), 0.034 bugs removed and only 34.78 added (plus 2.078 divisions by zero).

Attachments:

BTW: After the double forward and if you are still alive (if not > try a triple forward) play with this attached ... related with your question in some other thread.

Load R file first.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service