Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const Distance between earth and sun #175

Open
jindal12ketan opened this issue Apr 16, 2024 · 1 comment
Open

Const Distance between earth and sun #175

jindal12ketan opened this issue Apr 16, 2024 · 1 comment

Comments

@jindal12ketan
Copy link

`SunCalc.getMoonIllumination = function (date) {

var d = toDays(date || new Date()),
    s = sunCoords(d),
    m = moonCoords(d),

    sdist = 149598000, // distance from Earth to Sun in km

    phi = acos(sin(s.dec) * sin(m.dec) + cos(s.dec) * cos(m.dec) * cos(s.ra - m.ra)),
    inc = atan(sdist * sin(phi), m.dist - sdist * cos(phi)),
    angle = atan(cos(s.dec) * sin(s.ra - m.ra), sin(s.dec) * cos(m.dec) -
            cos(s.dec) * sin(m.dec) * cos(s.ra - m.ra));

return {
    fraction: (1 + cos(inc)) / 2,
    phase: 0.5 + 0.5 * inc * (angle < 0 ? -1 : 1) / Math.PI,
    angle: angle
};

};`

Why is the sdist constant, doesn't it change with date and time?

@lulunac27a
Copy link

This number is the distance of 1 AU (astronomical unit) in kilometers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants