in reply to Data visualisation.

You can pick some starting coordinates and then iteratively scoot the points around until you (hopefully) get a reasonable solution. I came up with this set of coordinates, which isn't too bad.

A 125.5 -13.0 B 5.8 622.6 C 170.2 250.3 D 67.6 28.0 E 54.9 392.3 F 128.8 137.6 G 126.6 63.5 H 137.6 100.2 I -115.1 83.3 J 219.8 483.8 K 117.0 352.0 L -176.7 28.1 M 86.2 63.7 N 189.9 182.1 O 207.5 242.4 P -124.3 -117.7 Q 116.8 109.2

Replies are listed 'Best First'.
Re^2: Data visualisation.
by BrowserUk (Patriarch) on Jan 02, 2014 at 22:05 UTC
    iteratively scoot the points

    I searched CPAN & google for a "scoot"ing algorithm without luck.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Heh. That's not a technical term. You can do something like this:

      for $i (0 .. $npts-1) { for $j ($i+1 .. $npts-1) { $dx = $x[$j] - $x[$i]; $dy = $y[$j] - $y[$i]; $d = sqrt($dx*$dx + $dy*$dy); $f = $d - $distance[$i][$j]; $fx[$i] += $f * $dx / $d; $fy[$i] += $f * $dy / $d; $fx[$j] -= $f * $dx / $d; $fy[$j] -= $f * $dy / $d; } }

      That gives you the x and y components of the total "force" on each point. Then you can update the positions.

      for $i (0 .. $npts-1) { $x[$i] += $dt * $fx[$i]; $y[$i] += $dt * $fy[$i]; }

      The trick is choosing a good time step $dt. Too small and it will converge very slowly. Too high and it will rattle around and never settle down. (You might want to look at the forces before choosing a time step, which is why I've put the update in a separate loop.) This kind of thing is sensitive to initial conditions and doesn't always converge well, so you may need to fiddle around with it to get it to work.

        Heh. That's not a technical term.

        (I kinda knew that :)

        The trick is choosing a good time step $dt.

        So...you're solving a simultaneous equation for each point? (I'm guessing?)

        Is that necessary? Cannot The law of cosines be combined with Sine function to derive the cartesian coordinates of a 3rd point given its vector lengths from two other points with known coordinates?

        This is what I've been trying, but I think the signed-ness malarkey of trig functions beyond π/2 is screwing me up :(


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.