Commit Graph

34 Commits

Author SHA1 Message Date
Don Cross
7e196a3c17 Fixed Windows batch files ignoring negative integer failure codes.
In many of my Windows batch files, I used the following
construct to detect failures:

    do_something
    if errorlevel 1 (
        echo.An error occurred in do_something
        exit /b 1
    )

I discovered that it is possible for a Windows program
to exit with a negative integer error code.
This causes the above construct to miss the failure
and the batch file blithely continues.

So I have replaced that construct with

    do_something || (
        echo.An error occurred in do_something
        exit /b 1
    )

This way, if the command exits with any nonzero error,
we correctly detect it as a failure.
2023-02-26 10:26:42 -05:00
Don Cross
1dcdb7780f Kotlin: true solar time demo 2023-02-12 19:30:35 -05:00
Don Cross
1a4f842764 Updated Ecliptic to return ECL in all languages. 2022-12-10 19:35:42 -05:00
Don Cross
8a153315cf Simplified and optimized nutation formula.
While trying to convert ecliptic coordinates from mean
equinox of date to true equinox of date, I ran into excessive
overhead from the IAU2000B nutation model. The fact that it
uses 77 trigonometric terms made the calculations a lot slower.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document mentions a shorter series
“NOD version 2” that has 13 terms instead of 77 as used in IAU2000B.
I had not noticed NOD2 before, because it appears only in
the FORTRAN version of NOVAS 3.x, not the C version.

After reading the FORTRAN code, I realized NOD2 is the same
as IAU2000B, only it keeps the first 13 of 77 terms.
The terms are already arranged in descending order of
significance, so it is easy to truncate the series.

Based on this discovery, I realized I could achieve all of
the required accuracy needed for Astronomy Engine by
keeping only the first 5 terms of the nutation series.
This tremendously speeds up nutation calculations while
sacrificing only a couple of arcseconds of accuracy.

It also makes the minified JavaScript code smaller:
Before: 119500 bytes.
After:  116653 bytes.

So that's what I did here. Most of the work was updating
unit tests for accepting slightly different calculation
results.

The nutation formula change did trigger detection of a
lurking bug in the inverse_terra functions, which convert
a geocentric vector into latitude, longitude, and elevation
(i.e. an Observer object). The Newton's Method loop in
this function was not always converging, resulting in
an infinite loop. I fixed that by increasing the
convergence threshold and throwing an exception
if the loop iterates more than 10 times.

I also fixed a couple of bugs in the `demotest` scripts.
2022-12-04 10:31:15 -05:00
Don Cross
e31be80497 Kotlin: reworked rise/set to work in polar regions 2022-11-13 19:25:44 -05:00
Don Cross
06b62887d2 Kotlin: obscuration for solar, lunar eclipses. 2022-10-20 17:31:21 -04:00
Don Cross
c1759b081a Kotlin: Reverse chrono search for rise/set, hour angles.
The following Kotlin functions now support searching
in forward or reverse chronological order:

    searchRiseSet
    searchAltitude
    searchHourAngle
2022-10-01 11:26:03 -04:00
Don Cross
5676049596 Kotlin: added iterator helper functions
Added the following iterator functions that wrap
search/next pairs of functions:

    globalSolarEclipsesAfter
    localSolarEclipsesAfter
    lunarApsidesAfter
    lunarEclipsesAfter
    moonNodesAfter
    moonQuartersAfter
    planetApsidesAfter
    transitsAfter

I updated the following Kotlin demos:

    MoonPhase.kt    ==> moonQuartersAfter
    LunarEclipse.kt ==> lunarEclipsesAfter

However, I have not yet figured out how to use these
functions in the corresponding Java demos.
2022-05-06 21:52:27 -04:00
Don Cross
87665fe5d5 Added missing Windows batch files: rundemo.bat
The help pages for the Java and Kotlin demos mention
a Windows batch file `rundemo.bat`, but they did not exist.
I created them, so now the documentation is correct.
2022-05-04 21:44:04 -04:00
Ebrahim Byagowi
adeb4de8ab jvm demos: Use let in RiseSetCulm.maybe 2022-05-05 01:47:04 +04:30
Ebrahim Byagowi
79aee817cf jvm demos: Use Jupiter moon names instead direct access
Makes the Kotlin demo similar to Java one.
2022-05-05 01:39:12 +04:30
Ebrahim Byagowi
37ca6c4fe3 jvm demos: Use stream/sequence
Uses of newer language structures to recreate the needed logic.
2022-05-05 01:38:14 +04:30
Don Cross
cc4bc88fbe Improved efficiency of 3 lunar eclipse demos.
Three of the lunar eclipse demos (Python, Java, Kotlin)
provided a less than ideal example of efficient computation.
They were wasting a lunar eclipse search by calculating it
but not printing it. Now after printing exactly 10 lunar
eclipses, stop running immediately.
2022-05-04 14:00:35 -04:00
Don Cross
25adb13997 Kotlin demo: lunar eclipse prediction 2022-05-04 12:49:46 -04:00
Don Cross
7a916d4f8c Java demo: rise/set/culmination
Added Java demo to search for rise/set/culmination
of the Sun and Moon.

Also added the missing entry for the Kotlin
rise/set/culmination demo that I had forgotten.
2022-05-04 11:12:49 -04:00
Don Cross
bdb28eee2e Kotlin demo: rise/set/culmination
Added Kotlin demo to search for rise/set/culmination
of the Sun and Moon.

Enhanced the Time class to allow it to be
directly compared and sorted.
2022-05-03 21:09:56 -04:00
Don Cross
f32a922ddb Demo for Kotlin, Java: constellation 2022-05-03 16:50:11 -04:00
Ebrahim Byagowi
c24d49f742 jvm: Upgrade Java language version to 11 2022-05-03 21:57:57 +04:30
Ebrahim Byagowi
6c55d15778 jvm demos: Simplify main function
Also makes the two more similar.
2022-05-03 01:41:06 +04:30
Ebrahim Byagowi
612f2ef3f4 jvm demos: Apply IDE provided suggestions 2022-05-03 01:27:05 +04:30
Don Cross
1e84f4940f Demo jupiter_moons for Kotlin, Java.
Added Kotlin and Java demos for calculating Jupiter's moons.
Illustrates correcting for light travel time.
I added named getters for the 4 moons in `JupiterMoonsInfo`,
because in Java it was really ugly to write
`jm.getMoon()[0]`, etc.
2022-05-02 15:45:10 -04:00
Don Cross
f670ae2127 Added Kotlin demo: jupiter_moons.
I had to add a new method `Vector.withTime` to work around
the error checking that throws an exception if vectors
from different times are added.

Also made Kotlin constants public:

    MINUTES_PER_DAY
    SECONDS_PER_DAY
    MILLISECONDS_PER_DAY
2022-05-02 14:57:16 -04:00
Don Cross
5df9b03e7c Added comments to Java demos. 2022-05-02 13:38:31 -04:00
Don Cross
237bc42084 Added Kotlin demo: positions.
I also reworked how the Java and Kotlin demos
process errors in the command line arguments.
Using exceptions that are caught by main() rather
than directly exiting the process where the errors
are detected.
2022-05-02 11:28:16 -04:00
Don Cross
551ce7a249 Simplified Java/Kotlin demo tests.
I found that it is possible to use the "||" operator
in Windows batch files, and it works the same as the
"||" operator in bash scripts.

This inspired me to rework the bash scripts and
Windows batch files for running the Java/Kotlin demo
tests to be much more compact using functions/subroutines.

The best part is, the new approach will make it much
easier to add more demo tests in the future.

Removed the "now" test from Java demos, because it
does not follow the same pattern as the other demos,
plus it is not really demonstrating astronomy calculations.

Starting working on the Positions.kt demo; but not finished yet.
2022-05-02 10:21:23 -04:00
Don Cross
eac8582418 Test Kotlin demos in Windows. 2022-05-01 19:48:18 -04:00
Don Cross
b03171ac3a Added code comments for the Kotlin demos. 2022-05-01 16:45:57 -04:00
Don Cross
5cb273ceed Starting to add Kotlin demos.
Just like we have Java demos that use the Kotlin
version of Astronomy Engine, I want equivalent
demos in Kotlin.
2022-05-01 16:39:14 -04:00
Don Cross
896df1ad19 Removed Kotlin Native tests for now.
We are having difficulty getting Kotlin code to build for
both JVM and Native. For now, the priority is to support JVM,
so I am turning off installation of the Kotlin Native compiler.
2022-04-15 13:04:52 -04:00
Don Cross
ad439c6d97 Kotlin Native work in progress: build errors.
Checking in with the Kotlin Native tests turned off,
because the code does not build yet. Seeking help.
2022-04-14 13:16:09 -04:00
Don Cross
30ee194e72 Trying my own Kotlin Native installer.
I kept running into problems trying to create
a GitHub Action to install the Kotlin Native compiler.
So I am rolling my own using a bash script.
2022-04-13 20:33:04 -04:00
Don Cross
4e588b7fe9 Kotlin Native: fixed GitHub Actions issues.
The Mac OS tests failed because the Kotlin Native
compiler created an unexpected directory:

	demo/kotlin/native/moonphase.kexe.dSYM/

I fixed this by adding *.dSYM to .gitignore.

Also, the GitHub Action `fwilhe2/setup-kotlin@main`
defaults to an older version of the compiler.
I added an option to specify using version 1.6.20.
2022-04-13 18:47:54 -04:00
Don Cross
d1d18c60e6 Setting up for Kotlin Native demo/test.
Nothing very interesting yet.
Just building a very basic Kotlin Native app
to make sure build and execute work on GitHub Actions,
on Linux and Mac OS.  I will worry about Windows later.
2022-04-13 17:37:00 -04:00
Don Cross
6b880894e2 Added Kotlin to supported language list.
The main README.md now includes Kotlin as a supported
language.

Pivoted the table so languages are listed vertically
instead of horizontally, because this fits better on
a screen, especially using the GitHub mobile app.

There is a link to Kotlin demos, but there are no
demos implemented yet.

Likewise, there is a link to Kotlin documentation,
but the generated documentation is not stored in Git yet,
so there is no actual documentation generated from docstrings
in the code yet.
2022-03-21 15:20:55 -04:00