Conversion to asmjs of Debian's astronomical-almanac package
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
debian
.agignore
.gitignore
README.md
aa-55.xml
aa.ans
aa.c
aa.ini
aa.que
aa.rsp
aa_msc6.mak
aaexe.zip
altaz.c
angles.c
annuab.c
arcdot.c
bc4.zip
bc5.zip
bcb5.zip
conjunct.c
constel.c
consts.c
consts.h
deflec.c
deltat.c
distance.c
diurab.c
diurpx.c
dms.c
domoon.c
ear404.c
epsiln.c
fk4fk5.c
gplan.c
julian_day.js
jup404.c
kep.h
kepler.c
kfiles.c
lightt.c
lonlat.c
makefile
mar404.c
mer404.c
messier.cat
mlat404.c
mlr404.c
moonrise.c
msvc5.zip
msvc6.zip
nep404.c
nutate.c
orbit.cat
package.json
planet.c
planet_distance.c
planet_kinit.c
plantbl.h
plu404.c
precess.c
protos.h
read.me
readme.404
refrac.c
rplanet.c
rstar.c
sat404.c
sidrlt.c
star.cat
sun.c
tdb.c
trnsit.c
unix.mak
ura404.c
vax.zip
vearth.c
ven404.c
zatan2.c

README.md

astronomical-almanac-js

This is the port to asm.js of Debian's astronomical-almanac.

The original license is GPL v2.0 and is found in the debian/copyright file. This package is licensed under the same licence.

The original README is the readme.404 file in the main directory.

The changes made are:

  • The makefile generates JavaScript targets using emcc and modified CFLAGS
  • Added planet.js and planet-node.js targets. They wrap the algorithm that computes the distance between two planets. planet.js can be used in the browser using Module.cwrap and planet-node.js can be used from the command line.

All programs compile but the only one guaranteed to work is the new planet.js library and the planet-node.js standalone program.

Building

$ npm install
$ make clean
$ make -j  # or just make

The distance algorithm is embedded in planet.js, planet.js.mem and planet.js.symbols for browser based projects. You'll need planet-node.js, planet-node.js.mem and planet-node.js.symbols for running it from the command line.

Examples

In the browser

<script type="text/javascript" src="planet.js"></script>

var kmToPlanet = Module().cwrap("km_to_planet", "number", ["number", "number"]);
var now = new Date().getTime() / 86400000 + 2440587.5; // Julian day
console.log(kmToPlanet(now, 4)); // Earth to Mars

A live example: http://connettiva.eu/newton (source at newton-says)

From the command line

$ node planet-node.js $(node julian_day.js) 4  # Earth to Mars

Available planet numbers

  • 1 Mercury
  • 2 Venus
  • 4 Mars
  • 5 Jupiter
  • 6 Saturn
  • 7 Uranus
  • 8 Neptune
  • 9 Pluto