Skip to content

Commit cce148f

Browse files
committed
feat: add introduction about Chebyshev and Manhattan distances
1 parent 5103c56 commit cce148f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/geometry/manhattan-distance.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ for(int msk=0;msk < (1<<d);msk++){
5656

5757
## Rotating the points and Chebyshev distance
5858

59+
It's well known that, for all $m, n \in \mathbb{R}$,
60+
61+
$$|m| + |n| = \text{max}(|m + n|, |m - n|).$$
62+
63+
To prove this, we just need to analyze the signs of $m$ and $n$. And it's left as an exercise.
64+
65+
We may apply this equation to the Manhattan distance formula to find out that
66+
67+
$$d((x_1, y_1), (x_2, y_2)) = |x_1 - x_2| + |y_1 - y_2| = \text{max}(|(x_1 + y_1) - (x_2 + y_2)|, |(x_1 - y_1) - (x_2 - y_2)|).$$
68+
69+
The last expression in the previous equation is the [Chebyshev distance](https://en.wikipedia.org/wiki/Chebyshev_distance) of the points $(x_1 + y_1, x_1 - y_1)$ and $(x_2 + y_2, x_2 - y_2)$. This means that, after applying the transformation
70+
71+
$$\alpha : (x, y) \to (x + y, x - y),$$
72+
73+
the Manhattan distance between the points $p$ and $q$ turns into the Chebyshev distance between $\alpha(p)$ and $\alpha(q)$.
74+
75+
Also, we may realize that $\alpha$ is a [spiral similarity](https://en.wikipedia.org/wiki/Spiral_similarity) (rotation of the plane followed by a dilation about a center $O$) with center $(0, 0)$, rotation angle of $45^{\circ}$ in clockwise direction and dilation by $\sqrt{2}$.
5976

6077

6178
## Manhattan Minimum Spanning Tree

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy