Simpact Cyan
Population based event driven simulation using mNRM
point2d.h
1 #ifndef POINT2D_H
2 
3 #define POINT2D_H
4 
5 #include <cmath>
6 
7 struct Point2D
8 {
9  Point2D() { }
10  Point2D(double x0, double y0) { x = x0; y = y0; }
11 
12  double getDistanceTo(Point2D p) const;
13  double getSquaredDistanceTo(Point2D p) const;
14 
15  double x, y;
16 };
17 
18 inline double Point2D::getDistanceTo(Point2D p) const
19 {
20  return std::sqrt(getSquaredDistanceTo(p));
21 }
22 
23 inline double Point2D::getSquaredDistanceTo(Point2D p) const
24 {
25  double dx = p.x - x;
26  double dy = p.y - y;
27  return dx*dx + dy*dy;
28 }
29 
30 #endif // POINT2D_H