14 for (
unsigned int k=0; k<_v.size(); ++k)
16 _v.at(k) =
Point2D( cos(k*2*M_PI/n), sin(k*2*M_PI/n) );
24 float sum=
dist( _v.front(),_v.back() );
25 for (
unsigned int k=1; k<_v.size(); ++k)
27 sum +=
dist( _v[k], _v[k-1] );
34 :
Form(0.0F, 0.0F), _v(n), _peri(-1.0F), _area(-1.0F)
36 for (
unsigned int k=0; k<_v.size(); ++k)
38 _v.at(k) =
Point2D( cos(k*2*M_PI/n), sin(k*2*M_PI/n) );
48 _peri=
dist( _v.front(),_v.back() );
49 for (
unsigned int k=1; k<_v.size(); ++k)
51 _peri +=
dist( _v[k], _v[k-1] );
62 _area=
crossZ(_v.back(),_v.front());
63 for (
unsigned int k=1; k<_v.size(); ++k)
65 _area +=
crossZ( _v[k-1], _v[k] );
Class containing a point in 2D.
Polygon(int n)
Constructs a regular polygon with vertices on the unit circle.
float perimeter() const
Computes the perimeter of the closed polygon.
float area() const override
Computes the area of the closed polygon.