Life in a flash - Shang Liang

Interesting Math Problem

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.
crossovers
To produces this,
nocrossovers

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 :).

Published by 5566, on November 6th, 2006 at 3:09 pm.
Filled under: Maths&Physics 2 Comments

2 Responses to “Interesting Math Problem”

  1. What do you need blue dots for?

    Comment by Maciek on November 6, 2006 at 5:34 pm



  2. lol, true, the problem remains the same without the blue dots .

    Comment by 5566 on November 6, 2006 at 8:39 pm



Leave a Reply

For spam filtering purposes, please copy the number 4835 to the field below: