Commit Graph

1232 Commits

Author SHA1 Message Date
Don Cross
7ed50c262b C Lagrange work in progress.
The Lagrange point calculation is still not finished,
but L1 and L2 are working. L3 is probably correct, but there
is no test data for it.

I replaced the test data with new JPL Horizons output that
is centered on the primary body instead of the Solar System Barycenter.
This allows Astronomy_LagrangePoint() to be agnostic about
the coordinate systems of the state vectors handed to it.

I still need to get L4 and L5 calculations to match JPL Horizons
data, but it is not yet clear how to do that.
2022-02-12 10:15:41 -05:00
Don Cross
f4b235fda4 Fixed #156 - Moon ascending/descending nodes.
Python and npm package version: 2.0.11.
Finished implementing new functions across all
supported languages:

    EclipticGeoMoon
        Calculate the Moon's ecliptic geocentric position
        in angular coordinates. The ecliptic longitude is
        measured with respect to the mean equinox of date.

    SearchMoonNode
    NextMoonNode
        A pair of functions to search for consecutive occurrences
        of the Moon's center passing through the ecliptic plane.
2022-02-06 21:06:30 -05:00
Don Cross
6f9c906061 PY EclipticGeoMoon, SearchMoonNode, NextMoonNode. 2022-02-06 19:55:24 -05:00
Don Cross
19007ebfd5 JS EclipticGeoMoon, SearchMoonNode, NextMoonNode. 2022-02-06 16:11:24 -05:00
Don Cross
eb5cc8ea9a C# EclipticGeoMoon, SearchMoonNode, NextMoonNode.
Implemented the C# versions of these functions.
Ported the unit tests from C to C# to validate them.
2022-02-06 12:57:51 -05:00
Don Cross
e7717ea4fa Added C functions SearchMoonNode, NextMoonNode.
Implemented a pair of C functions for finding a series of
Moon nodes:

    Astronomy_SearchMoonNode
    Astronomy_NextMoonNode

Finished the C unit test "moon_nodes" that verifies
my calculations against Fred Espenak's test data.
2022-02-05 14:29:08 -05:00
Don Cross
13b13a0f3f C Astronomy_EclipticGeoMoon implemented.
This is a thin wrapper function for the internal
function CalcMoon, which has already been extensively
validated. It will enable outside users to search
for ascending and descending nodes of the Moon,
or to calculate ecliptic spherical coordinates for the Moon
for any other useful purpose.
2022-02-03 22:05:12 -05:00
Don Cross
e4b2911c97 Clarify GeoMoon and GeoMoonState calculating EQJ.
Changed the documentation for the GeoMoon and GeoMoonState
functions to make it explicit that they calculate coordinates
oriented with respect to the Earth's J2000 equator (EQJ).
This is because I will soon add ecliptic (ECL) counterparts
for the GeoMoon function, to more directly search for ascending
and descending nodes of the Moon.
2022-02-03 19:43:18 -05:00
Don Cross
90a9839d18 Optimize for map-making calculation patterns.
See this discussion:
https://github.com/cosinekitty/astronomy/issues/150

For the case of calculating a map, where each pixel
on the map represents a different location on the Earth,
it is more efficient to factor out expensive calculation
of sidereal times, assuming the entire map represents
some phenomenon at a single moment in time.

For example, to determine whether the Moon is visible
at different places on the Earth, the following
functions can be calculated across thousands of
different (lat, lon) geographic coordinates around
the world:

    ObserverVector
    Rotation_EQD_HOR

Before iterating over the map pixels, a program
can call GeoMoon, then convert EQJ coordinates to EQD.

Then by passing the same time value in a loop to
ObserverVector and Rotation_EQD_HOR, the program
can calculate a vector from the observer to the Moon
in EQD coordinates, then convert EQD to HOR.
The z-coordinate of the horizontal coordinates
determines whether the Moon is above or below the
observer's horizon at that point on the Earth.

This calculation pattern performed redundant
sidereal time calculations for each pixel on the map.
I changed the code for all 4 languages to cache
sidereal time so that it only needs to be calculated
once.

In the C version of Astronomy Engine, this resulted
in a speedup factor of about 2.3 in the above use case.
(See the function MapPerformanceTest in generate/ctest.c.)
2022-01-22 20:47:46 -05:00
Don Cross
0bfdb359b1 Fixed #153 - Optimize C functions by recycling nutation calculations.
Reduce the number of redundant Earth nutation calculations
by passing astro_time_t values as pointers in more functions.
Nutation values can then be cached in the time parameter
and passed to other functions that can then avoid calculating
the same nutation again.

Nutation is an expensive calculation, so reducing this overhead
can dramatically speed up certain use cases.

This was only needed in C, because this is the only language
in which times are passed by value. In Python, C#, and JavaScript,
times are objects that are already passed by reference, and
they already benefit from this nutation recyling approach.

The following functions have had their parameters changed.
This is a breaking change, but in every case, the caller
usually just needs to change `time` to `&time`.

    Astronomy_Rotation_EQD_EQJ
    Astronomy_Rotation_EQD_ECL
    Astronomy_Rotation_EQD_HOR
    Astronomy_Rotation_EQJ_EQD
    Astronomy_Rotation_EQJ_HOR
    Astronomy_Rotation_ECL_EQD
    Astronomy_Rotation_ECL_HOR
    Astronomy_Rotation_HOR_EQD
    Astronomy_Rotation_HOR_EQJ
    Astronomy_Rotation_HOR_ECL
    Astronomy_RotationAxis
    Astronomy_VectorObserver
2022-01-21 20:59:06 -05:00
Don Cross
ab9b5a5ce5 pip, npm packages 2.0.10.
The pip and npm astronomy-engine packages will have
matching version numbers from now on, starting with
2.0.10.

https://pypi.org/project/astronomy-engine/2.0.10/
https://www.npmjs.com/package/astronomy-engine
2022-01-10 20:34:35 -05:00
Don Cross
cba75aa2e4 Fixed #64 - pip package for Astronomy Engine.
Thanks to ebrominio, I was able to create a pip
package for Astronomy Engine. See:

https://pypi.org/project/astronomy-engine/1.0.1/

I will probably need to go back and keep the version
numbers in sync with the matching npm package.
2022-01-10 19:59:25 -05:00
Don Cross
b60b11f86a Merge branch 'master' of https://github.com/ebraminio/astronomy into pip 2022-01-10 19:38:04 -05:00
Don Cross
15fefc4922 Windows CI: Upgrade Doxyfile to eliminate warnings. 2022-01-10 16:54:36 -05:00
Ebrahim Byagowi
f68c8766dd Add files necessary for pip package upload 2022-01-11 00:34:41 +03:30
Don Cross
15d1312060 Made Jupiter rotation matrix code gen one digit shorter.
This is another attempt to get consistent generated code
between Linux and macOS.
2022-01-07 21:38:41 -05:00
Don Cross
1ace122c9e Consistent generated tables between Linux, macOS.
The code generator was creating slightly different numeric
values for the Pluto state tables and the Jupiter rotation matrix.
I decreased the output precision by one decimal digit.
This should allow the code generator to produce identical
source code on both Linux and macOS.
2022-01-07 21:02:59 -05:00
Don Cross
753554db67 Make demo tests less sensitive to tiny floating point errors.
More work getting MacOS build process to work.
Avoid excessive number of floating point digits of
output in the demo tests, so that insignificant
floating point variations don't cause unit test failures.
2022-01-07 20:19:23 -05:00
Don Cross
b50a8fdce2 Merge branch 'jupiter_moons_imager' 2022-01-05 20:35:31 -05:00
Don Cross
b2f9219b56 Updated copyrights for 2022. 2022-01-04 18:55:20 -05:00
Don Cross
103e09d04c Raytracer: added radius data for other bodies.
Added radius data for the Sun, Moon, and remaining planets.
Test the raytracer for all other bodies except the Earth and Sun.
There is a problem with Pluto that I still need to figure out.
Fixed an issue in the doxygen-to-markdown translator I wrote
(hydrogen.js): it did not handle when one #define referred
to another #define. Created a more generic markdown expansion
that works in all cases, and creates embedded hyperlinks.
2022-01-02 20:32:45 -05:00
Don Cross
e158dab271 Raytrace: Added Saturn. Updated copyrights for 2022.
Added Saturn and its rings to the raytrace demo.

As a side effect of running the unit tests, copyrights
got updated for 2022. Happy New Year!
2021-12-31 22:25:16 -05:00
Don Cross
8731f1d229 Raytracer: started to generalize planet imager.
Refactored the Jupiter imager to be a generic planet imager.
Added support for drawing an image of Venus.
Verified that its extreme crescent phase looks correct
for the current date.
I will add radius constants to astronomy.h for each body I support.
2021-12-28 20:45:55 -05:00
Don Cross
210319d407 Python documentation fixes.
The documentation for the Python function `SearchAltitude`
was missing a mention of the `altitude` parameter.
I searched for similar mistakes in Python, C#, and C,
having just completed the same exercise in the JavaScript code.

I also found several places where extraneous newlines
between the parameter documentation caused the Markdown
to be rendered incorrectly.
2021-12-10 20:32:43 -05:00
Don Cross
7448727549 Fixed #143 - Fixed JS documentation mistakes.
Added documentation about the missing `date` parameter
to the `Elongation` function in the JavaScript version.
I reviewed all the other JavaScript functions to make sure there
were no other similar mistakes with parameters or return types.

Along the way, I discovered and fixed some other issues:

Fixed miscellaneous typos in the documentation.

Consistently refer to enumeration values like `Body.Earth`
instead of strings like `"Earth"`. I want to encourage
use of the enumerations because they make type-checking easier,
especially for TypeScript code.

Reworked `AstroTime` parameters to `FlexibleDateTime` parameters
in all exported functions. This is completely backward-compatible,
and allows callers more flexibility with passing `AstroTime`,
`Date`, or numeric day values.
2021-12-10 19:16:10 -05:00
Don Cross
f994d8d04c Fixed #141 - Upgrade C# code to .NET 6.
Now that Microsoft has officially released .NET 6,
I have upgraded the C# version of Astronomy Engine to use it.
No source code changes were needed. I just bumped the
version number in the project files, and targeted .NET 6
in the GitHub Actions continuous integration tests.
Fixed some obsolete wording in generate/README.md.
2021-12-07 17:06:04 -05:00
Don Cross
945e70a98f Fixed #106 - Calculate rotation axis of Sun, Moon, and planets. 2021-12-07 15:31:54 -05:00
Don Cross
e6c28a9a40 C: Found much more accurate Moon axis formulas.
I went back to the 2009 version of the IAU paper at:
https://astropedia.astrogeology.usgs.gov/alfresco/d/d/workspace/SpacesStore/28fd9e81-1964-44d6-a58b-fbbf61e64e15/WGCCRE2009reprint.pdf
and found formulas for the Moon's rotation axis and spin angle.
The north pole vector agrees with JPL Horizons to within 0.26 arcminutes,
which is much better than the 5.7 arcminutes I was getting using my
own formulas. So now I believe I'm ready to start porting the formulas
to the other 3 languages (C#, JavaScript, Python).
2021-12-07 14:10:24 -05:00
Don Cross
919973e11d Slight changes to moon axis calculation.
Added more test data for the Moon axis to better cover its orbital motion.
Tweaked the polar axis inclination to better match the test data.
2021-12-06 20:18:44 -05:00
Don Cross
a652da7b9e Rough version of Moon's rotation axis in C.
I used Cassini's Laws to derive an approximate solution
to the Moon's rotation axis. The error is on the order of
5 arcminutes. I still need to correct for physical libration.

I also need to find test data for the Moon's prime meridian
so that I can implement the spin angle calculation.
(I could use test data for all the planets' spins, for that matter.)
2021-12-05 13:22:00 -05:00
Don Cross
c36f16e1be PY RotationAxis function. 2021-12-02 16:11:50 -05:00
Don Cross
4235ee1715 JS RotationAxis function. 2021-12-01 21:26:29 -05:00
Don Cross
df518aeb84 Implemented C# RotationAxis. Improved C RotationAxis docs. 2021-11-30 22:12:34 -05:00
Don Cross
62dae5d893 Eliminated C constants MIN_BODY, MAX_BODY.
I don't think it's a good idea to imply that the body constants
are always going to be consecutive, or that it makes sense to
iterate over them. The caller needs to understand the body enough
to know which operations are allowed and which aren't.

So I removed the constants MIN_BODY and MAX_BODY.
2021-11-30 20:54:22 -05:00
Don Cross
afc472be77 C RotationAxis: added rotation model for the Earth.
This model uses the existing precession and nutation models
to calculate the north pole vector. Then it converts the vector
to equatorial coordinates.
2021-11-30 19:59:44 -05:00
Don Cross
55a2e8fd3b C RotationAxis: added code and test data for Pluto. 2021-11-29 21:19:18 -05:00
Don Cross
ad0611755a C RotationAxis: added Jupiter ... Neptune. 2021-11-29 21:08:44 -05:00
Don Cross
318fc416af C RotationAxis: Added Venus and Mars. 2021-11-29 20:49:00 -05:00
Don Cross
20ff46bb27 C RotationAxis: calculate north pole vector.
Calculate the vector that points in the direction
of the body's north pole.
The unit test now checks for excessive angle
between the expected north pole vector and the
calculated north pole vector.
2021-11-28 21:51:47 -05:00
Don Cross
ec35f21827 Starting body rotation axis calculation.
I'm starting to implement formulas from the IAU 2015 report:
https://astropedia.astrogeology.usgs.gov/download/Docs/WGCCRE/WGCCRE2015reprint.pdf

This is a work in progress. The unit test is partially finished.
The C function Astronomy_RotationAxis() works only for the Sun and Mercury.
I want to also return a rotation matrix that reports the rotating
frame in a way more suited to graphics work. I will add this to
the type astro_axis_t later.
2021-11-28 20:44:57 -05:00
Don Cross
d02039c78f Trying to make it easier for newcomers to find the code.
I'm concerned that a first-time visitor to the Astronomy Engine
repo on GitHub will get lost. I made it more obvious where to
quickly find the source code needed for a given language.
2021-11-23 20:43:17 -05:00
Don Cross
6b744edd71 Completed implementation of ObserverState.
Fixed a few lingering issues in the documentation of
the C# version of the ObserverState function.
This completes the implementation across all 4 languages.

ObserverState calculates the position vector of a point
on the surface of the Earth, and the velocity vector
of that point, both relative to the center of the Earth.
2021-11-19 22:15:02 -05:00
Don Cross
c91fe513c1 PY ObserverState
Implemented the Python version of the ObserverState function.
2021-11-19 21:40:22 -05:00
Don Cross
4f80808008 JS: ObserverState
Implemented the JavaScript version of the ObserverState function.
2021-11-19 20:26:46 -05:00
Don Cross
7e2b0a73eb C# ObserverState
Implemented the C# version of the ObserverState function.
This returns the geocentric position and velocity for
a point on the Earth's surface at a given time.
2021-11-19 17:30:52 -05:00
Don Cross
1d9a90af2d C barystate: Reworked internal data structure.
Made the internal data structure for the C version of barystate
use named fields in a struct for Sun...Neptune, instead of
an array. This makes the C code look more like the other 3
language implementations. I am going to experiment with adding
more bodies to see if it helps accuracy, and this makes the
code easier to modify for that experiment.
2021-11-18 10:40:42 -05:00
Don Cross
f4e40e764a Implemented C ObserverState, but not yet tested.
I am starting to work on a function to find the position
and velocity vectors for an observer on the surface of the Earth.
I created the C function Astronomy_ObserverState(), but I don't
yet have a unit test for it.
2021-11-16 19:14:40 -05:00
Don Cross
9537296347 Added missing supported bodies to Python HelioState docs. 2021-11-15 21:14:40 -05:00
Don Cross
5c989be20c PY HelioState: calculates heliocentric position and velocity.
This is the Python version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 20:37:09 -05:00
Don Cross
f16dcea487 JS HelioState: calculates heliocentric position and velocity.
This is the JavaScript version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 20:10:11 -05:00