Point2D.cpp 377 B

123456789101112131415161718192021222324
  1. #include "Point2D.h"
  2. CPoint2D::CPoint2D(double x, double y)
  3. {
  4. this->x = x;
  5. this->y = y;
  6. }
  7. CPoint2D::~CPoint2D()
  8. {
  9. }
  10. double CPoint2D::GetDistance(CPoint2D &pt1, CPoint2D &pt2)
  11. {
  12. return sqrt((pt1.x - pt2.x)*(pt1.x - pt2.x) + (pt1.y - pt2.y)*(pt1.y - pt2.y));
  13. }
  14. double CPoint2D::GetDistance(CPoint2D &pt)
  15. {
  16. return sqrt((x - pt.x)*(x - pt.x) + (y - pt.y)*(y - pt.y));
  17. }