Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Latest commit

 

History

History
27 lines (23 loc) · 543 Bytes

distances.md

File metadata and controls

27 lines (23 loc) · 543 Bytes

Distâncias

  • Distância euclidiana
template<typename T>
inline T euclidean_distance(T x1, T y1, T x2, T y2) {
    return sqrt( pow(x1-x2, 2) + pow(y1-y2, 2) );
}
  • Distância D4 (City-Block)
template<typename T>
inline T city_block_distance(T x1, T y1, T x2, T y2) {
    return abs(x1-x2) + abs(y1-y2);
}
  • Distância 8 (Chessboard)
template<typename T>
inline T chessboard_distance(T x1, T y1, T x2, T y2) {
    return std::max(abs(x1-x2), abs(y1-y2));
}