# While rotating, how can the pivot point of a line change based on which is the closest point to it?

Hi,

I saw this interesting video of the Youtube channel 3Blue1Brown about the IMO 2011 n°2 problem and i decided to simulate it in gh but i having a hard time understanding how it can be solved.

I manage to do it with two points but it is easy to list and cheat. Once i add more points the algorithm becomes more complicated.

I thought this simulation could be solved easily with one slider. I’m sure i’m kind of close to the answer being somewhat between a loop and booleans distance checking. I tried with anemone but totally misunderstood how it works. I can’t wrap my mind about it.

Anyone has any idea?

IMO 2011 P2.gh (26.4 KB)

Hey!

With “To Polar” component, you can get polar coordinates of your point, and so sort them and pick the first.
With anemone i made iteratively some lists:
– current pivot point index
– vector for current pivot point direction
– rotation angle from previous direction
The definition talk for itself better than many words…

pivot points.gh (28.4 KB)

6 Likes

Ooooh really interesting. I totally forgot about the “to polar” component.

Thank you for this, i really appreciate it. Gonna give you credit on this.

Somewhere in this is a good mobile game app idea.

2 Likes

Oh yeah, would you imagin like trying to dodge falling squares or something like that? I don’t know, but game app could be a good idea haha.