Files
astronomy/demo/nodejs
Don Cross 0d24433db3 Fixed #187 - Seasons() failed for distant years.
For years before 1582 or years after 3668, the Seasons functions
were unable to find many equinoxes and/or solstices.
The problem was that over time, the Earth's axis precesses
enough that the calendar dates of these events drifts outside
the fixed search ranges I had provided for them.

I expanded the search ranges so all season changes can be found
for a much wider range of years, as verified by unit tests:

    C/C++:      -2000..9999
    C#:             1..9999
    JavaScript: -2000..9999
    Python:         1..9999
    Kotlin:         1..9999

Note: C#, Python, and Kotlin currently do not allow
years values below +1. In fact, I discovered we were not
noticing when an invalid year was passed into the Kotlin code.
I updated that code to throw an exception when the year does
not match what was expected. It is disturbing that the
GregorianCalendar class silently ignores invalid years!

Constricted the search tolerance from 1 second to 0.01
seconds for the seasons search, to ensure more consistent
behavior.

Fixed a bug in the Kotlin search() function's
quadratic interpolation that was causing the convergence
to be slower than it should have been.
2022-04-08 16:51:09 -04:00
..
2020-08-10 11:37:34 -04:00

JavaScript examples for Node.js

The source file astronomy.js works as a Node.js module. Download the file into your project directory. Then in your own source file, do this:

const Astronomy = require('astronomy.js');

or install the package with npm i astronomy-engine and:

import { SearchMoonQuarter } from 'astronomy-engine';

Vanilla JS There are no external dependencies! Astronomy Engine is completely self-contained, and it always will be.

(By the way, you can use the same file astronomy.browser.js for astronomy calculations inside the browser.)


Culmination

Finds when the Sun, Moon, and planets reach their highest position in the sky on a given date, as seen by an observer at a specified location on the Earth. Culmination is also the moment a body crosses the meridian, the imaginary semicircle in the sky that passes from due north on the horizon, through the zenith (straight up), and then toward due south on the horizon.

Equator of Date

Given the right ascension and declination of a star, expressed in J2000 coordinates, converts those coordinates to right ascension and declination expressed in the Earth's equator at any given date and time. This example illustrates how to use rotation matrices to convert one coordinate system to another.

Horizon Intersection

This is a more advanced example. It shows how to use coordinate transforms to find where the ecliptic intersects with an observer's horizon at a given date and time.

Lunar Eclipse

Calculates details about the first 10 partial/total lunar eclipses after the given date and time.

Moon Phase Calculator

This example shows how to determine the Moon's current phase, and how to predict when the next few quarter phases will occur.

Positions

Calculates equatorial and horizontal coordinates of the Sun, Moon, and planets.

Rise/Set

Shows how to calculate sunrise, sunset, moonrise, and moonset times.

Seasons

Calculates the equinoxes and solstices for a given calendar year.

Triangulate

Given the geographic coordinates of two observers, and angular directions they are looking in, determines geographic coordinates of the point they are both looking at. This example demonstrates use of the geoid functions VectorObserver and ObserverVector that convert between geographic coordinates and vectors.


API Reference

Complete documentation for all the functions and types available in the JavaScript version of Astronomy Engine.