Fixed bug with distance calculations... distance <> slope
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user