. , , 10 , 5 , 15 , 6 . , , . . , , - , (, A B, B A).
, , . , , , A B , A C A D . , , , , ( " n , n . . , n , ... , , splay trees for " .).
C ++ hypot :
#include <cmath>
double getDistance(cv::Point2f punt1, cv::Point2f punt2)
{
return std::hypot(punt2.x - punt1.x, punt2.y - punt1.y);
}
, , , .
, , X Y . , , :
const double threshold = ...;
std::vector<cv::Point2f> points;
...
for (auto i = points.begin(); i != points.end(); ++i) {
for (auto j = i + 1; j != points.end(); ++j) {
double dx = std::abs(i->x - j->x), dy = std::abs(i->y - j->y);
if (dx > threshold || dy > threshold) {
continue;
}
double distance = std::hypot(dx, dy);
if (distance > threshold) {
continue;
}
...
}
}