From 08b57c9716bbbb434ea70c9bc6618b2e7aa868c7 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 24 May 2017 15:15:40 +1000 Subject: [PATCH] point: add docstrings for distance metrics --- point.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/point.hpp b/point.hpp index c9bf480c..8a4d11cf 100644 --- a/point.hpp +++ b/point.hpp @@ -24,6 +24,9 @@ namespace util { /// An n-dimensional position in space. + /// + /// \tparam S number of dimensions + /// \tparam T the underlying per-dimension datatype template struct point : public coord::base { @@ -39,19 +42,36 @@ namespace util { void sanity (void) const; }; + /////////////////////////////////////////////////////////////////////////// // distance operators + + /// computes the exact euclidean distance between two points. template typename std::common_type::type distance (point, point); + /// computes the squared euclidean distance between two points. + /// + /// useful if you just need to compare distances because it avoids a sqrt + /// operation. template constexpr typename std::common_type::type distance2 (point, point); + /// computes the octile distance between two points. that is, the shortest + /// distance between `a' and `b' where travel is only allowed beween the 8 + /// grid neighbours and cost for diagonals is proportionally larger than + /// cardinal movement. see also: chebyshev. template typename std::common_type::type octile (point<2,T>, point<2,U>); + /// computes the manhattan distance between two points. that is, the + /// distance where travel is only allowed along cardinal directions. template constexpr typename std::common_type::type manhattan (point, point); + /// computes the cheyvshev distance between two points. that is, the + /// shortest distance between `a' and `b' where travel is only allowed + /// between the 8 grid neighbours and cost for diagonals is the same as + /// cardinal movement. see also: octile. template constexpr typename std::common_type::type chebyshev (point, point);