summaryrefslogtreecommitdiffstats
path: root/kue/point.cpp
blob: 3ee12888301dc4b6d87e77d521768bcf3a28af56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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));
}