Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
ecedb44da9 Forked setup-kotlin action and fixed download.
This is my attempt to fix an incorrect download
URL in the GitHub Action:

https://github.com/fwilhe2/setup-kotlin

I forked it to try out my own fix:

https://github.com/cosinekitty/setup-kotlin

I updated the GitHub Actions configuration file
to use my forked version instead.
I hope this works!
2022-04-13 19:39:25 -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
646abeecfe Merge branch 'master' into kotlin 2022-04-13 16:39:12 -04:00
Don Cross
7553b6b749 Windows GitHub Actions: check all steps for errors
I found out in the Kotlin branch that GitHub Actions
only checks for error codes in the last step of the
Windows commands it executes. I moved all the command
line steps into a batch file generate\commit_hook.bat.
It does all the error checking itself.
2022-04-13 16:13:47 -04:00
Don Cross
b4897939cb Merge pull request #201 from ebraminio/kotlin-java
kotlin: Improve access of companions object fields/methods in Java
2022-04-13 08:15:46 -04:00
Don Cross
5c68f20099 Fixed Kotlin build error.
A build error slipped through because both
ebraminio and I were making changes to the Kotlin
code at the same time. Just needed to reorder
the parameters to a call to `search`.
2022-04-12 20:37:26 -04:00
Don Cross
ae3dd35bee GitHub Actions did not check failure in run.bat.
I just noticed a build problem in the Kotlin code
was detected by GitHub Actions in Linux and Mac OS,
but not in Windows. It marked the Windows test as
a success, even though the output clearly shows that
run.bat failed. I theorize that the steps inside
the file .github/workflows/astronomy-engine-tests.yml
are not being checked for errors after each step, but
only after all of them execute. So I have moved them
into a new batch file generate/commit_hook.bat, which
does check each step.

After pushing this change, all 3 builds should fail.
Once I get Windows to fail also, I will fix the failure.
2022-04-12 20:12:05 -04:00
Ebrahim Byagowi
b06493fd6d kotlin: Improve access of companions object fields/methods in Java 2022-04-13 04:25:22 +04:30
Don Cross
5052920517 Merge pull request #200 from ebraminio/kotlin-sam
kotlin: Move search context to the end of arguments
2022-04-12 19:22:18 -04:00
Ebrahim Byagowi
902f25db3f kotlin: Move search context to the end of arguments
This, in addition to annotating SearchContext interface as functional,
turns it into a more idiomatic Kotlin.
2022-04-13 02:53:39 +04:30
Don Cross
4c4aa3dac4 Merge pull request #199 from ebraminio/kotlin-android-demo
kotlin: Upgrade Android example to use the new namings
2022-04-12 17:25:28 -04:00
Don Cross
77b6edd2ff Kotlin: global solar eclipse search
Added functions:
    searchGlobalSolarEclipse
    nextGlobalSolarEclipse

These functions find a solar eclipse that is visible
somewhere on the Earth. They report the time of the
eclipse, what kind it is (partial, annular, total),
and if annular/total, the geographic location where
the eclipse is greatest.
2022-04-12 16:46:40 -04:00
Ebrahim Byagowi
7ad9487c3e kotlin: Upgrade Android example to use the new namings 2022-04-12 23:29:09 +04:30
Don Cross
74cca88d9e Kotlin: lunar eclipse search
Added functions:
    searchLunarEclipse
    nextLunarEclipse

These allow searching for a series of consecutive
lunar eclipses, including penumbral, partial,
and total eclipses.

Added a few extra functions that will be used soon
to search for solar eclipses (global and local) and
transits of Mercury and Venus.
2022-04-12 14:01:22 -04:00
Don Cross
a2fe6c4c38 Kotlin/Windows: fix markdown docs, just like Linux/mac. 2022-04-12 11:17:22 -04:00
Don Cross
55b5287eef Kotlin/Windows: build markdown, not html.
I discovered that the build process on Windows
was still using Dokka to make html, not markdown.
Fixed this to maintain compatibility with the
build process for Linux and Mac OS.
2022-04-12 10:55:20 -04:00
Don Cross
79ff7b2805 Kotlin: Create fatJar during initial build.
Moved the step that creates the fatJar into
the main build process for Kotlin. This is
needed to run the Java demos, and it is good
to fail early if it cannot be built.
2022-04-12 10:37:02 -04:00
Don Cross
3369d09e3f Merge pull request #198 from ebraminio/kotlin-demo-from-local-jar
kotlin: Directly provide the library to demo
2022-04-12 09:02:38 -04:00
Ebrahim Byagowi
6ac0dcbff4 kotlin: Directly provide the library to demo
No longer having jitpack as the middle man and just directly building
demo from the project itself.
2022-04-12 12:06:58 +04:30
Don Cross
57a736067a Kotlin: renamed AstroTime, AstroVector.
Renamed AstroTime to Time.
Renamed AstroVector to Vector.
For some reason this breaks the Java demo build.
I'm pushing the broken build anyway to see if
ebraminio can help me fix it.
2022-04-11 20:17:59 -04:00
Don Cross
4b3b445889 Kotlin: added function angleFromSun. 2022-04-10 20:42:31 -04:00
Don Cross
3dd817934e Kotlin: minor code cleanup.
Changed RotationMatrix.identity from a variable to a function.
I want to leave open the possibility of mutating matrices
in the future, for the sake of performance critical code.
That means it is a good idea to create a new matrix to avoid
unintended side effects.

Removed redundant function equatorFromVector.
It was the same as Vector.toEquatorial.

Moved nextMoonQuarter to be right after searchMoonQuarter.
Somehow other functions had ended up between them.

Simpler syntax for initializing SearchContextPeakAltitude.
2022-04-10 17:23:22 -04:00
Don Cross
b1ebd8d0d7 Kotlin: convert AstroVector to Observer.
Added `AstroVector.toObserver`, which converts a
geocentric equatorial vector (EQJ or EQD) into
a geographic location in an `Observer` object.
2022-04-09 19:41:15 -04:00
Don Cross
3f71bfeb63 Kotlin: convert Observer to StateVector.
Added `Observer.toStateVector` and `Observer.toVector` for converting
an observer's geographic location to position and velocity vectors
relative to the Earth's center.

Reworked the C unit test to output a text file that can be used
as reference, to make sure the Kotlin output matches.
2022-04-09 17:00:36 -04:00
Don Cross
429598e87b Merge worldmap.cpp example into kotlin branch. 2022-04-09 14:17:45 -04:00
Don Cross
83019ff009 Fixed broken build on Mac OS.
I forgot that Mac OS does not have sha256sum
installed by default. This caused the worldmap
demo test to fail, trying to confirm that I got
the output PNG image I expected.
2022-04-09 13:53:30 -04:00
Don Cross
edcf924806 worldmap.cpp demo now finds zenith locations.
The demo worldmap.cpp now also prints out the
geographic locations where the Sun/Moon appear
to be straight up (at the zenith) for the given time.
This illustrates that Astronomy_VectorObserver can
turn a geocentric vector into a location on the
Earth that is in the same direction from the Earth's
center that a given celestial body lies.
2022-04-09 13:12:15 -04:00
Don Cross
5be242400e Made worldmap.cpp demo more efficient.
The worldmap.cpp demo was calculating each pixel's
observer location twice. Now it does so only once.
Added verification that the output PNG file is
exactly as expected, using a sha256 checksum.
2022-04-09 12:57:56 -04:00
Don Cross
1315488c06 Added C++ demo for efficiently globe calculations.
The new demo worldmap.cpp generates a PNG image of
a Mercator projection of the Earth, showing color-coded
intensity of sunlight (yellow) and moonlight (blue).
This sample program shows how to efficiently calculate
horizontal altitudes of the Sun and Moon across many
different geographic locations, for a given observation time.
2022-04-09 12:10:41 -04:00
Don Cross
c254019ebb Merge pull request #194 from ebraminio/kotlin-toplevel-functions
kotlin: Remove Kt suffix from file top level object
2022-04-08 20:22:02 -04:00
Ebrahim Byagowi
a4e662dc32 kotlin: Remove Kt suffix from file top level object 2022-04-09 04:36:38 +04:30
Don Cross
80b8f8c9fa Merge pull request #193 from ebraminio/kotlin-toplevel-functions
kotlin: Turn calculation function to top level declaration
2022-04-08 19:53:39 -04:00
Ebrahim Byagowi
086a1f602d kotlin: Turn calculation functions to top level declaration 2022-04-09 03:59:12 +04:30
Don Cross
b754925e80 Merge pull request #192 from ebraminio/kotlin-sources
kotlin: Include sources artifact in the release
2022-04-08 18:49:26 -04:00
Don Cross
0c4e3dfec3 Fixed #187 - Seasons() fixes from kotlin branch.
Backported fixes to the Seasons functions in
C, C#, Python, and JavaScript. They were failing
to find equinoxes and/or solstices for distant
year values.

Also brought over some other minor code cleanup.
2022-04-08 18:18:45 -04:00
Don Cross
0d24433db3 Fixed #187 - Seasons() failed for distant years.
For years before 1582 or years after 3668, the Seasons functions
were unable to find many equinoxes and/or solstices.
The problem was that over time, the Earth's axis precesses
enough that the calendar dates of these events drifts outside
the fixed search ranges I had provided for them.

I expanded the search ranges so all season changes can be found
for a much wider range of years, as verified by unit tests:

    C/C++:      -2000..9999
    C#:             1..9999
    JavaScript: -2000..9999
    Python:         1..9999
    Kotlin:         1..9999

Note: C#, Python, and Kotlin currently do not allow
years values below +1. In fact, I discovered we were not
noticing when an invalid year was passed into the Kotlin code.
I updated that code to throw an exception when the year does
not match what was expected. It is disturbing that the
GregorianCalendar class silently ignores invalid years!

Constricted the search tolerance from 1 second to 0.01
seconds for the seasons search, to ensure more consistent
behavior.

Fixed a bug in the Kotlin search() function's
quadratic interpolation that was causing the convergence
to be slower than it should have been.
2022-04-08 16:51:09 -04:00
Ebrahim Byagowi
89a711f420 kotlin: Include sources artifact in the release 2022-04-08 17:13:11 +04:30
Don Cross
086542bb41 Merge branch 'ebraminio-kotlin' into kotlin 2022-04-07 15:36:40 -04:00
Don Cross
50ff026da1 Merge branch 'kotlin' of https://github.com/ebraminio/astronomy into ebraminio-kotlin 2022-04-07 15:36:23 -04:00
Don Cross
37d15e5f6a Kotlin: altitude search
Added Astronomy.searchAltitude, which enables more generic
searches for altitude events. The most common use for these
are finding civil, nautical, and astronomical twilight times.
2022-04-07 15:12:08 -04:00
Ebrahim Byagowi
41589a3186 kotlin: Don't run test on jitpack server
Tests needs more bootstrap to work properly and we are doing so in
our CI anyway so let's just exclude test task in jitpack servers.
2022-04-07 23:39:10 +04:30
Don Cross
1d491118e9 Kotlin: implemented search for rise/set, hour angle.
Implemented the following Kotlin functions:

    Astronomy.searchHourAngle
    Astronomy.searchRiseSet

The Kotlin code can now search for rise/set
times for a given Earthbound observer for the
Sun, Moon, or any planet.

It can also search for times when a given body
reaches a desired hour angle. This has its own
value (for example, culmination), but is also
used to assist finding time brackets that bound
rise/set events.

Added special case exception type:
EarthNotAllowedException.
This follows the pattern of the other languages,
and makes diagnosing a violation easier than
the more generic InvalidBodyException.

Minor simplifications to the C# function
Astronomy.InternalSearchAltitude.

Improved the comments for the C# unit test
function RiseSetTest. They make the algorithm
easier to understand.
2022-04-07 11:56:28 -04:00
Don Cross
94c7884f11 Kotlin: added moon phase and search functions.
Added the following Kotlin functions:

    equatorialToEcliptic
    pairLongitude
    moonPhase
    searchMoonPhase
    searchMoonQuarter
    nextMoonQuarter

Discovered I could tighten the tolerance for the moon phase
unit tests from 120 seconds to 90 seconds and they still pass.
2022-04-05 17:33:19 -04:00
Don Cross
fe47dad4a4 Merge branch 'master' into kotlin
Merged some C# fixes from the master branch.
2022-04-05 13:36:58 -04:00
Don Cross
94eabbd4a9 C#: Adding missing checks for unexpected search failures.
There were a few more places where C# code called
Search() but did not check for a search failure.
Throw InternalError exceptions if these ever occur,
because these particular searches should always succeed.
2022-04-05 13:22:50 -04:00
Don Cross
d7e86fae52 C#: Search cleanup, add InternalError exception.
Added an InternalError class to explicitly indicate
that an exception occurs due to an internal assertion
failure inside Astronomy Engine. Any InternalError
should be considered a bug in Astronomy Engine, not
a bug in calling code.

Upon reviewing the code for searching moon phases,
I discovered that there was inconsistent behavior
in SearchMoonPhase. It was sometimes returning null,
other times throwing an exception. Because the caller
passes in `limitDays`, it makes sense to simply
return `null` in any case where the search fails.
This is to support callers that intentionally want
to find whether or not a moon phase occurs in a given
small window of time.

Updated internal callers of SearchMoonPhase to throw
an InternalError when they know they should always
find an event.

Internal function FindSeasonChange did not check to
make sure SearchSunLongitude succeeded. There is no
known case where this failure happens, but if it did,
a null AstroTime would have been stored in SeasonsInfo.
It is better to fail early with an explicit InternalError.

Other miscellaneous C# code cleanup.

In the Python code, I found a couple of `raise Error`
that needed to be changed to `raise InternalError`.
2022-04-05 12:30:13 -04:00
Don Cross
c7bc1a1fe0 Kotlin: fixed formatting of @return doc.
Dokka preserves leading whitespace in the text after
`@return` comments. This causes these fields to render
as preformatted text. Removed the leading whitespace so
this text is rendered as normal markdown.
2022-04-04 12:21:08 -04:00
Don Cross
69bc2e60fc Kotlin: Fixed documentation for return values.
I was using `@returns` in the documentation comments
in Kotlin code, instead of `@return`. Thanks to @ebraminio
for pointing this out.
2022-04-03 20:23:32 -04:00
Don Cross
10bb3f30de Kotlin: implemented seasons search.
Implemented the following related functions in Kotlin:

    sunPosition
    searchSunLongitude
    seasons

C#: fail Astronomy.Seasons with an exception if any of the
equinox/solstice searches fail. If this ever happens, it is
an internal error. It should not be the burden of the caller
to check for nulls!  Fixed mistake in documentation for
searchSunLongitude.
2022-04-03 20:02:11 -04:00