#!/usr/bin/perl

$n = 0;			  # Compteur
$xmax = $ymax = -1000;    # maximums en abscisse et ordonnée
$xmin = $ymin = 1000;	  # minimums en abscisse et ordonnée

# === Acquisition des points de la trajectoire
open(F,"$ARGV[0]"); @liste = <F>; close(F); chop(@liste);

foreach (@liste) {
    if ($_ ne "") {
	$n++;
	($null,$x,$y) = split(/\s+/,$_);
	$xmax = $x if $x > $xmax;
	$xmin = $x if $x < $xmin;
	$ymax = $y if $y > $ymax;
	$ymin = $y if $y < $ymin;
	push(@X,$x); push(@Y,$y);
    }
}

$fx = ($xmax - $xmin) / 300;
$fy = ($ymax - $ymin) / 300;


$f  = $fx > $fy ? $fx : $fy ;

$mx = ($xmin + $xmax) / 2;
$my = ($ymin + $ymax) / 2;
 
$n = 0 ;
while(@X) {
    $n++;
    $sep = ($n % 5) == 1 ? "§" : "";
    $x = shift @X;
    $x = sprintf("%.3f",($x - $mx) / $f + 160);
    $y = shift @Y;
    $y = sprintf("%.3f",($y - $my) / $f + 160);
    if ($n == 1) {
    	print STDOUT "($x,$y)";
    } else {
    	print STDOUT "$sep..($x,$y)";
    }
}
