Fixed bug with distance calculations... distance <> slope

This commit is contained in:
2011-06-22 22:47:56 -04:00
parent 5b53e0b115
commit 1606dfb058
2 changed files with 11 additions and 11 deletions

View File

@ -1,13 +1,9 @@
#include "graph.h"
#include "debug.h"
#include <cmath>
using std::abs;
#ifdef DEBUG
#include <iostream>
using std::cerr;
#endif
Graph::Graph()
{
@ -110,6 +106,5 @@ float Vertex::distance(Vertex a, Vertex b)
{
float dy = abs(static_cast<float>(b.y) - a.y);
float dx = abs(static_cast<float>(b.x) - a.x);
if (dx == 0) return 0;
return dy/dx;
return sqrt(dy*dy + dx*dx);
}