Commit Graph

2227 Commits

Author SHA1 Message Date
Don Cross
887a200ac8 Cleaned up kotlin_language.svg. 2022-03-21 15:24:43 -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
Don Cross
8fd8d7b624 Kotlin AstroTime: millisecond resolution, ISO 8601
Allow floating point values for seconds when initializing
an AstroTime from (year, month, ..., seconds).
AstroTime can now represent date/time to millisecond resolution.

Represent AstroTime strings in ISO 8601 format:
yyyy-mm-ddThh:mm:ss.sssZ

Minor docstring fixes.

Rename target file to 'astronomy.kt'.
2022-03-21 13:28:49 -04:00
Don Cross
7a6c8e62bb Fixed broken build - updated template Kotlin.
Code changes need to be made to

    generate/template/astronomy.kt

and then the target code Main.kt is written by
the code generator. Then both must be committed to git
before pushing to GitHub.
2022-03-21 10:34:16 -04:00
Don Cross
9d76ef3619 Merge pull request #170 from ebraminio/kotlin
Make AstroTime class Kotlin's port complete and port TerseVector
2022-03-21 09:42:07 -04:00
Ebrahim Byagowi
f8771922d3 kotlin: Drop .0 where isn't needed 2022-03-21 15:25:29 +03:30
Ebrahim Byagowi
c9f4ce46e7 kotlin: Replace repetitive ifs with when 2022-03-21 15:21:47 +03:30
Ebrahim Byagowi
46e3088dd0 kotlin: Port TerseVector 2022-03-21 14:31:26 +03:30
Ebrahim Byagowi
88b2a38651 kotlin: Move AstroTime primary constructor to top level
This is more idiomatic Kotlin.
2022-03-21 14:11:04 +03:30
Ebrahim Byagowi
a4fc126a08 kotlin: Implement AstroTime.addDays 2022-03-21 13:55:18 +03:30
Ebrahim Byagowi
adf7b7a991 kotlin: Implement AstroTime toString 2022-03-21 13:48:06 +03:30
Ebrahim Byagowi
60e470b9c3 kotlin: Implement AstroTime.fromTerrestrialTime 2022-03-21 12:50:25 +03:30
Ebrahim Byagowi
e786e8af65 kotlin: Port other AstroTime constructors 2022-03-21 12:36:50 +03:30
Ebrahim Byagowi
6839240b18 kotlin: Use object instead explicit instancing 2022-03-21 11:42:48 +03:30
Ebrahim Byagowi
cd1617e47f kotlin: Minor style fixes
* Drop unnecessary semicolons
* Turn var to val where possible
2022-03-21 11:41:52 +03:30
Don Cross
2d0abac818 Reformatted Kotlin source code. 2022-03-20 20:59:01 -04:00
Don Cross
8093ceff2a Kotlin: started class AstroTime, delta-t calc. 2022-03-20 20:54:33 -04:00
Don Cross
a278a893ff Merge branch 'master' into kotlin
This brings in recent fixes to the Python
pip package build process.
2022-03-20 20:00:43 -04:00
Don Cross
74044b39d3 More Python/pip package cleanup : version 2.0.17.
Generate astronomy.py directly in the package directory.
I realized it doesn't make sense to generate it in the
parent directory and then copy it; just generate it where
it will end up anyway.

Updated documentation so people know they can just do

    pip install astronomy-engine

to install Astronomy Engine in their Python project.

Removed the GitHub Actions status badge because it is redundant with
the checkmark/X indicator.

Now that private symbols are no longer exported, I had to
fix a couple of places where the unit tests still accessed them.
2022-03-20 16:47:29 -04:00
Don Cross
8963fb7b69 Hide private symbols in Python package.
I realized that the way I structured the pip package
in version 2.0.15 made the private symbols (those whose
names begin with an underscore) to be visible by the importer.
I reworked the package structure so this no longer happens.

This is now fixed in:
https://pypi.org/project/astronomy-engine/2.0.16/
2022-03-20 14:24:00 -04:00
Don Cross
2a92ad70c0 Fixed pip package. Added SiderealTime to pip, npm.
The pip package was broken!
I violated ancient software development wisdom:
"If you haven't tested it, it doesn't work."
It is now working in:

https://pypi.org/project/astronomy-engine/2.0.15/

Version 2.0.15 of Astronomy Engine for Python (pip)
and Node.js (npm) add support for the new SiderealTime
function. This was previously an internal function,
but now it is exposed for outside callers.
2022-03-20 13:42:16 -04:00
Don Cross
e92cf212f2 Added Kotlin to source code generator.
This is just a stub to get started. None of the
necessary macros have been implemented in the Kotlin
code generator. But at least I can start editing the
Kotlin template and generating code from it.
2022-03-18 20:28:14 -04:00
Don Cross
0f0fab513a Kotlin: implemented Body enum with code docs.
Implemented the Body enum, with documentation strings
in comments. Reworked the Gradle build to generate
GitHub Flavored Markdown (gfm) instead of html.
2022-03-18 20:10:51 -04:00
Don Cross
ff16ae0a90 Windows Kotlin build: need to call gradlew.bat.
Because the 'gradlew' command is a batch file in
Windows, I need to use the 'call' command to invoke
it from run.bat, or it does not return to run.bat.
2022-03-18 07:31:46 -04:00
Don Cross
a0723c7406 Kotlin build/test integrated with 'run' scripts.
Instead of being executed directly by the GitHub Actions
yml file, the Kotlin build now has been integrated with
the build/test steps for the other 4 languages in the
bash script `generate/run` and the Windows batch file
`generate/run.bat`. This will be necessary to control the
order of execution, because the Kotlin source code will have
to be written by the code generator before it is built
and executed.

I also added hints for myself and other contributors about
how to set up Kotlin/JDK tools on a new developement machine.
These instructions are not needed by most users of Astronomy Engine,
just contributors.
2022-03-17 20:52:32 -04:00
Don Cross
0943f058c9 Fixed #165 - expose sidereal time function.
There was already an internal function for calculating
Greenwich Apparent Sidereal Time (GAST). By request,
I have exposed this function for outside users.

Added a minimal unit test to verify the function is
callable and returns the correct result for one case.
This function is already exhaustively tested by unit
tests that verify other functions that already called
this function when it was internal, so minimal testing
is sufficient in this case.
2022-03-15 20:48:02 -04:00
Don Cross
f0fe2f42ce Merge pull request #168 from ebraminio/kotlin
Enable Kotlin testing in macOS and Windows
2022-03-15 19:27:32 -04:00
Ebrahim Byagowi
34bf5f1497 Enable Kotlin testing in macOS and Windows 2022-03-16 01:54:27 +03:30
Don Cross
4a63ff45cf Merge pull request #167 from ebraminio/master
Add Kotlin project structure
2022-03-15 14:10:20 -04:00
Ebrahim Byagowi
01a0a89109 Add Kotlin project structure 2022-03-15 21:37:42 +03:30
Don Cross
1a645fea18 Bumped npm,pypi versions to 2.0.13 to test publish.
The way I was publishing the Python package was annoying.
I found a better way to authenticate myself to pypi.org,
but I needed to test it. This required bumping the version
numbers of the packages. There is no difference between
2.0.12 and 2.0.13.
2022-03-14 05:09:56 -04:00
Don Cross
bc42d609c1 Updated pip, npm packages to v 2.0.12.
This version of the Python and Node.js packages includes
support for calculating Lagrange points.
Also added a pypi.org badge to the main README.md.
2022-03-14 04:46:44 -04:00
Don Cross
d843775122 Fixed #148 - calculate Lagrange points.
Added the following new functions to all 4 languages:

MassProduct: find the GM product for all Solar System bodies.

LagrangePoint: calculate L1..L5 state vectors for a pair of bodies.

LagrangePointFast: calculate L1..L5 state vectors given
state vectors and GM products of a pair of bodies.
2022-03-13 20:56:32 -04:00
Don Cross
b773834349 Implemented Python Lagrange point calculation. 2022-03-13 17:47:40 -04:00
Don Cross
13413f2754 Prep Python unit tests for Lagrange.
Reworked the Python state vector unit tests so that they will
be ready for adding Lagrange point tests, which require
additional parameters.
2022-03-13 09:45:48 -04:00
Don Cross
eba8c2e87f Implemented JavaScript Lagrange point functions. 2022-03-12 20:31:07 -05:00
Don Cross
e4665f4669 JS tests: refactored StateVector tests.
Reworked the tests that use JPL Horizons output files containing
state vectors so that they generalize to different parameters.
Specifically, soon I will need to pass in (major_body, minor_body,
point) to support Lagrange point tests.
2022-03-12 18:06:58 -05:00
Don Cross
45dbdd87d4 Implemented C# Lagrange point functions. 2022-03-12 17:08:56 -05:00
Don Cross
4ce1bb8a6b C# test: refactored JPL state vector loader.
I want to be able to re-use the code for loading state
vectors from a JPL Horizons text file, instead of copy-n-paste
like I did in C. So I reworked it as an iterator.
2022-03-12 11:30:22 -05:00
Don Cross
a1ec0b730c ctest.c: fixed function names in error messages.
There were a few places inside the unit test function LoadStateVectors
where I had error messages that printed the wrong function name
(VerifyStateBody instead of LoadStateVectors) if an error was detected.
This is because of a copy-n-paste oversight. They are fixed.
2022-03-12 11:28:04 -05:00
Don Cross
1ad336be37 Fixed #158 - Use hypot function where appropriate.
In languages that support it, using hypot(x,y) is a little
easier to read than sqrt(x*x + y*y). Some documentation
(e.g. the man page for the C function) leads me to believe
hypot might also be better behaved than sqrt in some cases.

The JavaScript Math.hypot() is especially nice because it works
for any number of dimensions, so I can use it in 2D and 3D cases.

C only allows 2D usage, as does Python 3.7. Python 3.8 added
support for any number of dimensions, but I don't want to break
compatibility with Python 3.7 just yet. Therefore, in C and Python,
I am only using hypot for 2D cases.

C# does not appear to have any kind of hypot function,
so no changes were made to the C# code.

Thanks to https://github.com/ebraminio for this suggestion.
2022-02-21 13:30:13 -05:00
Don Cross
871389c9cf Fixed C# .NET Framework 4 compile error.
There is no function double.IsFinite() in .NET Framework.
Reworked the sanity check in Astronomy.Pivot so the C# code
builds in these older .NET platforms.
2022-02-21 10:54:01 -05:00
Don Cross
5744c9ebe9 Moon phase demos also calculate illuminated fraction.
The phrase "Moon phase" is ambiguous, because sometimes
it means relative ecliptic longitude, other times it means
illuminated fraction. The "moonphase" demos were only
calculating the relative ecliptic longitude, which was
confusing. Now they calculate both.
2022-02-20 15:27:46 -05:00
Don Cross
31f36f2ef8 Fixed #159 - unmangle markdown for C #defines.
My custom Markdown documentation generator for C had
a bug when emitting the listing of a #define.
It is not valid to try to hyperlink to other symbols,
because the Markdown syntax gets listed literally inside
the context of a C code block.
2022-02-19 19:19:01 -05:00
Don Cross
19a66caea2 Miscellaneous cleanup of C documentation. 2022-02-19 18:42:25 -05:00
Don Cross
3952ebd9af C Lagrange: Add simpler-to-use function for most cases.
In most cases, people calculating Lagrange points will just
want to pass in the bodies and not have to worry about calculating
their state vectors and masses.

Renamed Astronomy_LagrangePoint to Astronomy_LagrangePointFast.
Added new function Astronomy_LagrangePoint that accepts body enum
values instead of state vectors and masses. It knows to optimize
the precision of the calculation by calling GeoMoonState for the
Earth/Moon case.
2022-02-19 14:24:20 -05:00
Don Cross
d0693f972d Loosened tolerances on VerifyEquilateral Lagrange test for Mac.
I confirmed that the Mac version of GitHub Actions does not
flush stderr on exit, so that is why I couldn't see my
diagnostic error messages. Now I can tell VerifyEquilateral
is failing due to a slightly out of bounds length ratio
in the Earth/Moon/M4 equilateral triangle. Made the tolerance
window a little larger, and trying again.
2022-02-19 12:29:26 -05:00
Don Cross
030cc8f3d3 Testing theory: Mac does not flush stderr on exit. 2022-02-19 11:35:21 -05:00
Don Cross
aa3821cbf2 More guesswork to diagnose GitHub Actions failure on Mac. 2022-02-19 11:09:05 -05:00
Don Cross
0d1561a9d8 Still tracking down why VerifyLagrangeTriangle fails on Mac. 2022-02-19 05:18:16 -05:00