1.0.0 • Published 3 years ago

point-distance v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

point-distance Travis CI Build Status

Get the distance between 2 points on a 2d, 3d or Earth-like plane.

NPM Badge

Install

npm install point-distance

Usage

const pointDistance = require("point-distance")

console.log(pointDistance([0, 0], [3, 4]))
//=> 5

console.log(pointDistance([0, 0, 0], [3, 12, 4]))
//=> 13

console.log(pointDistance.earth([-36.848161, 174.762256], [-36.848513, 174.7635]))
//=> 117.6259

API

pointDistance(startX, startY, startZ?, endX, endY, endZ?)

Get the distance between 2 points on a 2d or 3d plane.

startX, startY, startZ, endX, endY, endZ

Type: number

The starting and ending coordinates to get the distance between.

pointDistance.earth(startLatitude, startLongitude, startAltitude?, endLatitude, endLongitude, endAltitude?)

Get the distance between 2 coordinates on Earth. Returns the distance in metres.

startLatitude, startLongitude, endLatitude, endLongitude

Type: number

The starting and ending coordinates to get the distance between.

startAltitude, endAltitude

Type: number

The starting and ending altitudes between the 2 coordinates in metres.