npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aviation-math

v1.8.0

Published

Different methods to calculate distances, bearing and projections for aviation related software

Downloads

74

Readme

Aviation Math

Version Downloads Build Status Maintenance Codecov

Installation

Aviation Math can be used in both node.js and in the browser.

Install Aviation Math using npm:

npm install aviation-math

Usage

Position class

Useful container for coordinates. The constructor expects two parameters lat and lon or a string. More documentation needs to be done here.

const { Position } = require("aviation-math");

const pos1 = new Position(35.161372664038055, 33.267828863069205);
// pos1.toDMS() --> 35° 09′ 40.94″ N 033° 16′ 04.18″ E

const pos2 = new Position("35.161372664038055 N 33.267828863069205 E");
// pos2.toDMS() --> 35° 09′ 40.94″ N 033° 16′ 04.18″ E

const pos3 = new Position("40° 7.38' 74° 7.38'");
// pos3.toDMS() --> 40° 07′ 22.80″ N 074° 07′ 22.80″ E

The class offers different conversion formats like toDMS, toDMSCode, toDMM, toDDD.

See http://www.c-dev.ch/2012/10/26/koordinatenformate/ for more information.

getBearing(from: Position, to: Position): DegreesTrue

This function calculates the true bearing from one position to another one.

const { Position, getBearing } = require("aviation-math");

const result = getBearing(
    new Position(39.778889, -104.9825),
    new Position(43.778889, -102.9825),
);
// result = 19.787524850709246

getDistance(from: Position, to: Position) : NauticalMiles

This function calculates the distance in nautical miles from one position to another one.

const { Position, getDistance } = require("aviation-math");

const result = getDistance(
    new Position(50.02756868784301, 8.534261553454376),
    new Position(50.04004266904205, 8.586451452554849)
);
// result = 2.149991944029959

getTurnRadius(speed: Knots, bankAngle: Degrees) : NauticalMiles

This function calculates the turn radius based on the speed in knots and the bank angle.

const { getTurnRadius } = require("aviation-math");

const result = getTurnRadius(160, 30);
// result is close to 0.645

projectBearingDistance(reference: Position, bearing: DegreesTrue, distance: NauticalMiles): Position

This function projects a new position based on a reference position and a certain bearing and distance.

const { Position, projectBearingDistance } = require("aviation-math");

const result = projectBearingDistance(
    new Position(52.518611, 13.408056),
    180,
    8.09935205184,
);
// result is { lat: 52.383863707381906, lon: 13.408056 }

projectBearingIntersection(point1: Position, bearing1: DegreesTrue, point2: Position, bearing2: DegreesTrue): [Position, Position]

This function projects two intersections of two points and their bearings. The closer intersection is always the first item of the list.

const { Position, projectBearingIntersection } = require("aviation-math");

const a = projectBearingIntersection(
    new Position(39.778889, -104.9825),
    0,
    new Position(43.778889, -102.9825),
    0,
);
// result[0] is { lat: 90, lon: -90 }

projectTurnPosition(reference: Position, inboundCourse: DegreesTrue, outboundCourse: DegreesTrue, radius: NauticalMiles, turnDirection: TurnDirection) : Position

This function projects a position based on a reference position (, its inbound course) and a turn radius to an outbound course.

const { projectTurnPosition } = require("aviation-math");

const result = projectTurnPosition(
    new Position(50.0379326, 8.5599631),
    270,
    90,
    4,
    "LEFT"
);
// result is { lat: 49.90483820750475, lon: 8.5599631 }