Interesting Math Problem
Monday 6 November 2006 - Filed under Maths&Physics
There are n dots, p red ones and q blue ones. The target is to link up the red ones without having cross overs, e.g.

To produces this,

To solve this problem. I consider all the red dots lie originally on a perfect circle and this irregular pattern is produced by moving the dots further or closer to the center of the circle. So, I first calculated the center point of all dots, centerX=(x1+x2+…+xn)/n, centerY=(y1+y2+…+yn)/n. Using a center point, I calculate the angle of a dot as angle1=Math.atan2(y1-centerY, x1-centerX). All the dots are sorted by their angles and linked clockwise or counterclockwise.
Not something difficult but quite interesting
.
2006-11-06 » 5566

6 November 2006 @ 5:34 pm
What do you need blue dots for?
6 November 2006 @ 8:39 pm
lol, true, the problem remains the same without the blue dots .