Giter Site home page Giter Site logo

nare214 / celmec Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 26.82 MB

Calculate the real-time positions of the sun, all planets and every star/deep-sky object at the sky completely client-side

Home Page: https://www.npmjs.com/package/celmec

License: MIT License

JavaScript 100.00%
astronomy calculations planets stars sun math physics

celmec's Introduction

celmec

About

With this package, you can calculate the real-time positions of the sun, all planets and every star/deep-sky object at the sky completely client-side.

How to use

For stars

First, find the rotating equatorial coordinates of the star. They can be divided into two parts: right ascension (RA) and declination (Dec). You can look them up on wikipedia. It should look similar to this:

RA:  18h 37m 44.7s
Dec: 38° 48' 33.0"

Next, create a new instance of the Star class. Use RA and Dec of the star in degrees as parameters in the constructor. If the coordinates are given in hour angles or sexagesimal degrees, use new HourAngle(hours, minutes, seconds).toDegrees() or new SexagesimalDegrees(degrees, minutes, seconds).toDegrees().

   See also: Angle Units (Wikipedia)

Now, use RA and Dec (both in degrees) to create a new Star object:

const star = new Star(RA, Dec);

Finally, calculate azimuth and height. You'll need the geographic latitude and longitude.

const azimuthalPosition = star.calculateAzimuthal(latitude, longitude);
const azimuth = azimuthalPosition.azimuth;
const height = azimuthalPosition.height;

For planets

Create a new instance of the Planet class. In this example, it's Saturn, but you can use any planet from the object PlanetAbbreviation.

const saturn = new Planet(PlanetAbbreviation.sat);

Calculate azimuth and height by calling the method calculateAzimuthal(latitude, longitude):

const azimuthalPosition = saturn.calculateAzimuthal(latitude, longitude);
const azimuth = azimuthalPosition.azimuth;
const height = azimuthalPosition.height;

For the sun

Call Sun.calculateAzimuthal(latitude, longitude):

const azimuthalPosition = Sun.calculateAzimuthal(latitude, longitude);
const azimuth = azimuthalPosition.azimuth;
const height = azimuthalPosition.height;

NPM Package

https://www.npmjs.com/package/celmec

celmec's People

Watchers

nare214 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.