Commit Graph

218 Commits

Author SHA1 Message Date
Don Cross
296f23af76 Libration functions now calculate apparent angular diameter of the Moon.
All 4 languages have added a `diam_deg` field to the
structure returned by the Libration function.
It is the apparent angular diameter of the Moon as
seen from the center of the Earth, expressed in degrees.
2021-11-05 16:02:14 -04:00
Don Cross
eab9c275b9 Implemented lunar libration function for JavaScript. 2021-11-05 14:46:56 -04:00
Don Cross
adf65e1f1f Throw an exception for invalid refraction option.
In JavaScript and Python, throw an exception if provided
an invalid refraction option. Especially in JavaScript,
it was too easy to pass in a value like 'true', which did
not calculate refraction as expected.
2021-10-12 14:31:13 -04:00
Don Cross
42240288b0 JS SearchAltitude: improved documentation and parameter checking. 2021-09-23 10:43:20 -04:00
Don Cross
24571444d9 JS SearchAltitude implemented.
Refactored SearchRiseSet to create a new function
InternalSearchAltitude. SearchRiseSet calls InternalSearchAltitude,
and the new function SearchAltitude also cals InternalSearchAltitude.
This causes the code to be only a tiny big larger.
2021-09-22 19:45:33 -04:00
Don Cross
dc5bb5317b No longer assume typescript is installed globally.
The unit tests for the calendar.ts demo program
assumed that the 'tsc' typescript compiler was
installed globally. Redirect it to the typescript
installed in the 'generate' folder.

I could have just made typescript a dependency,
but it seemed wasteful of disk space to have two
copies of the same thing (it is currently 54MB).
2021-09-18 21:59:06 -04:00
Don Cross
b32b2705ee Fixed JS doc formatting mistake.
The formatting of the JS documentation for class
GlobalSolarEclipseInformation was messed up in the
generated Markdown file. Fixed that issue in the
JS comments.

Bumping npm version to 2.0.6, to include recent
barycentric state and Earth gravity calculations.
2021-07-23 19:25:03 -04:00
Don Cross
a9479832dd JavaScript ObserverGravity function. 2021-07-19 17:27:33 -04:00
Don Cross
131638a964 equator_of_date.js demo now corrects aberration. 2021-07-14 21:54:58 -04:00
Don Cross
e398aa43a4 JS: Implemented BaryState function.
Ported the C version of BaryState to JavaScript.

Fixed an issue in both the C and JS unit tests:
the JPL Horizons data is given in terms of TT, not UT.
2021-07-11 19:40:27 -04:00
Don Cross
b005bdef5a Starting to implement generalized aberration.
I realize some use cases require adjustments for
stellar aberration. The existing aberration adjustments
are only supplied for calculating planet positions.
Some users will benefit from being able to add/subtract
aberration corrections to arbitrary vectors, including
for star positions.

I have added some JPL Horizons test data to help
validate the aberration functionality I'm about to add.
I created the beginning of a unit test in ctest.c,
but currently there is no aberration correction
implemented, so the test has no error threshold.
2021-07-09 20:31:23 -04:00
Don Cross
5ea2bf65a1 equator_of_date.js defaults to current date/time.
Allow this demo to use the current date and time by
default if the user does not specify one on the command
line. This required changing the order of the command line
parameters.
2021-07-06 20:58:31 -04:00
Don Cross
7d955c99ba Added demo program equator_of_date.js.
Given the right ascension and declination of a star,
expressed in J2000 coordinates, this demo converts those coordinates
to right ascension and declination expressed in the Earth's
equator at any given date and time. This example illustrates
how to use rotation matrices to convert one coordinate system
to another.

This example was prompted by the question at:

https://github.com/cosinekitty/astronomy/discussions/114
2021-07-06 20:21:07 -04:00
Don Cross
87926a71c1 Implemented C# 'triangulate' demo. Added doc links. 2021-06-22 13:51:14 -04:00
Don Cross
50019fafce Implemented JavaScript 'triangulate' demo. 2021-06-22 11:45:07 -04:00
Don Cross
a28aa5c3d9 One more documentation fix for JavaScript. 2021-06-21 21:20:05 -04:00
Don Cross
95960a962a Documentation fixes for JavaScript. 2021-06-21 20:56:38 -04:00
Don Cross
8abda4ea30 Documentation fixes for VectorObserver functions. 2021-06-21 20:23:33 -04:00
Don Cross
90f5ea367e JS: Implemented VectorObserver. 2021-06-21 16:45:59 -04:00
Don Cross
52fb59b32e Python: Implemented EQJ/GAL conversions.
Ported conversion to/from galactic coordinates to Python.
Added unit test for new Python code.
Updated documentation for all 4 supported languages.
Fixed mistakes in JavaScript function documentation.
2021-06-10 20:48:11 -04:00
Don Cross
15988c87df Ported GAL/EQJ conversion to JavaScript. 2021-06-09 21:11:30 -04:00
Don Cross
1396367524 Made minified JS browser code a little smaller.
Decreased the minified browser code from 94115 bytes to 94098 bytes.
Eliminated unncessary braces, used ternaries instead of 'if', etc.
2021-05-18 21:54:03 -04:00
Don Cross
efc6e7bdf9 Fixed broken build caused by improper branch merge.
When I merged from calendar2 branch into master branch,
I forgot to run the unit tests locally and commit the
code generation changes it caused. This has been fixed.
2021-05-16 14:29:30 -04:00
Don Cross
3e420e9e32 Merge branch 'calendar2' 2021-05-16 14:05:00 -04:00
Don Cross
7db556046b Calendar demo: planet constellations. 2021-05-16 13:32:19 -04:00
Don Cross
d5fb13d35c I forgot to check in updated calendar output. 2021-05-16 13:18:00 -04:00
Don Cross
5afeab6b02 Calendar demo: Sun, Moon culmination. 2021-05-16 12:25:57 -04:00
Don Cross
d950eaaa55 Calendar demo: planet perihelion and aphelion. 2021-05-16 12:15:24 -04:00
Don Cross
d87a42446f Calendar demo: added lunar apogee and perigee. 2021-05-16 12:04:18 -04:00
Don Cross
c4c90c9c22 Cleaned up JavaScript code and made minified version a little bit smaller. 2021-05-15 21:52:20 -04:00
Don Cross
08247921b5 Calendar demo: include transits of Mercury and Venus. 2021-05-15 20:45:30 -04:00
Don Cross
3220fb030d Calendar demo: include local solar eclipse predictions. 2021-05-15 20:32:29 -04:00
Don Cross
51235fbffd Calendar demo: include lunar eclipse predictions. 2021-05-15 20:00:55 -04:00
Don Cross
eefcce91e0 Calendar demo: added comments for remaining tasks. No code changes. 2021-05-13 20:28:51 -04:00
Don Cross
37c35737af Calendar enumerator demo: find times when Venus appears brightest. 2021-05-13 20:22:44 -04:00
Don Cross
629317e9ff Calendar enumerator demo: max elongations of Mercury and Venus.
Added event enumerators for when Mercury and Venus appear
at the maximum angle from the Sun as seen from the Earth.
2021-05-13 20:06:39 -04:00
Don Cross
31b71ac97f Calendar enumerator: added planetary conjunctions and oppositions.
The calendar enumerator demo now includes inferior and superior
conjunctions of the inner planets (Mercury and Venus), along
with the conjunctions and oppositions of the outer planets
(Mars ... Pluto).
2021-05-13 19:32:03 -04:00
Don Cross
23eb42f951 Removed unnecessary and risky method EventCollator.Append().
Once a collator has been created, and a caller starts
enumerating events, it does not make sense to be able to add
another enumerator to the collator. So I removed EventCollator.Append().
It was just opening up the possibility of bugs for no good reason.

Client code should decide up front what kind of events it wants
to enumerate and provide a complete list of enumerators.
Then it may use FindFirst/FindNext as many times as it wants
and everything will just work.
2021-05-12 20:36:32 -04:00
Don Cross
953ffef7a8 Calendar demo: added a moon quarter enumerator.
Added MoonQuarterEnumerator, which finds new moon, first quarter,
full moon, and third quarter events.
Changed the calendar start date to May 2021, so it is
more relevant to the time I'm testing it.
2021-05-12 19:54:09 -04:00
Don Cross
04ebd129dd Calendar demo now includes seasons. Also goes for 10 years instead of 1.
Generate solstices and equinoxes in the calendar event enumerator.
Generate 10 years of data instead of 1, to better test the seasons.
2021-05-12 19:37:34 -04:00
Don Cross
03f4e91bb9 Rough demo for how calendar enumerator will work.
This is an example of how multiple enumerators can be combined
into an EventCollator. The collator does the minimum amount
of work to keep searching for one event at a time, while always
emitting them in chronological order.
2021-05-12 19:00:21 -04:00
Don Cross
bba5b0b616 Calendar demo: apparently I don't need astronomy.d.ts for this to work. 2021-05-10 16:37:40 -04:00
Don Cross
398e8115c7 Added the new calendar demo to the JavaScript self-tests. 2021-05-09 21:00:54 -04:00
Don Cross
f299d15fd9 Starting to figure out how to make an Astronomy Engine demo in TypeScript. 2021-05-09 20:57:13 -04:00
Don Cross
1f2444c891 Starting to create a calendar event enumeration demo. 2021-05-09 18:11:00 -04:00
Don Cross
a57f8fc98e Made minified JS browser code a little smaller.
Decreased the minified browser code from 94918 bytes to 94221 bytes.
Did this by using a more efficient encoding of the IAU2000B nutation model:
instead of making {nals:[_], cls:[_]} objects, make lists of lists [[_], [_]].
2021-05-09 15:33:16 -04:00
Don Cross
d45bb771ac Python: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:55:54 -04:00
Don Cross
a53e83d4af JS: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:36:47 -04:00
Don Cross
cbcacc4b57 Improved agreement of precision among the 4 supported languages.
Before making these changes, I had the following discrepancies
between the calculations made by the different programming
language implementations of Astronomy Engine:

    C vs C#: 5.55112e-17, worst line number = 6
    C vs JS: 2.78533e-12, worst line number = 196936
    C vs PY: 1.52767e-12, worst line number = 159834

Now the results are:

    Diffing calculations: C vs C#
    ctest(Diff): Maximum numeric difference = 5.55112e-17, worst line number = 5

    Diffing calculations: C vs JS
    ctest(Diff): Maximum numeric difference = 1.02318e-12, worst line number = 133677

    Diffing calculations: C vs PY
    ctest(Diff): Maximum numeric difference = 5.68434e-14, worst line number = 49066

    Diffing calculations: JS vs PY
    ctest(Diff): Maximum numeric difference = 1.02318e-12, worst line number = 133677

Here is how I did this:

1. Use new constants HOUR2RAD, RAD2HOUR that directly convert between radians and sidereal hours.
   This reduces tiny roundoff errors in the conversions.

2. In VSOP longitude calculations, keep clamping the angular sum to
   the range [-2pi, +2pi], to prevent it from accumulating thousands
   of radians. This reduces the accumulated error in the final result
   before it is fed into trig functions.

The remaining discrepancies are largely because of an "azimuth amplification" effect:
When converting equatorial coordinates to horizontal coordinates, an object near
the zenith (or nadir) has an azimuth that is highly sensitive to the input
equatorial coordinates. A tiny change in right ascension (RA) can cause a much
larger change in azimuth.

I tracked down the RA discrepancy, and it is due to a different behavior
of the atan2 function in C and JavaScript. There are cases where the least
significant decimal digit is off by 1, as if due to a difference of opinion
about rounding policy.

My best thought is to go back and have a more nuanced diffcalc that
applies less strict tests for azimuth values than the other calculated values.
It seems like every other computed quantity is less sensitive, because solar
system bodies tend to stay away from "poles" of other angular coordinate
systems: their ecliptic latitudes and equatorial declinations are usually
reasonably close to zero. Therefore, right ascensions and ecliptic longitudes
are usually insensitive to changes in the cartesian coordinates they
are calculated from.
2021-04-18 21:15:17 -04:00
Don Cross
6b01510b33 Fixed #99 - Export the AngleBetween function for outside callers. 2021-04-16 20:18:25 -04:00