Languages
[Edit]
EN

JavaScript - Rectilinear Distance function

10 points
Created by:
Wiktor-Sribiew
830

In this short article, we would like to show how to calculate Rectilinear Distance using JavaScript.

The universal distance formula is:

Where:

  • x and y are points in the space,
  • n is a number of dimensions.

The two-dimensional formula is:

The three-dimensional formula is:

Rectilinear Distance is also known as taxicab metric, L1 distance or L1 norm, snake distance, city block distance, Manhattan distance, or Manhattan length.

It was used to measure the absolute distance needed to move from one place to the second one in taxicab city.

Rectilinear Dinstance calculation in JavaScript.
Rectilinear Dinstance calculation in JavaScript.

A practical example in 2D:

 

More complicated examples

Edit

In this section, you can find Rectilinear Distance examples for 3D and 4D.

 

See also

Edit
  1. JavaScript - Chebyshev Distance function

  2. JavaScript - how to calculate distance between two points with Pythagorean equation?

References

Edit
  1. Rectilinear distance - Wikipedia
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join