Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
5000a26049 Use "//" comments in C# code.
Replaced all /* ... */ comments with // comments in C# code,
both the Astronomy Engine library and the unit tests.
2022-10-02 21:47:46 -04:00
Don Cross
dc59b55d92 Added more testing of rise/set foreward/backward searches. 2022-10-02 19:58:48 -04:00
Don Cross
3bb3ce9ab6 C#: more testing of forward/backward altitude search.
Verify that forward and backward searches for sunrises work for
100 start times between a single pair of consecutive sunrises.
2022-10-02 13:44:21 -04:00
Don Cross
a0060c619c C: more testing of forward/backward altitude search.
Verify that forward and backward searches for sunrises work for
100 start times between a single pair of consecutive sunrises.
2022-10-02 13:29:25 -04:00
Don Cross
6e2229603c Fixed wording, variable names in unit tests. 2022-10-02 12:33:20 -04:00
Don Cross
316a49a398 C: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 12:24:46 -04:00
Don Cross
96fffcf2a6 JavaScript: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 11:33:04 -04:00
Don Cross
6c5d4d28bc C#: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 11:14:01 -04:00
Don Cross
a3337348f5 Kotlin: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 10:49:36 -04:00
Don Cross
f0b7b64a4b Python: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 10:13:43 -04:00
Don Cross
b91b1d905f Python: Reverse chrono search for rise/set, hour angles.
The following Python functions now support searching
in forward or reverse chronological order:

    SearchRiseSet
    SearchAltitude
    SearchHourAngle

Made some minor performance improvements to the
other implementations: return sooner if we
go past time window.
2022-10-01 21:44:04 -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
c2bded8605 JS: Reverse chrono search for rise/set, hour angles.
The following JavaScript functions now support searching
in forward or reverse chronological order:

    SearchRiseSet
    SearchAltitude
    SearchHourAngle
2022-09-29 04:33:34 -04:00
Don Cross
cd3013eac9 C#: Reverse chrono search for rise/set, hour angles.
The following C# functions now support searching
in forward or reverse chronological order:

    Astronomy.SearchRiseSet
    Astronomy.SearchAltitude
    Astronomy.SearchHourAngle

Also fixed places where I forgot to update documentation
for the corresponding changes to the C code.
2022-09-29 02:54:13 -04:00
Don Cross
e827c257b4 C: Reverse chrono search for rise/set, hour angles.
The following C functions now support searching
in forward or reverse chronological order:

    Astronomy_SearchRiseSet
    Astronomy_SearchAltitude
    Astronomy_SearchHourAngleEx

The function Astronomy_SearchHourAngleEx replaces
Astronomy_SearchHourAngle, adding a new `direction` parameter.
A #define for Astronomy_SearchHourAngle preserves backward
compatibility for older code.

Implementation notes:

Astronomy_SearchRiseSet and Astronomy_SearchAltitude used
to call a private function InternalSearchAltitude.
That function has been split into two functions:
BackwardSearchAltitude and ForwardSearchAltitude,
for searching both directions in time.

Fixed a bug where it was possible to report a successful
altitude event that went outside the time limit specified
by `limitDays`.
2022-09-28 17:31:35 -04:00
Don Cross
207b8e7f65 Removed incorrect comment in Python code. 2022-09-28 10:12:28 -04:00
Don Cross
add675ea09 C, TypeScript: code cleanup in Search function.
The quadratic interpolator used by `Search` was returning
an unused output: `x`. Search does not need this dimensionless
value; it only cares about the time solution `t` and the slope
of the function at `t`. Removed `x` from the return value
to make slightly smaller/faster code.
2022-09-27 17:14:36 -04:00
Don Cross
53b4b33958 Kotlin searchMoonPhase: allow searching backward in time.
Enhanced the Kotlin function searchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 22:07:47 -04:00
Don Cross
3bed4a9bdc PY SearchMoonPhase: allow searching backward in time.
Enhanced the Python function SearchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 21:08:37 -04:00
Don Cross
424b267007 JS SearchMoonPhase: allow searching backward in time.
Enhanced the JavaScript function Astronomy.SearchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 20:25:35 -04:00
Don Cross
c6f0561363 C# SearchMoonPhase: allow searching backward in time.
Enhanced the C# function Astronomy.SearchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 19:34:22 -04:00
Don Cross
1718da47e4 C SearchMoonPhase: allow searching backward in time.
Enhanced the C function Astronomy_SearchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 18:56:58 -04:00
Don Cross
fc21b4c0f1 Prevent use of -Ofast optimization in gcc.
The C version of Astronomy Engine does not work correctly
when gcc "fast math" optimizations are enabled.
The problem is that Astronomy Engine uses NAN values to
represent invalid/uninitialized floating point numbers.
The -Ofast option breaks the ability of the runtime to
check for NAN values, resulting in multiple failures
and incorrect behaviors at runtime.

Added a compile-time check for the __FAST_MATH__ preprocessor
symbol, which gcc defines to signal that the optimization
was enabled. If detected, this results in a compiler error
to make it obvious that something is wrong before invalid
code would be executed.

This is not an ideal fix for two reasons:

1. I don't know if this will detect similar problems for
   other compilers than gcc.

2. If individual risky math optimizations are enabled, instead
   of the combination of options included in -Ofast, the
   __FAST_MATH__ preprocessor symbol will not be defined
   and no compiler error will occur. I could not find a
   way to detect individual risky optimizations.

However, this change is much better than nothing, and
hopefully it will prevent most cases of overly-aggressive
optimization.
v2.1.3
2022-09-22 11:28:56 -04:00
Don Cross
18a0c5613d Increase JVM memory allowance for Gradle.
I encountered a build/test failure in the Kotlin
code due to the JVM running out of memory.
I configured gradle to allow using more memory:
1GB instead of the default 256MB.
2022-09-22 11:08:40 -04:00
Don Cross
d21ce79976 Updated version number to 2.1.3. 2022-09-22 10:25:47 -04:00
Don Cross
e9cf2a0417 Python: changed true to True in documentation.
There were two places in the Python documentation
where I wrote `true` instead of `True` for the
boolean literal. These have been fixed.
2022-09-10 19:13:53 -04:00
Don Cross
afd6f4835f Kotlin: reworked VSOP model selector as a function. 2022-09-10 16:20:03 -04:00
Don Cross
3fad9d0c2b Merge branch 'ebraminio-resolve-cyclic-dependency' 2022-09-10 14:18:46 -04:00
Ebrahim Byagowi
8ed7de7923 Resolve cyclic dependency of Body.vsopModel
Definition of vsopModel constant on Body enum items constructors
makes cyclic dependency with constants defined later in the code
and makes application crash when things are not initiated in the
correct order.

This fixes the issue by turning vsopModel into a property which
will have almost the same internal API for the rest of the code
and resolves crashes I'm getting when certain part of my app
is initiated sooner than usual.
2022-09-10 14:31:40 +04:30
Don Cross
f187bc3e22 Fixed mistake in Python enum for not correcting refraction.
GitHub user `hidp123` submitted the following pull request:
https://github.com/cosinekitty/astronomy/pull/240

The problem was I had documentation for the Python enum
`Refraction` where I incorrectly wrote `Refraction.None`
instead of the correct name `Refraction.Airless`.

The fix in the pull request was correct, but it was
applied to generated source code, so it did not correctly
update the template file or the online documentation.

This commit fixes the mistake in all the affected files.
2022-09-07 18:39:31 -04:00
Don Cross
1012bca47f makedoc.bat was not running Python programs.
In the Windows build process, I finally realized why
I was having so much trouble sorting JavaScript
functions in the generated markdown documentation.
The script `makedoc.bat` had several cases where
I thought I was running Python programs, but I wasn't.

On my own Windows system, I can do something like:
program.py args...
And it runs the program. But in the GitHub Actions
environment, not only does this NOT run the program,
it leaves the errorlevel at 0, so I don't detect
anything bad happened.

In `run.bat`, I had already made this work by doing:
py program.py args...

Following suit in `makedoc.bat`. Hopefully this finally
works! It is also scary that all along, I wasn't running
several steps in the build process for Windows
and I had no way to detect it.
2022-07-22 13:25:59 -04:00
Don Cross
4f4dba70a3 Another attempt to fix JS func sorting in Windows. 2022-07-22 12:30:44 -04:00
Don Cross
935c4ac403 Help debug file diff in Windows build failure. 2022-07-21 21:43:21 -04:00
Don Cross
455121f79e Fixed JS doc sort for Windows build.
I forgot to add the new step for sorting
JavaScript functions in the generated markdown
documentation. I added the same step to makedoc.bat.
2022-07-21 18:50:30 -04:00
Don Cross
a1c3f6be52 JS documentation: sort functions alphabetically.
The JavaScript functions were appearing in unsorted
order in the markdown documentation.
The `jsdoc2md` tool does not have an option for sorting them.
So I wrote a new script `sort_js_functions.py` that post-
processes the markdown to sort the functions.
2022-07-21 17:36:17 -04:00
Don Cross
1322e48cd1 Merge pull request #232 from cosinekitty/dependabot/npm_and_yarn/generate/shell-quote-1.7.3
Bump shell-quote from 1.7.2 to 1.7.3 in /generate
2022-06-23 08:34:49 -04:00
dependabot[bot]
7a1e186d11 Bump shell-quote from 1.7.2 to 1.7.3 in /generate
Bumps [shell-quote](https://github.com/substack/node-shell-quote) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/substack/node-shell-quote/releases)
- [Changelog](https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md)
- [Commits](https://github.com/substack/node-shell-quote/compare/v1.7.2...1.7.3)

---
updated-dependencies:
- dependency-name: shell-quote
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 11:06:25 +00:00
Don Cross
ee35d1f0c3 Removed unused variable in ctest.c.
This was causing a warning-as-error in some compilers.
2022-06-11 16:04:18 -04:00
Don Cross
e187707412 Patch version numbers using a Python program.
It turns out that "sed" does not work on Mac OS,
and I wasn't even trying to patch the version
numbers on Windows. I decided to write a Python
program for this task, so it will work identically
on all 3 operating systems.
2022-06-05 15:03:02 -04:00
Don Cross
1e9f1a7b05 Automatically patch version number.
Added a new file generate/version.txt that contains
the current Astronomy Engine version number.
Now when I run the build/test process, the version
number is patched in all the places it needs to
be changed to keep all the packages and documentation
up to date.

This means when I want to change the Astronomy Engine
version number, I just need to edit version.txt, then
execute the generate/run script.
2022-06-05 14:07:32 -04:00
Don Cross
2a1abad0d5 Better use of package badges/links.
Provide shield.io badges for pypi, npm, and nuget packages.
On the main README page, moved the badges into the supported
languages grid.
Added link and badge on each language documentation page.
2022-06-05 12:42:00 -04:00
Don Cross
6425e4ef11 C#: More benefits from using netstandard2.0.
Now that I have retargeted astronomy.csproj from
net5.0 to netstandard2.0, there are a couple of
other little improvements that are now possible:

1. In my manual Framework 4 test project, instead
   of directly pulling in the source file astronomy.cs,
   add astronomy.csproj as a project reference.
   This demonstrates that the same binary astronomy.dll
   works in both Framework and Core.

2. Now there is no need/use for conditional compilation
   directives in the Astronomy.CubeRoot function.
   Instead, always use my own implementation since the
   Math.Cbrt function is never available.
   From a testing standpoint, this was probably
   the better option all along.
2022-06-05 10:07:35 -04:00
Don Cross
f3b273a973 First attempt at C# NuGet package.
https://www.nuget.org/packages/CosineKitty.AstronomyEngine/2.1.2

This is my first attempt at publishing a NuGet package.
I have never done this before, so I'm not sure it is going to work.
Changed astronomy.csproj to target netstandard2.0, which still
works fine with all my net6.0 unit tests.
2022-06-04 22:01:36 -04:00
Don Cross
476fb794c4 Fixed #217 - generic light travel correction.
Bumped version to 2.1.2.
v2.1.2
2022-06-01 20:21:19 -04:00
Don Cross
b7979cb7a0 Light travel correction: improved documentation. 2022-06-01 19:25:48 -04:00
Don Cross
d7d68de068 Use light travel corrector in raytrace demo.
Simplified the Jupiter moon raytraced image demo
by using Astronomy_BackdatePosition to directly
calculate the vector while returning the backdated
time directly. This eliminates a redundant calculation
using the distance divided by the speed of light.
2022-06-01 18:41:25 -04:00
Don Cross
5e7162f08d GeoVector must return observation time.
Fixed 3 of the language implementations where I forgot
to make GeoVector return the observation time, not the
backdated time. This is important to preserve existing
behavior.
2022-05-31 21:26:03 -04:00
Don Cross
409451b3c2 Kotlin: light travel time correction. 2022-05-31 20:52:41 -04:00
Don Cross
9afbf0a67f Python: generalized light-travel correction. 2022-05-30 21:37:19 -04:00
Don Cross
765c39d3fa JS: generalized light-travel time correction. 2022-05-30 19:27:25 -04:00