Giter Site home page Giter Site logo

Comments (3)

0xStarcat avatar 0xStarcat commented on June 12, 2024

Potential Solution ?

This looks like it can be resolved by removing this line in moon.js:

i = (i+1) & 3;

Here's what results, and these are much closer aligned to expectations:

Day: 1  || illuminatedFraction: 0.2718262029195282 || phaseQuarter: 1
Day: 2  || illuminatedFraction: 0.1913535738047783 || phaseQuarter: 1
Day: 3  || illuminatedFraction: 0.12275534591473419 || phaseQuarter: 1
Day: 4  || illuminatedFraction: 0.06789228968867916 || phaseQuarter: 1
Day: 5  || illuminatedFraction: 0.028402658847401396 || phaseQuarter: 1
Day: 6  || illuminatedFraction: 0.005654730897217575 || phaseQuarter: 1
Day: 7  || illuminatedFraction: 0.0006617445257049992 || phaseQuarter: 2
Day: 8  || illuminatedFraction: 0.01398865166284069 || phaseQuarter: 2
Day: 9  || illuminatedFraction: 0.04567593153994548 || phaseQuarter: 2
Day: 10 || illuminatedFraction: 0.09519380617986456 || phaseQuarter: 2
Day: 11 || illuminatedFraction: 0.16142284737506968 || phaseQuarter: 2
Day: 12 || illuminatedFraction: 0.2426405680532956 || phaseQuarter: 2
Day: 13 || illuminatedFraction: 0.3364851635748891 || phaseQuarter: 2
Day: 14 || illuminatedFraction: 0.43987279594989304 || phaseQuarter: 2
Day: 15 || illuminatedFraction: 0.5488689342271671 || phaseQuarter: 3
Day: 16 || illuminatedFraction: 0.6585597621788225 || phaseQuarter: 3
Day: 17 || illuminatedFraction: 0.763029581554865 || phaseQuarter: 3
Day: 18 || illuminatedFraction: 0.8555981913616235 || phaseQuarter: 3
Day: 19 || illuminatedFraction: 0.9294546722062444 || phaseQuarter: 3
Day: 20 || illuminatedFraction: 0.9786814411700813 || phaseQuarter: 3
Day: 21 || illuminatedFraction: 0.9994095420276781 || phaseQuarter: 3
Day: 22 || illuminatedFraction: 0.9906443297921943 || phaseQuarter: 0
Day: 23 || illuminatedFraction: 0.9543665946579276 || phaseQuarter: 0
Day: 24 || illuminatedFraction: 0.8948694419357917 || phaseQuarter: 0
Day: 25 || illuminatedFraction: 0.8176725929146917 || phaseQuarter: 0
Day: 26 || illuminatedFraction: 0.728477536842415 || phaseQuarter: 0
Day: 27 || illuminatedFraction: 0.6324682679459483 || phaseQuarter: 0
Day: 28 || illuminatedFraction: 0.5340178279576334 || phaseQuarter: 0
Day: 29 || illuminatedFraction: 0.4367005906508668 || phaseQuarter: 1
Day: 30 || illuminatedFraction: 0.3434676777124016 || phaseQuarter: 1
Day: 31 || illuminatedFraction: 0.2568689766546564 || phaseQuarter: 1

I'm running this on a fork with tests (https://github.com/0xStarcat/Moshier-Ephemeris-JS), so I can say confidently removing this line does NOT break anything.

Does this line need to be in there? Was the & bitwise operator intended as a % modulo maybe?

Honestly, if you changed the line to:

i = (i+2) % 4;

and moved it right above $moshier.body.moon.position.phaseQuarter = i; so it ran every iteration, it makes the calculated value make much more sense.

New Moon = 0
First quarter = 1
Full moon = 2
last quarter = 3

i can add a PR for this if you'd like. What do you think?

Thank you! :)

from ephemeris.

0xStarcat avatar 0xStarcat commented on June 12, 2024

I'm beginning to think this line

i = (i+1) & 3;

was maybe meant to serve as an "approximator" or an orb in astrological terms, for when to designate the start and end of a quarter. In this case, from checking the phaseDaysBefore and phaseDaysAfter values, it seems like the quarters are approximated within 3 days on either side of the true quarter event.

I suppose this has a useful purpose, and based on this, there's probably something that can be done to make the output of these fields more useful like

  1. letting user define the "approximation" or "orb" amount,
  2. returning Waxing, Waning, Crescent and Gibbous strings for shape and direction, etc

In any case, I've done a little bit of this in my fork 0xStarcat@135ca2b

from ephemeris.

0xStarcat avatar 0xStarcat commented on June 12, 2024

Closing this down because I think I've answered this sufficiently for myself

from ephemeris.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.