#include<CGAL/Cartesian.h>
#include<CGAL/Polygon_2.h>
#include<iostream>

using std::cout;
using std::endl;
using namespace CGAL;

typedef Cartesian<double> K;
typedef Point_2<K> Point;

int main (int argc, char *argv[])
{
   if (argc != 2)
   {
      cout << "usage: " << argv[0] << " max-no-of-vertices" << endl;
      return 1;
   }

   int maxn = strtol (argv[1], NULL, 10);
   if (maxn < 3)
   {
      cout << "maximal number of vertices must be >= 3" << endl;
      return -1;
   }

   for (int n = 3; n <= maxn; ++n)
   {
      cout << "creating polygon with " << n << " vertices..." << endl;
      Polygon_2<K> poly;
      for (int i = 0; i < n; ++i)
      {
	 double phi = 2*i*CGAL_PI/n;
	 poly.push_back (Point(cos(phi),sin(phi)));
      }
      cout << "...and area " << poly.area() << endl;
   }
}

