10 s <<
"(" << rhs.
GetX() <<
"," << rhs.
GetY() <<
")";
23 for (
unsigned int k=0; k<_v.size(); ++k)
25 _v.at(k) =
Point2D( cos(k*2*M_PI/n), sin(k*2*M_PI/n) );
33 float sum=
dist( _v.front(),_v.back() );
34 for (
unsigned int k=1; k<_v.size(); ++k)
36 sum +=
dist( _v[k], _v[k-1] );
45 for (
unsigned int k=0; k<_v.size(); ++k)
47 _v.at(k) =
Point2D( cos(k*2*M_PI/n), sin(k*2*M_PI/n) );
57 _peri=
dist( _v.front(),_v.back() );
58 for (
unsigned int k=1; k<_v.size(); ++k)
60 _peri +=
dist( _v[k], _v[k-1] );
Class containing a point in 2D.
float GetX() const
Getter.
float GetY() const
Getter.
Polygon(int n)
Constructs a regular polygon with vertices on the unit circle.
float perimeter() const
Computes the perimeter of the closed polygon.
ostream & operator<<(ostream &s, const Point2D &rhs)
float dist(const Point2D &a, const Point2D &b)
Calculates the Euclidian distance between two points in 2D.