Commit Graph

368 Commits

Author SHA1 Message Date
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
fce1468a1c Fixed #55 - Python documentation internal links translated to Markdown.
pydown.py now searches description text for internal links
and expands them properly for Markdown file README.md.
For example:  "#Body" ==> "[`Body`](#Body)".
Fixed a couple of incorrect "Astronomy_..." names in Python docs.
2019-12-18 17:07:00 -05:00
Don Cross
7040ff8684 Cleaned up documented return types for Python functions.
Never use pound-signs inside documentation for Python return types.
Automatically create internal link just like for function parameter types.
Added special case logic in pydown.py for "Time or `None`".
Fixed minor documentation mistakes in JS version.
2019-12-18 16:53:13 -05:00
Don Cross
e168f37ac5 Python: Finished rotation logic and unit tests.
I thought I had finished the rotation functions last time,
but I missed a couple of them. Finishing the unit tests
revealed that, thankfully.
2019-12-18 10:05:00 -05:00
Don Cross
98deea4523 Python: Finished coding rotation functions. Need to finish test cases. 2019-12-17 20:32:37 -05:00
Don Cross
85d9113f77 Python: Added more rotation functions and unit tests. 2019-12-15 21:24:32 -05:00
Don Cross
d572edb10f Python: Implemented Rotation_ECL_EQJ. 2019-12-15 20:41:03 -05:00
Don Cross
126cc04d1d Python: Implemented CombineRotation. 2019-12-15 20:29:41 -05:00
Don Cross
8c590e4449 Python: implemented InverseRotation function. Cleaned up trailing whitespace.
Also added missing check in Python apsis test where
I did not verify that each apsis kind was correct.
2019-12-15 20:23:35 -05:00
Don Cross
92cc2d9783 Python: starting to implement rotation functions and associated unit tests. 2019-12-15 19:51:30 -05:00
Don Cross
4a449cc0a1 Python: InverseRefractionAngle, RotateVector. Minor doc fixes. 2019-12-15 13:11:47 -05:00
Don Cross
6440743052 Python: Added function RefractionAngle.
Separate the calculation of refraction angle from the Horizon function.
Added missing documentation for the parameters of the Horizon function.
Added definition of class Spherical. Not yet used, but soon will be.
2019-12-15 12:25:17 -05:00
Don Cross
ab8d8ba295 Python: Starting to port new rotation code.
Split _precession into _precession_rot/_precession.
Split _nutation into _nutation_rot/_nutation.
Removed trailing whitespace from readme.
2019-12-15 11:34:16 -05:00
Don Cross
4fc2787569 JS: Added demo program horizon.js. 2019-12-14 21:16:43 -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
185a872082 JS: Added helper function EquatorFromVector. 2019-12-14 14:44:29 -05:00
Don Cross
7307c99280 JS: Added function VectorFromEquator to convert equatorial coordinates to vector. 2019-12-14 14:36:56 -05:00
Don Cross
46fa5174a2 JS: Added factory function MakeRotation.
There was no way for outside callers to directly instantiate
a RotationMatrix object. Provided the factory function MakeRotation.
2019-12-14 14:19:25 -05:00
Don Cross
32f5567254 JS: More unit testing of rotation. Fixed a couple more bugs it uncovered. 2019-12-13 21:06:52 -05:00
Don Cross
690d3d0528 JS: More unit testing of rotation. Fixed a couple of bugs. 2019-12-13 20:18:48 -05:00
Don Cross
8322975e15 JS: Added inverse matrix unit test. Fixed bugs it uncovered. 2019-12-13 07:21:24 -05:00
Don Cross
13041b735e JS: Finished porting rotation functions. Not yet tested. 2019-12-12 21:30:54 -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
0aeb875ec5 C#: Implemented SearchPeakMagnitude. 2019-12-01 11:41:48 -05:00
Don Cross
efd1629e9a C#: Implemented Illumination(). Not fully tested yet.
The unit test exercises Illumination() except for Saturn.
Will implement that next.
2019-12-01 10:27:40 -05:00
Don Cross
df12a2c8c8 C#: Added SearchLunarApsis, NextLunarApsis. 2019-11-27 22:13:52 -05:00
Don Cross
655b9bca46 C#: Implemented functions Elongation and SearchMaxElongation. 2019-11-06 18:50:06 -05:00
Don Cross
af106481f6 C#: Implemented SearchRelativeLongitude. 2019-11-05 22:12:21 -05:00
Don Cross
162f3c5683 C#: Added SearchHourAngle and SearchRiseSet. 2019-11-03 15:33:30 -05:00