22 Point2D(
float x,
float y) : _x(x), _y(y) {}
26 float GetX()
const {
return _x;}
30 float GetY()
const {
return _y;}
54 return std::sqrt( std::pow(a.
GetX()-b.
GetX(),2) + std::pow(a.
GetY()-b.
GetY(),2) );
64 int number()
const {
return _v.size(); }
69 std::vector<Point2D> _v;
96 int number()
const {
return _v.size(); }
113 std::vector<Point2D> _v;
Class containing a point in 2D.
Point2D(float x, float y)
Constructor.
Point2D()
Constructor without parameters. Defines the point to the origin (0.0).
float GetX() const
Getter.
float GetY() const
Getter.
bool operator<(const Polygon_old &rhs) const
void append(const Point2D &a)
Contains the description of a polygon, now with mutable. The traverse is stored.
bool operator<(const Polygon &rhs) const
Less operator regarding the perimeter.
int number() const
Number of vertices in polygon.
Polygon(int n)
Constructs a regular polygon with vertices on the unit circle.
float perimeter() const
Computes the perimeter of the closed polygon.
void append(const Point2D &a)
Adds a vertex to the end of the polygon traverse.
float dist(const Point2D &a, const Point2D &b)
Calculates the Euclidian distance between two points in 2D.
std::ostream & operator<<(std::ostream &s, const Point2D &rhs)
Output operator for class Point2D.