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

Calculation of lunar days #69

Open
damirmur opened this issue Sep 3, 2020 · 1 comment
Open

Calculation of lunar days #69

damirmur opened this issue Sep 3, 2020 · 1 comment

Comments

@damirmur
Copy link

damirmur commented Sep 3, 2020

Calculation of lunar days
Greetings.
I've done this before in Java, here is a piece of code
public static double[] moon_Rise(SwissEph sw, SweDate sd, double lat, double lon, double tzOffset) { double[] md; ArrayList<Double> moondays = new ArrayList(); if (sw == null) { sw = new SwissEph("./ephe"); } double date = sd.getJulDay(); sd.makeValidDate(); int fl = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE; TransitCalculator tc = new TCPlanetPlanet( sw, SweConst.SE_MOON, SweConst.SE_SUN, fl, 0); boolean backwards = true; double previousTransitUT = sw.getTransitUT(tc, sd.getJulDay(), backwards);//forward double nextTransitUT = sw.getTransitUT(tc, sd.getJulDay(), false);//forward int pl = SweConst.SE_MOON; fl = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE | SweConst.SEFLG_TRANSIT_SPEED; int rsmi = 0; double[] geopos = {lon, lat, 0}; DblObj tret = new DblObj(); StringBuffer serr = new StringBuffer(); date = previousTransitUT; moondays.add(previousTransitUT); double monday = sd.getJulDay(); while (date < nextTransitUT) { sw.swe_rise_trans(date, pl, null, fl, SweConst.SE_CALC_RISE, geopos, 0, 0, tret, serr); monday = tret.val + 0.1; if (date > tret.val) { continue; } if (nextTransitUT < tret.val) { break; } moondays.add(tret.val); sw.swe_rise_trans(sd.getJulDay(), pl, null, fl, SweConst.SE_CALC_SET, geopos, 0, 0, tret, serr); date = monday; } moondays.add(nextTransitUT); md = new double[moondays.size()]; for (int i = 0; i < md.length; i++) { md[i] = moondays.get(i); } return md; }

Can you tell me how to do this in Javascript, the same Transit calculator, the previous aspect, the next aspect?

@damirmur damirmur changed the title Расчет лунных дней Calculation of lunar days Sep 3, 2020
@gkostov
Copy link
Contributor

gkostov commented Feb 16, 2021

The objects and methods above make it look like you have used the SwissEph.java code (a Java port of the original C library). Unfortunately those are not part of the original code and are not available in this Javascript binding.

The way forward would be to port the required logic from Java (code is at http://th-mack.de/international/download/) to JS and then use it.

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