#! /usr/bin/perl

# Copyright (C) 2006 Arne Wichmann
#
# This little thing is distributed under the GNU General Public License,
# version 2. If you need the license, ask your distributor for it.

# usage: $0 <inputfile>

# Input format is: First line contains the number of base pairs.
# All other lines contain pairs of: <position> <name>

# Output is a FIG file containing a drawing of the plasmid

use strict;
use Math::Trig;

my $version=0.1;

print "#FIG 3.2 Produced by plasmidkarte version $version\nLandscape\n".
  "Center\nMetric\nA4\n100.00\nSingle\n-2\n1200 2\n";

print "1 3 0 1 0 7 50 -1 -1 0.0 1 0.0 0 0 ".(40*45)." ".(40*45)." 0 0 ".
  (40*45)." 0\n";
print "1 3 0 1 0 7 50 -1 -1 0.0 1 0.0 0 0 ".(36*45)." ".(36*45)." 0 0 ".
  (36*45)." 0\n";

my $numpairs=<>;

while (<>) {
  chomp;
  my @i=split(" ",$_,2);
  print "2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n";
  # starting at 0, numpairs=2pi
  # x=cos(w)*a, y=sin(w)*a
  print "\t".(int(40*45*sin(2*pi*$i[0]/$numpairs)))." ".
    (int(40*45*-cos(2*pi*$i[0]/$numpairs)))." ".
    (int(44*45*sin(2*pi*$i[0]/$numpairs)))." ".
    (int(44*45*-cos(2*pi*$i[0]/$numpairs)))."\n";
  print "4 0 0 50 -1 4 12 0.0 4 135 2915 ".
    (int(48*45*sin(2*pi*$i[0]/$numpairs)))." ".
    (int(48*45*-cos(2*pi*$i[0]/$numpairs)))." $_\\001\n";

}
