diff options
Diffstat (limited to 'kue/point.cpp')
-rw-r--r-- | kue/point.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kue/point.cpp b/kue/point.cpp new file mode 100644 index 00000000..3ee12888 --- /dev/null +++ b/kue/point.cpp @@ -0,0 +1,19 @@ +#include "point.h" +#include <math.h> + +point::point(double x, double y) { + _pos_x = x; + _pos_y = y; +} + +point::~point() { +} + +double point::distance(const point &other_point) const { + // Finds the distance between two points, using: + // d^2 = (x1 - x2)^2 + (y1 - y2)^2 + double delta_x = _pos_x - other_point._pos_x; + double delta_y = _pos_y - other_point._pos_y; + + return sqrt((delta_x * delta_x) + (delta_y * delta_y)); +} |