Commit Graph

1235 Commits

Author SHA1 Message Date
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
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
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
Don Cross
53c8d7145a Publish generated Kotlin documentation to GitHub.
Merge a custom Markdown prefix with documentation
generated by dokka from Kotlin source code into
the published GitHub page. See the new script:

    generate/kotlindoc/format_kotlin_doc.py

The result is not yet quite what I want, but it
is much better than nothing.

Things to improve:

The `object Astronomy` link should not be hidden
in the middle of the other types. It should be
expanded and promoted to the top level.
2022-03-23 20:36:00 -04:00
Don Cross
40e0fb7b4f Kotlin: Another batch of functions ported.
Converting between radians and degrees.
Clamping angles to a desired range of degrees.
Converting between vector, spherical, horizontal.
Refraction and inverse refraction.
2022-03-23 17:21:37 -04:00
Don Cross
94aba0240a Kotlin: rotate a state vector.
Bootstrapped the function for rotating a vector
to rotate a state vector (position and velocity combined).
2022-03-23 14:36:42 -04:00
Don Cross
b0929b1b49 Kotlin: added rotation matrix functions and unit tests.
Implemented most of the RotationMatrix functions.
Added unit tests for combining rotation matrices, using a
rotation matrix to rotate a vector, and pivoting a rotation
matrix around its axes.

Replaced AstroVector operator '*' with infix function 'dot',
because it removes ambiguity between vector dot products
and vector cross products.
Later I will add a 'cross' infix function too.

Corrected minor typo in documentation for Python, C, C#, JavaScript.
"trasnform" -> "transform"
2022-03-23 14:25:32 -04:00
Don Cross
9e343aef8a Kotlin: Minor code cleanup.
Moved Astronomy object to bottom of source file.
This object is going to end up with a lot of functions,
so it's best to keep outer classes above it.

Removed unnecessary empty {} after classes.

Replace Array<Array<Double>> with Array<DoubleArray>.
This is more efficient because Array<Double> boxes the numbers
inside it, whereas DoubleArray is unboxed.
2022-03-23 12:31:43 -04:00
Don Cross
79d66bb00b Kotlin: added a few more type definitions.
StateVector
JupiterMoonsInfo
RotationMatrix
Spherical
Observer
EquatorEpoch
Aberration
Refraction
Direction
Visibility
Equatorial
2022-03-22 20:52:07 -04:00
Don Cross
8a9e30a888 Kotlin: Added AstroVector class. 2022-03-22 17:07:02 -04:00
Ebrahim Byagowi
a17456514e kotlin: Use Kotlin test and its asserters
It provides more idiomatic asserters to Kotlin.
2022-03-22 19:30:41 +04:30
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
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
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
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
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
eba8c2e87f Implemented JavaScript Lagrange point functions. 2022-03-12 20:31:07 -05:00
Don Cross
45dbdd87d4 Implemented C# Lagrange point functions. 2022-03-12 17:08:56 -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
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
5e3faef062 C Lagrange: simplify logic using cross products.
It is conceptually simpler to take cross products to
generate 3 coordinate axes (essentially a rotation matrix)
that represent radial, tangential, and normal directions
with respect to the major and minor bodies.
2022-02-17 18:47:05 -05:00
Don Cross
35f8a45d53 C Lagrange: fixed mass parameter comments. Clarified algorithm. 2022-02-16 22:13:23 -05:00
Don Cross
2616880835 C Lagrange Points: almost there!
Now correctly calculating L4 and L5 positions, but
there is a large error in their velocity vectors.
Refactored ctest.c LagrangeTest() to be a lot easier
to understand and modify. A new function VerifyStateLagrange()
allows passing test parameters in a more function-oriented way.

Confirmed that L4 and L5 always lie in the same plane with
the position vector and velocity vector.
2022-02-16 11:35:01 -05:00