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

solaris-model

v0.1.0

Published

A logical model of our Solar System providing the positions of planets, moons and other celestial bodies as a function of time.

Downloads

3

Readme

solaris-model

A logical model of our Solar System providing the positions of planets, moons and other celestial bodies as a function of time.

You can use it as a data source to render the Solar System, in 2D or 3D.

It also provides other info needed for rendering such as each object's radius, axial tilt, ring boundaries (if any) and orbital path.

This is a work in progress: the positions of the planets seem to checkout against established tools like Celestia, but there is still a lot of work to be done on satellite orbits and other features (check the TODO list below). Please don't use it to plan the trajectory for your multibillion-dollar space probe just yet (it will crash - on the wrong target).

Corrections and bug reports are welcome.

Install

Node or browser:

npm install solaris-model

Old school? Download the tarball and get the bundle from the dist folder.

<script src="solaris-model.min.js"></script> <!-- sets window.SolarSystem -->

Usage

CommonJS:

let SolarSystem = require('solaris-model')

ES6 (Michael Jackson script included!):

import SolarSystem from 'solaris-model'

Both methods give you a class you can instantiate to get your model:

let system = new SolarSystem

// Flat dictionary of all bodies in the system, by key
console.log(Object.keys(system.bodies)) // ['sun', 'mercury', 'venus', 'earth', 'moon', 'iss', ...]

let sun = system.bodies.sun
console.log(sun.key) // 'sun'
console.log(sun.name) // 'The Sun'
console.log(sun.type) // 'star'
console.log(sun.position) // [0, 0, 0]

console.log(Object.keys(sun.satellites)) // ['mercury', 'venus', 'earth', 'mars', 'ceres', ...]

let mars = sun.satellites.mars
console.log(mars.name) // 'Mars'
console.log(mars.type) // 'planet'
console.log(mars.central.name) // 'The Sun'
console.log(mars.satellites.phobos.name) // 'Phobos'

let earth = system.bodies.earth
console.log(earth.satellites.iss.name) // 'ISS'
console.log(system.bodies.iss.type) // 'spacecraft'

let saturn = system.bodies.saturn
console.log(saturn.radius) // 60268000
console.log(saturn.type) // 'planet'
console.log(saturn.mass) // 5.68319e+26
console.log(saturn.tilt) // 26.73

system.setTime('1961-04-12')

console.log(saturn.position) // in meters, relative to the sun
// [640052013047.9685, -1353546339129.1343, -1739512961.8784275]

console.log(system.bodies.europa) // in meters, relative to *jupiter*
// [666664577.6643108, -21177279.12859592, 4714819.292014049]

console.log(saturn.getOrbitPath().length) // 360

console.log(saturn.getOrbitPath())
// [
//   [-136760528961.4258, -1496030001961.143, 31460392085.67932],
//   [-113085367440.416, -1498196488549.527, 30555898430.39112],
//   ...
// ]

Known issues and limitations

  • The reference data from JPL used for the planets allows calculation of approximate positions, valid for the period from 1800 to 2050 CE. Check the same link for the approximate error table.

To-do list

  • Account for perturbations of Earth's Moon.

  • Fill in remaining major dwarf planets, moons and asteroids.

  • Fix satellite orbits.

  • Calculate rotation angle of bodies.

  • Include ring info for Jupiter, Uranus and Neptune.

  • Consider using angles.js and kepler.js.

References

Big thanks to the authors of the awesome resources below:

Articles:

Open source projects:

License

MIT