Advertisement
Litigare

Untitled

Jun 16th, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <cmath>
  2. #include <algorithm>
  3.  
  4. #include "Heuristic.h"
  5.  
  6. Coordinate Heuristic::getDelta(Coordinate source_, Coordinate target_)
  7. {
  8.     return {
  9.         abs(source_.x - target_.x),
  10.         abs(source_.y - target_.y)
  11.     };
  12. }
  13.  
  14. int Heuristic::euclidean(Coordinate source_, Coordinate target_)
  15. {
  16.     auto delta = std::move(
  17.         getDelta(source_, target_)
  18.     );
  19.  
  20.     return static_cast<int>(10 * sqrt(pow(delta.x, 2) + pow(delta.y, 2)));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement