Distance between Manhattan and cherbihov and their mutual transformation; distance between Manhattan and Xuefu

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.