Coffee + Grasshopper

A daily geometric problem is presented to the grasshopper 3d community. Degrees of difficulty vary by day.

The idea is to sharpen skills, challenge, or a fun exercise: Useful for beginners wanting to learn, or as an alternative to your morning coffee + cross-word puzzle. 

Rules:

Contributions can be posted by anyone. Either selected from a previously posted problem from the general discussion (please acknowledge original poster), a selection from one of the many grasshopper+ primers (please include credits) something you think is fun, curious about, or even something you want to learn.

We should keep the entries dated so we can track them. One new problem per day (so if you see one posted for today- there is always tomorrow).

User(you) adds post titled: date-name of problem.

 

Solutions will be posted with breakdowns, either in logic procedure, etc. And in the spirit of the NY Times, an explained solution will be posted as well within the following days.

Remember there are multiple ways to solve a problem- however the “official” post should include a “clean and elegant” (or simplest) solution. So that all learning can develop better scripting habits.

Rules: an explanation.

1- Submission categories are as follows: 

Native 

Plug In

Scripted

Each category should have a difficulty rating - 1 to 5 perhaps. 

They should be included in title for clarity-

Date_NameOfProblem_Native Plugin or Script_Difficulty

2. Since we are an international community, and this is an open group- a C+G day starts at the time of 10 am local poster’s time.

3.Anyone can set the next question. However the same person cannot set two days in a row. If a question is up- then next person needs to wait until the following day to post. You can PM Danny Boyes or Myself (Monique) if you are having posting issues- (i.e.: how to post, or have been trying to post, but keep missing the opportunity) 

4. Answers are presented in the typical grasshopper community response way: in the form of examples, and/or screen shots. For screen shots: make sure the nodes are legible, if you do a function inside a node make sure we can see what you did. Verbal explanation. Maybe picture of result.

The difference between this group and the general discussion is that the poster should know how to solve the problem, be able to post a solution up themselves.

5. The poster judges the answer. They should offer a sample solution as well when they declare the winner.

However overall quality control may be checked by moderators of the group.

6. Still thinking about this one. 

sorting algorithm for xy plotter

As I managed to get my pen plotter (a nice Roland DXY-1150A) working with gh via chiplotle (a also nice library that enables you to talk to the plotter via usb to serial port interface) all I need to be happy is the right sorting algorithm for the curves..

Will post some of the workflow and results later on here on the forum.

The task is to create a scripting component that sorts a given list of curves and lines and also flips them in a way that an xy plotter (or cutter or whatever) will go through them with the shortest walk.

And this time we will also have a price. I will ship a unique generative watercolor plot to the winner. 

To determine the winner I will measure the plotting time on my plotter. 

----------------------------------------------------------------------------------------

Here are some assumptions I made but of course any other solution is welcome:

In my opinion it should be something like David Mans "Sequentially Sort Points by Distance Component" for curves.

pseudo code would be:

 

input: list of curves and lines

 

  1. make a list of all endpoints and start points of the given curves

  2. start with a given point

  3. find the closest point regardless of whether its a start point or an endpoint.

  4. delete that point from the list

  5. take the other point of that curve  

and so on until you reach the end of the list.

 

the curves get sorted sequentially according to pattern above.

 

output would be the sorted indices of the curves and a true/false pattern whether

the first picked point was a start point or an endpoint.

to be able to flip the curves afterwards...

 

  • up

    Jake Newsum

    Hi Christian,

    Here is a python script that works in the same way as your pseudo code/sketch. I would say that this produces a short walk, but not the shortest. This is a first pass at how to start sorting out the problem, and there is a lot of room for improvement.

    Let me know if you have any questions.

    Kind Regards,

    10