Skip to content

Commit c967b4e

Browse files
authored
chore: Merge pull request TheAlgorithms#645 from Enoch-Moke/patch-2
Create Coordinate.js
2 parents ff1d209 + d46e467 commit c967b4e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Maths/Coordinate.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Calculate the mathematical properties involving coordinates
3+
Calculate the Distance Between 2 Points on a 2 Dimensional Plane
4+
Example: coorDistance(2,2,14,11) will return 15
5+
Wikipedia reference: https://en.wikipedia.org/wiki/Geographical_distance#Flat-surface_formulae
6+
*/
7+
const distance2points = (longitude1, latitude1, longitude2, latitude2) => {
8+
const width = longitude2 - longitude1
9+
const height = latitude2 - latitude1
10+
return (Math.sqrt(width * width + height * height))
11+
}
12+
13+
export { distance2points }

0 commit comments

Comments
 (0)