Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. class Point //класс точки
  5. {
  6. private:
  7. float x, y; //координаты точки
  8. Point(float _x, float _y) : x(_x), y(_y) {};
  9.  
  10. public:
  11. float getx() { return x; };
  12.  
  13. float gety() { return y; };
  14.  
  15. static Point Polar(float R, float F)
  16. { Point p(R * cos(F), R * sin(F)); return p; }; //полярные координаты точки
  17.  
  18. Point() { x = y = 0.0; };
  19. };
  20.  
  21. int main(int argc, char *argv[])
  22. {
  23. float edge{1.0}, angle{0.0}, pi{3.141592}, radius;
  24. int i = 0;
  25. Point vertex[8]; //массив точек
  26.  
  27. if (argc > 1)
  28. edge = atof(argv[1]);
  29.  
  30. radius = edge / (2 * sin( pi / 8.0 ));
  31.  
  32. while ( i < 8)
  33. {
  34. vertex[i] = Point::Polar(radius, angle);
  35. angle += pi / 4.0;
  36. i++;
  37. };
  38.  
  39. do
  40. {
  41. --i;
  42. printf("%f ; %f\n", vertex[i].getx(), vertex[i].gety());
  43. }
  44. while( i > 0 );
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement