00001 #include "geometry.hpp"
00002
00003 using namespace Arak;
00004 using namespace Arak::Geometry;
00005
00006 void Arak::Geometry::n_gon(int n, double radius, Polygon& poly) {
00007 assert(n > 1);
00008 assert(radius > 0);
00009
00010 poly.erase(poly.vertices_begin(), poly.vertices_end());
00011
00012 typedef CGAL::Aff_transformation_2<Geometry::Kernel> Transformation;
00013 double angle = (2.0 * M_PI) / double(n);
00014 Transformation rot(CGAL::ROTATION, sin(angle), cos(angle));
00015 Point p(radius, 0);
00016 for (int i = 0; i < n; i++) {
00017 poly.push_back(p);
00018 p = rot.transform(p);
00019 }
00020 }