Distance between Manhattan and cherbihov and their mutual transformation; distance between Manhattan and Xuefu
This article only discusses the distance between the two-dimensional space and the chibbihov.
Manhattan distance Definition
Set two points in the plane space. Their coordinates are $ (x1, y1) $, $ (x2, y2) $
$ Dis = | x1-x2 | + | y1-y2 | $
That is, the sum of the two-point horizontal and vertical Coordinate Difference
Boil a chestnut
In the figure, the distance between $ A and B $ is $ AC + BC = 4 + 3 = 7 $.
Distance Definition
Set two points in the plane space. Their coordinates are $ (x1, y1) $, $ (x2, y2) $
Then $ dis = max (| x1-x2 |, | y1-y2 |) $
That is, the maximum horizontal and vertical coordinate difference between two points
Boil another Chestnut
$ Dis = max (AC, BC) = AC = 4 $
Relationship between the two
The two definitions seem to have no wool relationship, but in fact, these two distances can beMutual Conversion!
In the simplest case, in a two-dimensional coordinate system, set the origin to $ (0, 0) $
If it is represented by the Manhattan distance, a point with a distance of $1 $ from the origin will constitute a square with a side length of $1 $.
If it is represented by a cut-over distance, a point with a distance of $1 $ from the source will constitute a square with a side length of $2 $.
What do you find by carefully comparing the two images?
That's right!
The second image is obtained by doubling the first image and rotating $45 ^ {\ circ} $.
Then, based on what is messy in the vector matrix
The vertex $ (x, y) $ in the first graph corresponds to the vertex $ (\ dfrac {x + y} {2}) in the second graph }, \ dfrac {x-y} {2}) $
In this way, we can convert each other.