JSPM

point-distance

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q24136F
  • License MIT

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

Package Exports

  • point-distance

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (point-distance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.