csansoon

P9.05 P84786 Circles (1)

Dec 11th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. struct Point {
  6.     double x, y;
  7. };
  8. struct Circle {
  9.     Point center;
  10.     double radius;
  11. };
  12.  
  13. double dist(const Point& a, const Point& b) {
  14.     return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
  15. }
  16.  
  17. void move(Point& p1, const Point& p2) {
  18.     p1.x = p1.x + p2.x;
  19.     p1.y = p1.y + p2.y;
  20. }
  21. void move(Circle& c, const Point& p) {
  22.     c.center.x = c.center.x + p.x;
  23.     c.center.y = c.center.y + p.y;
  24. }
  25.  
  26. void scale(Circle& c, double sca) {
  27.     c.radius = c.radius * sca;
  28. }
  29.  
  30. bool is_inside(const Point& p, const Circle& c) {
  31.     return dist(c.center,p)<=c.radius;
  32. }
  33.  
  34. // (c) Carlos Sansón (Best pro1 delegate ever for sure) @csansoon
Advertisement
Add Comment
Please, Sign In to add comment