Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
DiagonalDistance.hpp
Go to the documentation of this file.
1
6// Copyright (c) 2017 Czech Technical University in Prague | Faculty of Information Technology. All rights reserved.
7
8#pragma once
9
10#include <cmath>
11#include <alib/pair>
12#include <functional>
13
14namespace graph {
15
16namespace heuristic {
17
19// ---------------------------------------------------------------------------------------------------------------------
20 public:
21 template<typename TCoordinate>
24
25// ---------------------------------------------------------------------------------------------------------------------
26
27 template<typename TCoordinate>
28 static std::function<double(const ext::pair<TCoordinate, TCoordinate> &,
30
31// ---------------------------------------------------------------------------------------------------------------------
32
33};
34
35// =====================================================================================================================
36
37template<typename TCoordinate>
40 TCoordinate d_max = std::max(std::abs(node.first - goal.first), std::abs(node.second - goal.second));
41 TCoordinate d_min = std::min(std::abs(node.first - goal.first), std::abs(node.second - goal.second));
42
43 return M_SQRT2 * d_min + (d_max - d_min);
44}
45
46// ---------------------------------------------------------------------------------------------------------------------
47
48template<typename TCoordinate>
49std::function<double(const ext::pair<TCoordinate, TCoordinate> &,
51 return diagonalDistance < TCoordinate >;
52}
53
54// ---------------------------------------------------------------------------------------------------------------------
55
56} // namespace heuristic
57
58} // namespace graph
59
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: DiagonalDistance.hpp:18
static double diagonalDistance(const ext::pair< TCoordinate, TCoordinate > &goal, const ext::pair< TCoordinate, TCoordinate > &node)
Definition: DiagonalDistance.hpp:38
static std::function< double(const ext::pair< TCoordinate, TCoordinate > &, const ext::pair< TCoordinate, TCoordinate > &)> diagonalDistanceFunction()
Definition: DiagonalDistance.hpp:50
constexpr const T & max(const T &a)
Root case of maximum computation. The maximum from one value is the value itself.
Definition: algorithm.hpp:278
constexpr const T & min(const T &a)
Definition: algorithm.hpp:310
Definition: ReconstructPath.hpp:14
Definition: Node.cpp:11