Commit Graph

520 Commits

Author SHA1 Message Date
Don Cross
4f8977067b Snapped constellation border to nearest quarter arcminute.
Instead of using decimal hours/degrees rounded to 4 decimal places,
I went back to the original constel.c and modified it to represent
both RA and DEC in degrees, and to round all values to the nearest
quarter arcminute. This seems closer to the original intent of the
constellation boundaries.
2020-05-02 21:21:32 -04:00
Don Cross
7fe9863b88 Renamed C function Astronomy_FindConstellation to Astronomy_Constellation. 2020-05-02 17:21:58 -04:00
Don Cross
e803a65b4e More thorough constellation unit test for C code.
I'm using the HYG star database v3 from:
https://github.com/astronexus/HYG-Database

I compare the star constellations it reports against
what I calculate from the star RA/DEC it lists.
When I try this against all stars in the database, I
find 25 disagreements about which constellation contains
the star. Another person found 3 disagreements. See:

https://github.com/astronexus/HYG-Database/issues/21

For now, I'm testing only the stars brighter than mag 4.890,
which eliminates all the disagreements, and still gets me
over 1000 test cases.

Also, now I'm verifying ephemeris file and star database
checksums whether or not they have just been downloaded.
The idea is to catch corruption or unexpected changes
each time I run the unit test.
2020-05-02 15:10:10 -04:00
Don Cross
1e1af922fe Constellations: Added C unit test. Fixed bugs in C code.
This unit test only exercises 8 different points.
I want to add a more thorough unit test soon, before
moving on to implementing the constellation finder in
the other supported programming languages.
2020-05-02 13:33:25 -04:00
Don Cross
d0f328fe78 Starting work on C version of constellation lookup.
Generate C code for constellation tables.
First pass of Astronomy_FindConstellation(). Not yet tested.
2020-05-02 11:45:32 -04:00
Don Cross
3bb740fd1c Fixed #62 - Automatically update copyright year range. 2020-04-30 15:12:14 -04:00
Don Cross
f754a6de82 Fixed #58 - Solar System Barycenter, Earth/Moon Barycenter.
Can now calculate the heliocentric Solar System Barycenter (SSB)
and Earth/Moon Barycenter (EMB).

Changes made in C, C#, JavaScript and Python:
Added new body codes SSB, EMB.
Added support for calculating both in HelioVector functions.
Verified that all calculations match NOVAS.
Verified that all calculations match each other across languages.
2020-04-29 21:53:57 -04:00
Don Cross
ec6a82b133 Improved performance of Neptune apsis search.
The apsis search for Neptune was sampling 1000 points
in its first pass. It turns out 100 is enough.
2020-01-07 11:57:54 -05:00
Don Cross
cdf9c6955e Added planet apsis functions to C and C# documentation topic indexes. 2020-01-06 17:28:09 -05:00
Don Cross
977ab2d5b3 C# planet apsis: Implemented unit tests. 2020-01-06 16:04:57 -05:00
Don Cross
9992f2570b Starting to port planetary apsis functions to C#.
No unit tests implemented yet.
2020-01-06 15:19:19 -05:00
Don Cross
ff482335db C planet apsis: made SearchPlanetApsis, NextPlanetApsis parameters consistent.
Existing functions have body parameter before time parameter.
Made the planet apsis search functions consistent with that pattern.
2020-01-06 14:16:17 -05:00
Don Cross
6304cc861a C planet apsis: removed unnecessary clamping of apsis search interval to 10 days. 2020-01-06 13:57:00 -05:00
Don Cross
02dc4e95a4 Pluto apsis predictions are now within 0.0810 degrees of orbit period.
Increased from 7 Chebyshev sections to 8.
This also decreases max arcmin error from 0.336084 to 0.120252.
2020-01-06 11:25:47 -05:00
Don Cross
f67ddf1c8d Planet apsis: all planets but Pluto now have prediction error below 0.1 degrees.
Adjust VSOP models for planets to bring their prediction errors beneath
0.1 degrees of a total orbit.
ctest no longer runs tests when no command line arguments are given.
That was annoying because I kept running it by accident.
2020-01-06 10:59:38 -05:00
Don Cross
819e59745d Decreased Neptune apsis prediction errors from 49.25 days to 15.45 days.
Include an extra 4 terms in the radial component of the VSOP
model for Neptune. The code automatically picks the 4 terms
that maximize the time derivative's highest possible contribution.
2020-01-05 20:44:29 -05:00
Don Cross
331bdfcea9 Added special-case logic for finding Neptune perihelion/aphelion.
Because of Sun/SSB wobble, can't use slope solver to find
Neptune apsides. Added special case logic to find them
using more of a brute force algorithm.
Unit tests now pass, but require very loose tolerances
for the outer planets.
I will have to adjust the model generator to create
more accurate heliocentric distance models for the VSOP
planets, and more accurate Chebyshev polynomials for Pluto.
This will be a judgment call to balance accuracy versus code size.
2020-01-04 11:01:28 -05:00
Don Cross
1436a0be25 Planet apsides - work in progress - BROKEN TESTS.
Use planet apsis test data generated by generate.c to verify
Astronomy Engine calculations. Currently this fails for Neptune
as expected. Will fix that in a future commit.

Implemented a more efficient function Astronomy_HelioDistance
for calculating heliocentric distances of the planets
Mercury through Neptune: use VSOP distance formula only.
For Moon and Pluto, fall back to calculating heliocentric
vector and then finding the length of that vector.
2020-01-04 09:37:56 -05:00
Don Cross
4d573b50bd C: First draft of SearchPlanetApsis, NextPlanetApsis.
I have tested only for Earth.
Will need to add tests for all the other planets.
2019-12-31 16:02:23 -05:00
Don Cross
93fdf9a146 C# rotation: added remaining rotation functions.
Fixed a couple of mistakes in the C documentation.
Turned on link checking for csharp markdown output.
2019-12-22 13:44:58 -05:00
Don Cross
d3f0339498 C# rotation: Added more rotation functions. 2019-12-22 13:32:15 -05:00
Don Cross
8768a157cb C# rotation: Added more rotation functions.
More work on new functions for converting orientation systems.
Changed a few classes to structs for memory allocation efficiency.
Moved stuff around in astronomy.cs so the Astronomy class comes
last. This is helpful when I want to add new functions, so I
don't have to search for the end of the class.
2019-12-22 12:07:38 -05:00
Don Cross
1fde8049c6 Added check_internal_links.py utility to look for broken links in markdown files.
Currently I ignore any errors when checking the C# documentation,
because there are broken links for the rotation functions I
haven't started adding yet.  I will turn that error check back on
once I finish those functions.
2019-12-21 15:41:39 -05:00
Don Cross
3d38890aaf Merge branch 'master' into csharp.
Includes coordinate transform logic support in
C, JavaScript, and Python.
Will start porting to C# soon.
2019-12-19 14:28:09 -05:00
Don Cross
0c11c626de Fixed typo in C function topic index. 2019-12-14 22:08:26 -05:00
Don Cross
1971e4d7b5 C: Added coordinate transform functions to topic index. 2019-12-14 22:05:30 -05:00
Don Cross
ef633967e3 C, JS: continued eliminating redunancies in precession, nutation. 2019-12-14 20:18:45 -05:00
Don Cross
e7d8804bf1 C: Eliminated duplicate code - nutation() is based on nutation_rot().
Instead of having the same calculations duplicated in both
nutation() and nutation_rot(), I reworked nutation() in terms of
nutation_rot(). Use nutation_rot() to calculate the rotation matrix,
then multiply that matrix by the input vector to produce the output vector.
2019-12-14 18:15:13 -05:00
Don Cross
c4a537a236 C: Fixed some code documentation mistakes. 2019-12-14 17:24:19 -05:00
Don Cross
7b7c28bced C: Added Astronomy_VectorFromEquator and Astronomy_EquatorFromVector.
These helper routines in the JavaScript code make sense for C also.
2019-12-14 17:20:32 -05:00
Don Cross
d6ab8b5148 JS: Beginning to port vector rotation code from C. 2019-12-12 17:16:17 -05:00
Don Cross
52db7cd898 Fixing travis-ci build error: looks like they changed gcc-6.
The gcc-6 compiler in travis-ci has changed its behavior.
It is warning that 'fmid' local variable in Search() may
be used uninitialized. I believe it is safe but I'm adding
an initialization to fmid to make the warning go away.
2019-12-12 13:52:58 -05:00
Don Cross
9b0a9fcd78 C: Added Astronomy_VectorFromHorizon. 2019-12-10 20:55:27 -05:00
Don Cross
696dbbaa5d C: Implemented Astronomy_InverseRefraction. 2019-12-10 20:20:31 -05:00
Don Cross
824792004d Starting to work on inverse function for refraction calculation.
I need a way to undo a refraction correction:
given a post-refraction altitude, find the unrefracted
altitude that leads to it. Starting to write the code.
Not finished yet.
2019-12-10 17:58:38 -05:00
Don Cross
8b0827e1e8 C: Added Astronomy_Refraction function to calculate refraction.
This function eliminates duplicate code and exposes the refraction
formula to outside callers.
2019-12-10 13:26:30 -05:00
Don Cross
55d4cc3dde C: Added Astronomy_Rotation_EQD_ECL, ECL_EQD, HOR_ECL, ECL_HOR.
These are the final 4 rotation functions to complete every
possible coordinate transform.

Finished unit tests of verifying that all triangular
cycles of transitive rotation are consistent.
2019-12-09 16:53:02 -05:00
Don Cross
4c368f3d75 C: Implemented Astronomy_Rotation_EQJ_HOR. 2019-12-09 14:45:04 -05:00
Don Cross
cdcdfe7762 Fixed bug in Astronomy_CombineRotation. Implemented Astronomy_Rotation_HOR_EQJ.
Astronomy_CombineRotation was multiplying matrices correctly,
but it was doing it in the backwards order from what I need.
I forgot that to rotate a vector V by a matrix M, you multiply M*V,
with the matrix on the left.
Likewise, to rotate a matrix A by another matrix B, you need B*A, not A*B.
This explains why I was seeing larger than expected errors combining
nutation and precession: nutation is a very tiny shift in orientation,
so the errors were small but noticeable. Tightened the error thresholds
in the unit test code.

Astronomy_Rotation_HOR_EQJ converts from horizontal of-date coordinates
to equatorial J2000 coordinates. Here I could no longer ignore the
errors caused by having backwards matrix multiplication, leading
to discovering the problem in Astronomy_CombineRotation.
2019-12-09 12:47:43 -05:00
Don Cross
0aa80dbf6f C: Implemented Astronomy_Rotation_HOR_EQD. 2019-12-09 11:18:15 -05:00
Don Cross
4399e72334 Added Astronomy_HorizonFromVector, Astronomy_Rotation_EQD_HOR.
Astronomy_HorizonFromVector is a specialized variant of
Astronomy_SphereFromVector that flips the orientation of the
azimuth angle to the more traditional clockwise-from-north
direction used in navigation and cartography.
It also allows the same optional refraction correction as
Astronomy_Horizon.

Astronomy_Rotation_EQD_HOR converts a equatorial-of-date vector
to a horizontal vector. The horizontal vector has the following
components:
    x = North
    y = West
    z = Zenith

Removed trailing whitespace in generate.c.
2019-12-09 11:06:02 -05:00
Don Cross
212c60b633 C: Implemented Astronomy_Rotation_EQD_EQJ. 2019-12-08 20:41:01 -05:00
Don Cross
cd545033ae C: Added Astronomy_Rotation_EQJ_EQD(). 2019-12-08 19:48:43 -05:00
Don Cross
bf7e958152 C: Implemented Astronomy_Rotation_ECL_EQJ.
This function returns the rotation matrix for
converting ecliptic J2000 coordinates to equatorial J2000.
2019-12-08 16:44:43 -05:00
Don Cross
dd39803180 C: Implemented Astronomy_Rotation_EQJ_ECL.
This function returns the constant rotation matrix that converts
equatorial J2000 coordinates to ecliptic J2000 coordinates.
Verified that it is exactly consistent with existing Ecliptic().
2019-12-08 15:49:29 -05:00
Don Cross
f493707e6d C: Implemented Astronomy_RotateVector.
Astronomy_RotateVector translates a vector in one orientation
to another orientation, as specified by a rotation matrix.
I will use this to implement all the coordinate transforms
among EQJ, EQD, ECL, HOR.
2019-12-08 15:13:55 -05:00
Don Cross
65e3e931c9 C: Implemented Astronomy_SphereFromVector.
Implemented C function that converts cartesian vector to spherical coordinates.
2019-12-08 14:17:23 -05:00
Don Cross
bca3f808ae C: Added Astronomy_VectorFromSphere, astro_spherical_t.
Added new data type astro_spherical_t that represents generic spherical coordinates.
Implemented Astronomy_VectorFromSphere to convert spherical coordinates
to Cartesian coordinates. Included unit test to verify it is working as expected.
2019-12-08 13:48:27 -05:00
Don Cross
ae0946bd47 Implemented C versions of Astronomy_CombineRotation, Astronomy_InverseRotation.
Beginning to implement functions for converting among the
following four orientation systems:

- EQJ: equatorial J2000
- EQD: equatorial of date
- ECL: ecliptic J2000
- HOR: horizontal

Starting with some basic functions for manipulating rotation matrices.
Astronomy_CombineRotation multiplies two rotation matrices to obtain
a third that combines their effects in order. I will use these for
combining a precession matrix and a nutation matrix, to obtain a
rotation matrix that can convert between EQJ and EQD.

Astronomy_InverseRotation will allow converting in either direction
between two orientations.
2019-12-08 11:26:59 -05:00
Don Cross
df12a2c8c8 C#: Added SearchLunarApsis, NextLunarApsis. 2019-11-27 22:13:52 -05:00