shashwatak/satellite-js

Adding Sun() function (Sun Position/Ascension/Declination) to the package

Closed this issue · 1 comments

Hi,

I work with orbit propagation and I have been used Vallado MATLAB package for a long time. Currently, I am using satellite.js for a web-based project and I realized not all of the functions are converted from the original Vallado code. Since I personally needed the Sun position in my project, I converted the MATLAB function "sun.mat" from the Vallado package to Javascript "sun.js".

Since it is very short and simple, I would like to share it here. Maybe it becomes useful for some users.
sun.js.txt
(Remove .txt extension)

To use, just simply add sun.js after loading satellite.js in your page. This function gets JulianDate as input and returns Sun position/ascension/declination as the output.

Since the MATLAB syntax is very simple, it is easy to convert the whole Vallado package to JavaScript and satellite.js. I think adding this (and also other functions from the original package) to satellite.js makes it more practical for various projects.

Cheers

thkruz commented

This looks like valid code and I hope it helps others, but there are no plans to upgrade this library. If you are looking for sun position or ra/dec caclulations for the sun or stars I recommend looking at the OP's solution or the following libraries:

suncalc3
ootk-core