#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.14159265358979323846
int main (int argc, char **argv)
{
double offset, x, y, z, r, angle;
int order, n;

order = atoi (argv[1]);
r = atof (argv[2]);

offset = (2 * PI) / 36;
printf ("<gml>\n  <molecule>\n");

z = 0.1;
for (n = 0; n < order; n++)
  {
  angle = (2 * PI) / order;
  x = r * cos (n * angle);
  y = r * sin (n * angle);
  printf ("    <atom element=\"C\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", x, y, 1.0 - z);

  x = r * cos (n * angle + offset);
  y = r * sin (n * angle + offset);
  printf ("    <atom element=\"O\" x =\"%f\" y=\"%f\" z=\"%f\"/>\n", x, y, 1.0 + z);

  z = -z;
  }

printf ("  </molecule>\n</gml>\n");

return 0;
}
