Polygon.cpp 506 B

123456789101112131415161718192021222324
  1. #include "Polygon.h"
  2. #include <iostream>
  3. #include <algorithm>
  4. Polygon::init(vector<struct Point> init_points)
  5. {
  6. points = init_points;
  7. }
  8. Polygon::Polygon(vector<struct Point> init_points)
  9. {
  10. init(init_points);
  11. }
  12. void Polygon::sort_points()
  13. {
  14. return std::sort(points.begin(), points.end(), [](struct Point lhs, struct Point rhs) {return l2(lhs.x, lhs.y, 0.0, 0.0) < l2(rhs.x, rhs.y, 0.0, 0.0); });
  15. }
  16. double Polygon::calc_perimiter()
  17. {
  18. sort_points();
  19. std::cout << points << std::endl;
  20. }