Go to the documentation of this file.00001
00012 #ifndef LGL_NAVIGATION_DISTANCES_HEURISTICS_HPP
00013 #define LGL_NAVIGATION_DISTANCES_HEURISTICS_HPP
00014
00015 #include <math.h>
00016
00017 namespace jafar {
00018 namespace lgl {
00019
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 template <class Point, class DistType>
00043 DistType mahattanDist(const Point& v1, const Point& v2, const int& d1, const int& d2) {
00044
00045 DistType a1 = d1*v1.x();
00046 DistType a2 = d1*v1.y() + v1.x()%d1 - v1.x();
00047 DistType a3 = -d1*v1.y() - v1.x()%d1 - v1.x();
00048
00049 DistType b1 = d1*v2.x();
00050 DistType b2 = d1*v2.y() + v2.x()%d1 - v2.x();
00051 DistType b3 = -d1*v2.y() - v2.x()%d1 - v2.x();
00052
00053
00054 return d2*max(abs(a1-b1), max(abs(a2-b2), abs(a3-b3)));
00055 }
00056
00058 template <class Point, class DistType>
00059 DistType Mahattan2dDist(const Point& v1, const Point& v2) {
00060 return (fabs(v1.x()-v2.x()) + fabs(v1.y()-v2.y()));
00061 }
00062
00064 template <class Point, class DistType>
00065 DistType Mahattan3dDist(const Point& v1, const Point& v2) {
00066 return fabs(v1.x()-v2.x()) + fabs(v1.y()-v2.y()) + fabs(v1.z()-v2.z());
00067 }
00068
00070 template <class Point, class DistType>
00071 DistType Euclidean2DDist(const Point& v1, const Point& v2) {
00072 DistType dx = v2.x() - v1.x();
00073 DistType dy = v2.y() - v1.y();
00074 return sqrt(dx * dx + dy * dy);
00075 }
00076 }
00077 }
00078
00079 #endif