当前位置:网站首页>Pyqt5 development tips - obtain Manhattan distance between coordinates

Pyqt5 development tips - obtain Manhattan distance between coordinates

2022-07-06 08:00:00 [email protected]

PyQt5 Development tips—— Get Manhattan distance between coordinates

Introduction to Manhattan distance

We can define the formal meaning of Manhattan distance as L1- Distance or city block distance , That is to say, the sum of the distance of the projection of the line segment formed by two points to the axis in the fixed rectangular coordinate system of Euclidean space .

For example, on the plane , coordinate (x1, y1) The point of P1 And coordinates (x2, y2) The point of P2 The Manhattan distance is :
 Insert picture description here
It should be noted that , Manhattan distance depends on the rotation of the coordinate system , Not the translation or mapping of the system on the coordinate axis .

The reason why Manhattan distance is named is from the city planned as a square building block ( Such as Manhattan ) between , The shortest driving path ( Ignore the one-way lanes in Manhattan and only exist in 3、14 The oblique lane of the avenue ). Any three blocks to the East 、 The path to Beiliu block must take at least block 9 , There is no other shortcut .

API

int manhattanLength (self)
x = (btn1.pos() - btn2.pos()).manhattanLength()
原网站

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131848202817.html