Commit Graph

166 Commits

Author SHA1 Message Date
Don Cross
bb27adfdfa Update C# demo/test projects to dotnet core 7. 2023-06-18 21:04:33 -04:00
Don Cross
5e2292dfa6 Kotlin: added metersAboveGround parameter to searchRiseSet. 2023-03-12 22:10:50 -04:00
Don Cross
6c3a7ab753 C#: Atmosphere, metersAboveGround in SearchRiseSet. 2023-03-12 11:17:47 -04:00
Don Cross
7bb9d02053 C#: Atmosphere function. 2023-03-11 20:23:20 -05:00
Don Cross
1de31cf21f C#: Implemented Observer.ToString(). 2023-02-26 17:08:07 -05:00
Don Cross
ce0acf6d44 Kotlin: support calendar dates for years -999999 to +999999.
Enhanced the Time class to correctly calculate calendar
dates for the year range -999999 to +999999.

Made unit tests in C, C#, and Kotlin all exercise
the full year range, for February 28 and March 1 in each year,
to make sure we cover before and after each potential leap day.
2023-02-26 12:54:57 -05:00
Don Cross
e7d48c6ea7 C#: Fixed bugs with calendar dates with extreme year values.
Fixed problems converting AstroTime to calendar dates and back.
Also expose struct CalendarDateTime to outside callers,
for convenience dealing with Gregorian calendar dates.
2023-02-25 20:23:41 -05:00
Don Cross
88a94b860f C#: Convert times and vectors to/from strings.
Implemented and added tests for the following methods:

    AstroTime.TryParse()
    AstroVector.TryParse()

I still need to implement StateVector.TryParse().

Fixed a bug in CalendarDateTime: the NOVAS cal_date
function worked well, except when years go below
somewhere near -12000. Then the formulas start making
negative numbers, which messes up the calculation
of the month and day.

So to fix this, I figured out that any multiple of
400 years added to any calendar date gives the exact
same calendar date. And 400 years always has the exact
same number of days in it: 146097.

Because one million years = 400 * 2500 years, I can
add 2500*146097 days at the front of the formula
and subtract 1000000 years at the back, and everything
works for the entire range of years plus or minus
one million years from the present.

Because my date format allows for no more than a 6-digit
decimal year, this is perfectly adequate.
2023-02-24 19:49:12 -05:00
Don Cross
f3c211fadb C#: Added StateVector.ToString(). 2023-02-23 22:31:47 -05:00
Don Cross
410708e8b3 C#: Added AstroVector.ToString() function. 2023-02-23 22:06:12 -05:00
Don Cross
43c37c9038 C#: Implemented HourAngle function. 2023-02-12 13:05:29 -05:00
Don Cross
8bf48d0681 Slight relaxation of test tolerances.
Contributor @ris-tip ran into erroneous test failures
due to tiny floating point calculation differences.
I'm adjusting the thresholds slightly so his tests will pass.
2023-02-09 08:37:39 -05:00
Don Cross
1a4f842764 Updated Ecliptic to return ECL in all languages. 2022-12-10 19:35:42 -05:00
Don Cross
47ce0ac34e C#: EquatorialToEcliptic now returns ECT instead of ECL. 2022-12-09 21:03:05 -05:00
Don Cross
f959599497 Completed EQJ/ECT, ECT/EQJ rotations. 2022-12-09 13:12:42 -05:00
Don Cross
78a850daac C# tests: verify EQD/ECT is inverse of ECT/EQD. 2022-12-06 20:09:24 -05:00
Don Cross
f043ebc62b C#: added rotation matrix functions for EQD/ECT. 2022-12-06 18:36:47 -05:00
Don Cross
541e2774ef C# RotationTest cleanup. 2022-12-06 17:04:22 -05:00
Don Cross
552c7a5557 EclipticGeoMoon uses true equinox of date in all languages.
Added EclipticGeoMoon as output to the temp/*_check.txt files as 'm' lines.
This ensures that all the languages calculate nearly identical values.

Optimized EclipticGeoMoon a little more by eliminating a redundant
call to mean_obliq.
2022-12-05 21:44:35 -05:00
Don Cross
d3f36b942d Verify nutation angles are consistent across languages. 2022-12-04 14:20:44 -05:00
Don Cross
15cb6ddc23 Fixed test breakage caused by nutation changes.
C# Test_EQD_HOR: EXCESSIVE HORIZONTAL ERROR:
diff_alt=6.750155989720952E-14, diff_az=8.526512829121202E-14
2022-12-04 11:25:58 -05:00
Don Cross
740a65d29b Windows: fixes for testing nutation changes. 2022-12-04 11:13:24 -05:00
Don Cross
8a153315cf Simplified and optimized nutation formula.
While trying to convert ecliptic coordinates from mean
equinox of date to true equinox of date, I ran into excessive
overhead from the IAU2000B nutation model. The fact that it
uses 77 trigonometric terms made the calculations a lot slower.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document mentions a shorter series
“NOD version 2” that has 13 terms instead of 77 as used in IAU2000B.
I had not noticed NOD2 before, because it appears only in
the FORTRAN version of NOVAS 3.x, not the C version.

After reading the FORTRAN code, I realized NOD2 is the same
as IAU2000B, only it keeps the first 13 of 77 terms.
The terms are already arranged in descending order of
significance, so it is easy to truncate the series.

Based on this discovery, I realized I could achieve all of
the required accuracy needed for Astronomy Engine by
keeping only the first 5 terms of the nutation series.
This tremendously speeds up nutation calculations while
sacrificing only a couple of arcseconds of accuracy.

It also makes the minified JavaScript code smaller:
Before: 119500 bytes.
After:  116653 bytes.

So that's what I did here. Most of the work was updating
unit tests for accepting slightly different calculation
results.

The nutation formula change did trigger detection of a
lurking bug in the inverse_terra functions, which convert
a geocentric vector into latitude, longitude, and elevation
(i.e. an Observer object). The Newton's Method loop in
this function was not always converging, resulting in
an infinite loop. I fixed that by increasing the
convergence threshold and throwing an exception
if the loop iterates more than 10 times.

I also fixed a couple of bugs in the `demotest` scripts.
2022-12-04 10:31:15 -05:00
Don Cross
7b7a306baf Python: Find rise/set/culm of user-defined stars.
Added Python support for user-defined stars.
Defined new StateVector methods: Position and Velocity.
Defined division operator: Vector / float.
Bumped version number to 2.1.12.
2022-11-22 21:42:02 -05:00
Don Cross
fe625c5956 Kotlin: added support for user-defined stars. 2022-11-22 19:29:15 -05:00
Don Cross
a6ddf1880a C#: implemented user-defined stars. 2022-11-22 15:06:04 -05:00
Don Cross
480e0c3ab5 C#: Overhauled altitude search for polar regions.
The C# version of the altitude searches now work correctly
near the Earth's poles. This is a port of the C version.
Cleaned up a little code in the C version.
2022-11-13 12:25:10 -05:00
Don Cross
fd49c25ae3 C#: exported function PlanetOrbitalPeriod. 2022-11-01 17:01:03 -04:00
Don Cross
06b62887d2 Kotlin: obscuration for solar, lunar eclipses. 2022-10-20 17:31:21 -04:00
Don Cross
f6c5bd0bba JS: lunar eclipse obscuration 2022-10-19 14:37:21 -04:00
Don Cross
f7787caf98 C#: solar eclipse obscuration and accuracy enhancements 2022-10-18 20:09:59 -04:00
Don Cross
c798c5015d C#: lunar eclipse obscuration 2022-10-18 16:21:15 -04:00
Don Cross
1e95f0656b C, C#, Python: Support formatting calendar years -999999 to +999999. 2022-10-06 16:28:55 -04:00
Don Cross
1327730324 C# AstroTime no longer limited to years 0000..9999.
The .NET type System.DateTime is limited to the years 0000..9999.
The Astronomy Engine type AstroTime was using System.DateTime to
convert a (year, month, day, hour, minute, second) tuple into a
fractional day value. This caused an exception for years outside
the supported range 0000..9999.

I ported the NOVAS C 3.1 functions julian_date and cal_date to C#,
and removed the dependence on System.DateTime.
Now we can create AstroTime for a much wider range of year values.
Allow converting AstroTime to string for years before 0 and after 9999.
2022-10-05 14:20:14 -04:00
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
6e2229603c Fixed wording, variable names in unit tests. 2022-10-02 12:33:20 -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
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
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
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
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
f014d13910 C# gravsim: finished implementation.
Unit tests are complete and verified for the C# gravity simulator.
I found and fixed one bug in the GravitySimulator constructor.
2022-05-17 17:20:30 -04:00
Don Cross
50c4099184 C#: Jupiter's moons returned by name
It makes more sense to report Jupiter's moons with
individually named structure fields rather than an array.
It reduces the overall code and documentation size,
and outside of unit testing, there are few cases
where iterating over an array of moons is more
lucid than using the names of the moons.

This is a breaking change, but hopefully very few
developers are using this function yet.
Fixing the breakage is very simple.
2022-05-05 11:38:55 -04:00
Don Cross
8696241c90 Kotlin: search for planet aphelion/perihelion.
Added functions:

    searchPlanetApsis
    nextPlanetApsis

I discovered that I had an unnecessary special relaxation
of apsis error tolerance for Pluto. It turns out that currently
0.1 degrees of orbital rotation is enough for all the planets.
2022-04-24 20:55:51 -04:00
Don Cross
a6e72a2423 Kotlin: search for lunar nodes.
Search for times when the Moon ascends or descends
through the ecliptic plane. These are called
ascending and descending nodes. Added the functions:

    searchMoonNode
    nextMoonNode

Also corrected comments in the unit tests that
incorrectly stated nodes occur when the ecliptic
longitude is zero. They should have said the
ecliptic latitude is zero.
2022-04-23 20:34:52 -04:00
Don Cross
3ce32f8819 Kotlin: lunar libration. Fixes for other languages.
The existing lunar libration functions in the
other languages (C, C#, Python, JavaScript) were
calculating the Moon's ecliptic latitude and longitude
in radians, not degrees as intended. They have been fixed.

Implemented the libration function for Kotlin.
2022-04-22 16:36:14 -04:00
Don Cross
567376255c Kotlin: visual magnitude, peak magnitude search.
Implemented the `illumination` function, which calculates
visual magnitude, illuminated phase angle/fraction, and
ring tilt for Saturn.

Implemented `searchPeakMagnitude` for finding when
Venus appears brightest in the sky.
2022-04-20 19:47:21 -04:00
Don Cross
ef6af40b0d Kotlin: added maximum elongation search.
Added searchMaxElongation function, which finds the
next time Mercury or Venus reaches is maximum angular
separation from the Sun.
2022-04-18 13:03:08 -04:00