Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
79ddc105fb Kotlin: Added NOVAS C 3.1 check for Windows builds.
The previous commit added the NOVAS check for
Kotlin output to the bash script unit_test_kotlin,
which is executed in Linux and Mac OS.
This commit adds the same check to run.bat,
which is executed on Windows.
2022-04-03 16:36:58 -04:00
Don Cross
e46c0cf8c6 Kotlin: Compare test output to NOVAS C 3.1.
Instead of relying only on diffcalc to catch calculation
errors, call `generate check` before proceeding with other
unit tests. This way, breakage can be more quickly isolated
to the Kotlin code, if it is the culprit.
2022-04-03 10:43:20 -04:00
Don Cross
075a80fde8 Kotlin: Implemented Astronomy.search.
Implemented the low-level search function that will be used
to implement all the special-purpose search functions to come.

Added missing documentation to class NodeEventInfo members.

Minor cleanup in the C# function `Astronomy.Search`:
- removed an unused output parameter.
- deleted confusing sentence in documentation.
2022-04-03 10:37:12 -04:00
Don Cross
9d6294d7fe Miscellaneous documentation fixes.
While working on the Kotlin implementation, I have
found a few documentation mistakes in the other language
implementations. These have been accumulating in the
`kotlin` branch. I migrated these changes back into
the released code for now, because I don't want to wait
until Kotlin is ready.
2022-04-02 16:52:54 -04:00
Don Cross
6ea35232d8 Updated C# readme based on changes in C# docstring. 2022-04-02 15:28:05 -04:00
Don Cross
e879a67be7 Kotlin: Added constellation function. 2022-04-02 15:17:14 -04:00
Don Cross
04e7102f76 Kotlin: rotationEqjGal, rotationGalEqj. 2022-04-01 19:59:03 -04:00
Don Cross
9b11c44b9e Kotlin: rotationEclHor, rotationHorEcl. 2022-04-01 19:44:33 -04:00
Don Cross
a7e667309d Kotlin: rotationEqdEcl, rotationEclEqd. 2022-04-01 19:34:26 -04:00
Don Cross
3c2f8c0cc9 Kotlin: rotationEqjHor, rotationHorEqj.
Added two more rotation functions.

Corrected a typo in the documentation for Rotation_HOR_EQJ
in the other 4 languages.
2022-04-01 19:19:24 -04:00
Don Cross
2ee5f6f8f5 Kotlin: rotationEqdHor, rotationHorEqd.
Added two more of the rotation functions.
This is the pair for converting between of-date equatorial
coordinates and an observer's horizontal system.
2022-04-01 18:52:00 -04:00
Don Cross
cf38342f69 Kotlin: implemented rotationEqdEqj. 2022-04-01 18:27:50 -04:00
Don Cross
aeb6e90028 Kotlin: starting to add rotation functions.
Starting to add the functions that create rotation
matrices to convert from one orientation to another.
Here are the ones implemented in this commit:

    rotationEqjEcl
    rotationEclEqj
    rotationEqjEqd

Also starting to add missing documentation to
resolve Dokka warnings.
2022-04-01 18:12:21 -04:00
Don Cross
12ae8291a2 Merge branch 'master' into kotlin
Bringing over Python fixes:
- Better string representations of classes.
- A few documentation fixes.
2022-03-31 23:06:58 -04:00
Don Cross
608a7a8dca Fixed #184 - repr for Python classes
Defined consistent __repr__ methods for
Astronomy Engine Python classes.
Each string representation is reversible:

eval(repr(x)) -> x

The main goal is to facilitate interactive
debugging and experimentation for developers
working directly in the Python interpreter.

Fixed documentation mistakes in the following classes:
    IlluminationInfo
    LunarEclipseInfo
2022-03-31 22:47:59 -04:00
Don Cross
c9054e25e3 Diffcalc C/Kotlin: relaxed tolerances.
The GitHub Actions test comparing C and Kotlin
output failed for the Mac OS platform.
The test failed locally on my Windows 10 system
for the same reason.
Relaxed the constraints on both so they will pass again.
2022-03-31 15:45:15 -04:00
Don Cross
41be8a2b6b Kotlin: Fixed bug calculating horizontal coordinates.
The `horizon` function was taking the sine and cosine
of the right ascension, but treating it as degrees.
This was wrong because right ascension is in sidereal hours.
Fix: multiply hours by 15 to get degrees.

Keeping the unit test that confirmed this bug.

Added comparison of C and Kotlin output to `diffcalc`
and `diffcalc.bat`. This test now passes on Linux.
This is a big milestone!
2022-03-31 14:49:35 -04:00
Don Cross
fe1cba065b Kotlin: Fixed bug in Pluto gravity simulator.
The function getPlutoSegment had a bug simulating gravity
in the forward direction. It was creating an array `seg`
that was one item too long: 202 instead of 201 elements.
This caused states from inconsistent time steps to be mixed.

I discovered this via the `diffcalc` script.
I added a new unit test that quickly reproduced this issue.
This was helpful for debugging and finding the problem.
I'm keeping the new unit test, in case it helps detect
breakage in the future.
2022-03-31 13:28:10 -04:00
Don Cross
503e31b0d9 Kotlin code style: remove semicolons, underscores. 2022-03-31 08:28:53 -04:00
Don Cross
397c259bc6 Kotlin: Jupiter's moons.
Implemented Kotlin functions and code generator
for calculating the state vectors of Jupiter's
largest 4 moons.

Added cautionary comments about needing to correct
Jupiter's moons for light travel time.

This is the first pass to get everything needed
for the AstroCheck tests. I tried comparing
C output to Kotlin output, and there are some
serious problems to debug:

    $ ./ctest diff 2.8e-16 temp/{c,k}_check.txt
    First  file: temp/c_check.txt
    Second file: temp/k_check.txt
    Tolerance = 2.800e-16

                lnum                 a_value                 b_value     factor       diff  name
    FAIL      137746  4.2937184148112564e+01  4.2944101081740065e+01    0.03364  2.327e-04  helio_x
    FAIL      373510  1.4197190315274938e+01  1.4193716564905307e+01    0.03364  1.168e-04  helio_y
    FAIL      137746 -6.5897675150466091e+00 -6.5929481589493522e+00    0.03364  1.070e-04  helio_z
    FAIL       59150  1.8035183339348251e+01  1.8035909197904104e+01    0.01730  1.255e-05  sky_j2000_ra
    FAIL      137747 -8.1222057639092533e+00 -8.1250990689970894e+00    0.00556  1.607e-05  sky_j2000_dec
    FAIL      137747  4.8436159305823310e+01  4.8441487614058218e+01    0.03481  1.855e-04  sky_j2000_dist
    FAIL      322846  8.7596368704201495e+01  2.6760770774700188e+02    0.00278  4.995e-01  sky_hor_az
    FAIL      405828 -6.5075824596574279e+01  5.6922941329250996e+01    0.00556  6.778e-01  sky_hor_alt
      OK       92717  4.1268347083494783e-03  4.1268347083494774e-03  223.21429  1.936e-16  jm_x
      OK       45091 -8.0149190392649894e-03 -8.0149190392649929e-03   79.42812  2.756e-16  jm_y
      OK      135377  1.5470777280065808e-03  1.5470777280065804e-03  223.21429  9.680e-17  jm_z
      OK      216836  4.5725777238332412e-03  4.5725777238332394e-03  126.58228  2.196e-16  jm_vx
      OK      351647  5.1351566793199944e-03  5.1351566793199962e-03  126.58228  2.196e-16  jm_vy
      OK      351647  2.5217607180929289e-03  2.5217607180929298e-03  126.58228  1.098e-16  jm_vz

    Score = 6.778e-01
    ctest(Diff): EXCEEDED ERROR TOLERANCE.

So I'm checking this in as work-in-progress.
2022-03-30 22:49:22 -04:00
Don Cross
74a1274c85 Kotlin: Implemented functions: geoVector, equator, horizon.
Implemented more of the core functions needed for
the AstroCheck tests. Most of AstroCheck is now implemented,
except for the JupiterMoons tests.

Code cleanup thanks to @ebraminio:
- Use `when { }` syntax.
- Renamed `IllumInfo` to `IlluminationInfo`.
- Other minor naming fixes.

Configured Dokka to warn about undocumented symbols.

We also configured Dokka to omit internal symbols, including
inside enums, but that does not work, despite this bug
being marked fixed in dokka:

https://github.com/Kotlin/dokka/issues/1802

We suspect they didn't really fix the bug, and that
there is a bug in their test.
2022-03-30 20:42:24 -04:00
Don Cross
f2d19c4dcc Fixed #179: Fixed Kotlin hyperlinks.
Thanks to @ebraminio for telling me how to fix the
Kotlin docstring hyperlinks. Symbols just need to be put
in brackets, not prefixed by a pound sign.
2022-03-30 14:48:20 -04:00
Don Cross
832fec5ce7 Kotlin: simplified per-body mass product and VSOP87 models.
Thanks to @ebraminio, I learned that Kotlin enum classes
allow the members to contain data properties. This greatly
simplifies code so that I no longer need such verbose
`when (body)` statements.

I also understand Kotlin enums better, and I realized
there is no need for `Body.Invalid`, because the compiler
simply does not allow invalid enum values to exist.
In any future hypothetical situation where I want to
represent an optional `Body` value, I can use the nullable type `Body?`.
2022-03-30 14:22:22 -04:00
Don Cross
e4a186aa09 Kotlin: heliocentric state vectors.
Added Astronomy.geoMoonState and Astronomy.helioState functions.
These allow calculating the position and velocity of any
solar system body.

Added sanity checks for state vectors in the unit tests.
2022-03-30 12:53:23 -04:00
Don Cross
1eeea5b46e Kotlin: calculate Solar System Barycenter position. 2022-03-29 20:54:17 -04:00
Don Cross
9d38dac2f1 Kotlin: Gravity simulator, Pluto calculation.
Added calculation of heliocentric and barycentric
state vectors for Pluto. This is done using
a gravity simulator that treats Pluto as a negligible
mass that is affected by the major masses of the
Solar System: Sun, Jupiter, Saturn, Uranus, Neptune.

Updated the code generator to write the Kotlin
version of the Pluto state table, a lookup table
of known-correct state vectors of Pluto at long
intervals, derived from the TOP2013 model.

The gravity simulator interpolates state vectors
of Pluto between these known-correct states.

Minor code style cleanup in the Kotlin source.

Fixed a possible thread-safety issue in the C# code.
2022-03-29 19:22:40 -04:00
Don Cross
71c919c10e Merge branch 'dependabot/npm_and_yarn/generate/minimist-1.2.6'
Security update for the developer tools.
This change has no effect on most users of Astronomy Engine;
the updated code is only executed by contributors and developers.
2022-03-29 15:50:50 -04:00
dependabot[bot]
166bd6e1d5 Bump minimist from 1.2.5 to 1.2.6 in /generate
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 06:24:50 +00:00
Don Cross
044ecfb774 Kotlin: VSOP87 position, velocity vectors.
Implemented the VSOP87 calculation functions for
heliocentric position vectors, heliocentric velocity vectors,
and heliocentric distances.
Implemented Astronomy.helioVector for everything except Pluto and SSB.

Corrected small errors in C# documentation.
2022-03-28 12:33:01 -04:00
Don Cross
2d5ef05536 Kotlin: implemented geocentric Moon.
Implemented the Montenbruck/Pfleger version of the NAO1954
geocentric Moon model in Kotlin.

In the process, code review helped simplify parts of the C# code.
I may want to go back and see if I can simplify the CalcMoon
code in the other languages too.
2022-03-27 20:39:43 -04:00
Don Cross
490b5dee5c Kotlin: Generating VSOP87 model source code.
Added code generator for VSOP87 major planet models in Kotlin.
Added a lookup function for VSOP87 models to Kotlin template.
Moved IAU2000b delcaration outside class Astronomy.
2022-03-27 06:02:21 -04:00
Don Cross
44adf1e652 Relaxed diff threshold so it passes on my Windows laptop.
The recent changes in C# vector to spherical conversions
caused a miniscule change in the comparison between
C and C# calculations. The same thing happened in Linux.
I am relaxing the threshold slightly so the tests pass
again on my Windows 10 laptop. It's curious that they
didn't fail in the GitHub Actions Windows image.
2022-03-26 21:04:31 -04:00
Don Cross
a96c8358b9 Kotlin: Added Astronomy.rotationAxis().
Added the rotationAxis, which calculates dynamic orientation
of planet, Sun, and Moon rotation axes. Added the first
unit test that verifies against JPL Horizons data.

Eliminated more redundant time parameters in precession functions.

More cleanup of C# code: I realized the private function
vector2radec was redundant with the public function EquatorFromVector.
Deleted vector2radec.
2022-03-26 20:42:14 -04:00
Don Cross
bec202ba37 Kotlin: added nutation matrix/vector functions.
Added functions for generating rotation matrices,
rotating position vectors, and rotating state vectors,
for the Earth's axial nutation.

Simplified gyration functions in C#:
it turns out the `time` parameters were redundant,
because time is included in the `t` field of the vector
passed in. I reworked the C# code to eliminate those time
parameters.

The Kotlin code follows suit.
2022-03-26 13:40:52 -04:00
Don Cross
62405be175 Kotlin: Convert observer <==> state vector.
Implemented the functions `terra` and `inverseTerra`.

`terra` converts geographic coordinates and time into
a geocentric state vector.

`inverseTerra` converts a position vector and time
into geographic coordinates.

I realized the C# function `inverse_terra` could be
simplified. It does not need to be passed a separate
time, because the sidereal time can be derived
from, or has already been stored inside, the vector's
time field `ovec.t`.

There were a couple of other minor cleanups to the C# code.
2022-03-26 11:51:36 -04:00
Don Cross
9ae0ba1e01 Dump unit test failures to GitHub Actions log.
If the Kotlin unit tests fail on my home system,
I can easily read them. But if they fail on GitHub Actions,
I would have no idea what went wrong. So now I dump
the XML output of the unit tests if the gradlew command
fails for any reason. Then I can see the problem in
the GitHub Actions console log.
2022-03-26 02:24:46 -04:00
Don Cross
9b4223193b Kotlin: sidereal time
Implemented Astronomy.siderealTime() in Kotlin.

Updated all languages' unit tests for sidereal time
to verify exact conformity between them, rather than
to an externally derived value. I wanted to make
sure all languages, including Kotlin, are calculating
the exact same value.

I don't need an external authoritative test for
sidereal time, because it will be indirectly tested
through its involvement in thousands of other calculations
that depend on it. I just need a quick sanity check
before implementing those other things that depend on it.
2022-03-26 02:07:15 -04:00
Don Cross
9772ea9f47 Kotlin: starting precession and nutation.
Implemented the iau2000b nutation formula.
Implemented calculation of the precession
rotation matrix.

This is the very first use of a code generator
macro for the Kotlin code.  I am going to try
keeping all these macros toward the bottom
of the source tepmlate, so that as I look at
line numbers for compiler errors, they will match
between the target code and the template code.

I may go back and rework the other languges to
do this also. I'm not sure why I didn't think
of this before!
2022-03-25 21:00:11 -04:00
Don Cross
6cb7ab7cce Kotlin: added constants and massProduct function. 2022-03-25 18:28:51 -04:00
Don Cross
8c923d49d6 Kotlin: added more data types.
Ported the following types to the Kotlin code:

    GlobalSolarEclipseInfo
    EclipseEvent
    LocalSolarEclipseInfo
    TransitInfo
    ShadowInfo
    IllumInfo
    AxisInfo
    NodeEventKind
    NodeEventInfo

Made some wording fixes in the documentation for the
other languages.
2022-03-25 15:52:27 -04:00
Don Cross
29472cded9 Kotlin code style.
Bringing Kotlin source code into closer alignment with
the style guide at:

https://kotlinlang.org/docs/coding-conventions.html
2022-03-25 14:22:40 -04:00
Don Cross
bdf49c4487 Kotlin: Treat warnings as errors. Fixed warnings. 2022-03-24 21:19:44 -04:00
Don Cross
a43a2531b6 Merge branch 'master' into kotlin 2022-03-24 20:38:31 -04:00
Don Cross
b8fc1bc975 Fixed #177 - Incorrect text in Python documentation for enum EclipseKind. 2022-03-24 20:35:30 -04:00
Don Cross
f0c4eb05db Kotlin: Ported some more data types.
Ecliptic
Topocentric
SeasonsInfo
MoonQuarterInfo
LibrationInfo
HourAngleInfo
ElongationInfo
ApsisKind
ApsisInfo
EclipseKind
LunarEclipseInfo
2022-03-24 20:17:14 -04:00
Don Cross
cb54c32e79 Delete source/kotlin/build dir before build on Windows.
Just like in Linux and Mac OS, nuke the 'build'
directory before running gradlew. This ensures
no stale content leaks in from previous builds.
2022-03-24 11:20:09 -04:00
Don Cross
a30c879262 Remove dokka step from 'rebuild' helper scripts.
During development, when I just want a quick build/test cycle,
I don't need to waste time regenerating documentation.
So I removed the dokka steps from the 'rebuild' scripts.
The dokka steps are still executed when running the full
build process before pushing to GitHub.
2022-03-24 10:32:31 -04:00
Don Cross
96b84cfc67 Weirdly, GitHub Actions steps were in wrong order.
This is strange. I noticed looking in the GitHub Actions report
for running tests that my Gradle/Kotlin steps were run before
their dependencies were supposedly installed. Perhaps the
steps "set up JDK 1.8" and "gradle/wrapper-validation-action@v1"
are not even needed? Regardless, I moved these steps to run
before building and testing the Kotlin code.

Even if the steps are not needed, they are a helpful reference
point for understanding what things a developer needs to install
on a local system before making contributions to Astronomy Engine.
2022-03-24 10:27:31 -04:00
Don Cross
fa499d75cc Fixed broken unit tests due to stale Dokka output.
I didn't realize Dokka doesn't clean up its output directory
before writing documentation files. This caused stale documentation
to still exist from previous builds. The result was a failed
unit test because the generated documentation did not match
what was checked into git.

In general, I want to make sure that builds I run on my development
system exactly match what GitHub Actions does on its cloud platform.
So before running the `gradlew` build step, I delete the entire
directory source/kotlin/build. This directory is always absent
on GitHub Actions, which makes my local build better match the
remote build.
2022-03-24 09:47:22 -04:00
Don Cross
e68ba361c3 Kotlin: minor code cleanup. 2022-03-23 20:53:31 -04:00