Commit Graph

187 Commits

Author SHA1 Message Date
Don Cross
898276e130 Update copyrights, move AstroTime notes to correct file, copyediting. 2024-05-26 16:30:43 -04:00
Don Cross
dd0245cbf8 C: Astronomy_GetCurrentTime supports microsecond resolution.
This is a follow-up to work provided by:
Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>

Before now, the C function Astronomy_GetCurrentTime returned
the current time from the system clock, but only with whole
second resolution. Now it supports microsecond resolution on
Linux/Unix, Mac OS, and Windows.

For unsupported platforms, a compiler error will occur
to indicate that microsecond resolution is not available.
However, it is possible to define one of the following two
preprocessor symbols to work around the compiler error:

1. ASTRONOMY_ENGINE_NO_CURRENT_TIME
   Excludes the function Astronomy_CurrentTime from the build.
   If your project does not need to obtain the current time,
   or your hardware platform does not provide current date
   and time in the first place, this is likely the better option.

2. ASTRONOMY_ENGINE_WHOLE_SECOND
   If your project does need to use the current date and time
   for astronomy calculations, and it can tolerate whole
   second resolution, this option provides a version of
   Astronomy_CurrentTime that uses a call to `time(NULL)`.

Notes:

- Added unit test to confirm at least millisecond resolution.
  Because these tests have to run on GitHub Actions cloud platform,
  and those systems can be heavily CPU-loaded, I want to be tolerant
  of resolution and avoid false failures.

- Added detection of Mac platform.

- Added preprocessor options documented above.

- On Windows, use ULARGE_INTEGER and eliminated one integer division.

- Added comments and developer documentation.

- Converted tabs to spaces in astronomy.c, for consistent code format.
2023-08-28 12:24:20 -04:00
Don Cross
7cf1a7eb7d Minor tweaks for cppcheck. Use const pointers for grav sim.
Slightly different cppcheck dev 2.11 behaviors have added
another warning that I don't care about. I don't want to
have to convert callback pointers to const, then cast them
to const.

However, it did find a couple of useful cases I fixed in
astronomy.c where GravSim parameters could be made const.
2023-06-19 12:37:39 -04:00
Don Cross
7bb9d02053 C#: Atmosphere function. 2023-03-11 20:23:20 -05:00
Don Cross
cdd75c7810 C SearchRiseSetEx: moved metersAboveGround parameter to end.
Because I plan on adding metersAboveGround as a parameter
that defaults to 0.0 in the other languages, and I want
the language implementations to be reasonably consistent,
I moved the metersAboveGround parameter to the end of
the parameter list for the C version of SearchRiseSetEx.
2023-03-11 18:50:57 -05:00
Don Cross
c275922c0e C: rise/set now corrects for height above ground.
I realized I had to rework the RiseSetEx function so that
it accepts a height above ground level, rather than a generic
altitude angle correction, because atmospheric effects are
important both for the horizon dip angle and for the amount
of refraction at ground level.

The atmosphere calculations were interesting enough that
I made them public as a new function Astronomy_Atmosphere.
This returns the idealized temperature, pressure, and relative
density of air at the given elevation above/below sea level.
2023-03-05 22:05:40 -05:00
Don Cross
cc7d9f5bc9 C: Implemented horizon dip calculation for observer above ground.
This is the first step toward calculating body rise/set times
for an observer that is significantly above the ground.
It figures out the angular correction of the horizon
using both parallax and refractive correction of a light
ray from the horizon to the observer's eye.
2023-03-05 13:56:26 -05:00
Don Cross
6a8a905aa5 C: Implemented Astronomy_HourAngle function.
We already had a function to search for the next time a body
reaches a certain hour angle. But we didn't have a function
to ask what the current hour angle of a body is.
This will resolve that problem, which will also answer
questions about true solar time: use the Sun as the body,
and add 12 to the hour angle, modulo 24.
2023-02-12 10:52:42 -05:00
Don Cross
62192357ba Updated copyrights for 2023.
Windows build process now updates copyright
years just like the Linux build process does.
Ran it to update the copyright years for 2023.
2023-01-07 17:13:07 -05:00
Don Cross
f811b6f55b C: Ecliptic function returns ECT instead of ECL.
Now the C function Astronomy_Ecliptic returns ecliptic
coordinates in true equinox of date instead of the
J2000 mean equinox. I'm doing this because it is a
better fit for physical phenomena that ecliptic
coordinates are often used for. For example, lunar nodes,
eclipses, phase angles, and oppositions make more sense
with true latitude and longitude of date.

I will port these changes to the other languages also.
2022-12-09 20:00:52 -05:00
Don Cross
1864fa8539 Orientation nomenclature. C: EQJ/ECT rotations.
More work standardizing the nomenclature of the
orientation systems across all language documents.

Added C functions to calculate rotation matrices
for EQJ/ECT and ECT/EQJ.
2022-12-08 22:03:43 -05:00
Don Cross
c102208e2b C: Rotation matrices for EQD/ECT.
Added new C functions to convert back and forth
between Equator of Date (EQD) and True Ecliptic of Date (ECT).
2022-12-06 15:09:00 -05:00
Don Cross
6b4c6c67e2 C: Added Astronomy_DefineStar.
Beginning to add support in C for user-defined stars.
2022-11-21 22:16:30 -05:00
Don Cross
bd115770e1 C: Added function Astronomy_PlanetOrbitalPeriod. 2022-11-01 16:38:57 -04:00
Don Cross
f7787caf98 C#: solar eclipse obscuration and accuracy enhancements 2022-10-18 20:09:59 -04:00
Don Cross
35936761f7 C: local solar eclipse obscuration
C function Astronomy_SearchLocalSolarEclipse now reports
obscuration for the peak of a solar eclipse seen at a given location.
Some of the test data from aa.usno.navy.mil looks suspiciously inaccurate.
I am finding better agreement with Fred Espenak's eclipsewise.com and
Xavier M. Jubier's xjubier.free.fr online calculators.
The larger obscuration differences are from aa.usno.navy.mil:

don@spearmint:~/github/astronomy/generate $ ./ctest -v solar_fraction
C GlobalAnnularCase(2023-10-14) obscuration error = 0.00009036, expected = 0.90638000, calculated = 0.90647036
C GlobalAnnularCase(2024-10-02) obscuration error = 0.00005246, expected = 0.86975000, calculated = 0.86980246
C GlobalAnnularCase(2027-02-06) obscuration error = 0.00007237, expected = 0.86139000, calculated = 0.86146237
C GlobalAnnularCase(2028-01-26) obscuration error = 0.00003656, expected = 0.84787000, calculated = 0.84790656
C GlobalAnnularCase(2030-06-01) obscuration error = 0.00008605, expected = 0.89163000, calculated = 0.89171605
C LocalSolarCase(2023-10-14) obscuration diff = 0.00006323, expected = 0.90638000, calculated = 0.90644323
C LocalSolarCase(2023-10-14) obscuration diff = -0.00521043, expected = 0.57800000, calculated = 0.57278957
C LocalSolarCase(2024-04-08) obscuration diff = 0.00000000, expected = 1.00000000, calculated = 1.00000000
C LocalSolarCase(2024-04-08) obscuration diff = 0.00304558, expected = 0.34000000, calculated = 0.34304558
C LocalSolarCase(2024-10-02) obscuration diff = 0.00007858, expected = 0.86975000, calculated = 0.86982858
C LocalSolarCase(2024-10-02) obscuration diff = -0.00343797, expected = 0.43600000, calculated = 0.43256203
C LocalSolarCase(2030-06-01) obscuration diff = 0.00007259, expected = 0.89163000, calculated = 0.89170259
C LocalSolarCase(2030-06-01) obscuration diff = -0.00059871, expected = 0.67240000, calculated = 0.67180129
C SolarFractionTest: PASS

I am going to rework using xjubier.free.fr in a subsequent commit.
2022-10-18 10:29:13 -04:00
Don Cross
14b881e0d9 C: global solar eclipse obscuration
Fixed bug in internal C function Obscuration().
It was not calculating obscuration correctly when
the second disc is completely inside the first disc,
i.e. the annular solar eclipse case.

Added C/C++ calculation of obscuration for global solar
eclipses that are total or annular at their peak
location and time. Obscuration is not calculated
for partial solar eclipses by SearchGlobalSolarEclipse.

Soon SearchLocalSolarEclipse will calculate obscuration
for partial solar eclipses at the geographic location
provided by the caller.
2022-10-17 16:31:05 -04:00
Don Cross
82be64ab2a C: lunar eclipse obscuration
Starting to add support for calculating the intensity
of lunar eclipses and solar eclipses in terms of "obscuration".

This commit adds calculation of obscuration for lunar eclipses
in C/C++. The structure returned by SearchLunarEclipse and
NextLunarEclipse now includes an `obscuration` field whose value
is in the range [0, 1], indicating what fraction of the Moon's
apparent disc is covered by the Earth's umbra at the eclipse's peak.
2022-10-17 11:25:10 -04:00
Don Cross
a50436b535 C: Support formatting calendar years -999999 to +999999. 2022-10-06 15:29:24 -04:00
Don Cross
e827c257b4 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_SearchHourAngleEx

The function Astronomy_SearchHourAngleEx replaces
Astronomy_SearchHourAngle, adding a new `direction` parameter.
A #define for Astronomy_SearchHourAngle preserves backward
compatibility for older code.

Implementation notes:

Astronomy_SearchRiseSet and Astronomy_SearchAltitude used
to call a private function InternalSearchAltitude.
That function has been split into two functions:
BackwardSearchAltitude and ForwardSearchAltitude,
for searching both directions in time.

Fixed a bug where it was possible to report a successful
altitude event that went outside the time limit specified
by `limitDays`.
2022-09-28 17:31:35 -04:00
Don Cross
0dd66c8981 C# light travel time correction
Implemented the generalized light travel time corrector for C#.
Reworked Astronomy.GeoVector to use it.
2022-05-29 21:17:25 -04:00
Don Cross
384b5eba96 C light travel time correction
Implemented two new C functions for generic correction
of light travel time:

1. Astronomy_CorrectLightTravel
   This is a completely generic solver that is passed
   a pointer to a function that returns a relative
   position vector for a given time.
   The generic solver keeps calling the function
   whose address is passed, until the light travel
   solution converges. This usually takes 3 or 4 iterations.

2. Astronomy_BackdatePosition
   This is a more specific solver that uses Astronomy_CorrectLightTravel
   to backdate the position of a target body as seen from an
   observer body at a specified observation time.
   It implements the aberration option needed by Astronomy_HelioVector.
   Astronomy_HelioVector now uses Astronomy_BackdatePosition,
   instead of having a redundant light travel solver,
   so the code isn't much larger than it was before.
2022-05-29 18:05:08 -04:00
Don Cross
636c4196bb C gravsim: added more functions
Added the following functions:

    GravSimTime
    GravSimNumBodies
    GravSimOrigin
    GravSimSwap

The GravSimSwap function allows an instantaneous "undo"
of a simulation step, which required refactoring the internal
data structures of the simulator. I did this because I realized
I needed a way to undo exploration of time steps near a fixed
current time. This will make it easier to implement a
light travel time solver.
2022-05-13 13:38:25 -04:00
Don Cross
f6ae31c619 C gravsim: removed option parameter.
I have decided the ability to select different
collections of gravitating bodies causes far
more complexity in the code than it is worth.

So now the gravity simulator always calculates
the Sun and all planets except Pluto.
This greatly simplifies the core code, gets
a good balance between efficiency and accuracy,
and makes the test matrix much simpler.
2022-05-12 13:35:13 -04:00
Don Cross
b2c69ddcfd C gravsim: bug fixes, flexible origin body.
Added an extra parameter `originBody` when creating
a new gravity simulator. This defines the
body center used as a coordinate origin for
both input state vectors and output state vectors.
This allows the caller to do everything in barycentric,
heliocentric, geocentric, or planetocentric coordinates.
This is important to avoid redundant calculations,
since we already have to calculate most/all of the
Solar System bodies anyway.

Fixed a bug: the unit tests were not using the `option`
parameter that was supposed to be passed to
Astronomy_GravSimInit. It was always using the GRAVSIM_ALL_PLANETS
option, which is why the tests always calculated the same answers.

The way I was measuring error was a little dodgy.
I reworked it to work without assuming anything about
the struct layout of astro_state_vector_t in memory.
I also always made it measure relative error converted
into arcminutes, so it is easier for me to understand
the numbers.

There are still excessively large calculation errors
that need to be debugged, so this is a work in progress.

$ ./ctest gravsim
C GravSimFile(0 : barystate/Ceres.txt   ): PASS (count = 731, pos error =  1.8348 arcmin, vel error =  1.7127 arcmin)
C GravSimFile(0 : barystate/Pallas.txt  ): PASS (count = 731, pos error =  1.7055 arcmin, vel error =  1.3432 arcmin)
C GravSimFile(0 : barystate/Vesta.txt   ): PASS (count = 731, pos error =  1.5655 arcmin, vel error =  1.4338 arcmin)
C GravSimFile(0 : barystate/Juno.txt    ): PASS (count = 731, pos error =  1.1724 arcmin, vel error =  0.8732 arcmin)
C GravSimFile(1 : barystate/Ceres.txt   ): PASS (count = 731, pos error =  0.5821 arcmin, vel error =  0.5398 arcmin)
C GravSimFile(1 : barystate/Pallas.txt  ): PASS (count = 731, pos error =  0.4566 arcmin, vel error =  0.3327 arcmin)
C GravSimFile(1 : barystate/Vesta.txt   ): PASS (count = 731, pos error =  0.8185 arcmin, vel error =  0.7616 arcmin)
C GravSimFile(1 : barystate/Juno.txt    ): PASS (count = 731, pos error =  0.3206 arcmin, vel error =  0.2692 arcmin)
C GravSimFile(2 : barystate/Ceres.txt   ): PASS (count = 731, pos error =  0.5821 arcmin, vel error =  0.5398 arcmin)
C GravSimFile(2 : barystate/Pallas.txt  ): PASS (count = 731, pos error =  0.4566 arcmin, vel error =  0.3327 arcmin)
C GravSimFile(2 : barystate/Vesta.txt   ): PASS (count = 731, pos error =  0.8185 arcmin, vel error =  0.7616 arcmin)
C GravSimFile(2 : barystate/Juno.txt    ): PASS (count = 731, pos error =  0.3206 arcmin, vel error =  0.2692 arcmin)
C GravSimFile(0 : heliostate/Ceres.txt  ): PASS (count = 731, pos error =  0.0692 arcmin, vel error =  0.0659 arcmin)
C GravSimFile(0 : heliostate/Pallas.txt ): PASS (count = 731, pos error =  1.0762 arcmin, vel error =  0.8765 arcmin)
C GravSimFile(0 : heliostate/Vesta.txt  ): PASS (count = 731, pos error =  4.6165 arcmin, vel error =  4.2126 arcmin)
C GravSimFile(0 : heliostate/Juno.txt   ): PASS (count = 731, pos error =  1.0013 arcmin, vel error =  0.7634 arcmin)
C GravSimFile(1 : heliostate/Ceres.txt  ): PASS (count = 731, pos error =  1.2524 arcmin, vel error =  1.1585 arcmin)
C GravSimFile(1 : heliostate/Pallas.txt ): PASS (count = 731, pos error =  2.3224 arcmin, vel error =  1.8889 arcmin)
C GravSimFile(1 : heliostate/Vesta.txt  ): PASS (count = 731, pos error =  2.2375 arcmin, vel error =  2.0198 arcmin)
C GravSimFile(1 : heliostate/Juno.txt   ): PASS (count = 731, pos error =  0.4975 arcmin, vel error =  0.4193 arcmin)
C GravSimFile(2 : heliostate/Ceres.txt  ): PASS (count = 731, pos error =  1.2524 arcmin, vel error =  1.1585 arcmin)
C GravSimFile(2 : heliostate/Pallas.txt ): PASS (count = 731, pos error =  2.3224 arcmin, vel error =  1.8889 arcmin)
C GravSimFile(2 : heliostate/Vesta.txt  ): PASS (count = 731, pos error =  2.2375 arcmin, vel error =  2.0198 arcmin)
C GravSimFile(2 : heliostate/Juno.txt   ): PASS (count = 731, pos error =  0.4975 arcmin, vel error =  0.4192 arcmin)
C GravSimFile(0 : geostate/Ceres.txt    ): PASS (count = 731, pos error =  6.5958 arcmin, vel error =  6.5102 arcmin)
C GravSimFile(0 : geostate/Pallas.txt   ): PASS (count = 731, pos error = 11.1674 arcmin, vel error =  8.7643 arcmin)
C GravSimFile(0 : geostate/Vesta.txt    ): PASS (count = 731, pos error = 10.6710 arcmin, vel error = 12.7938 arcmin)
C GravSimFile(0 : geostate/Juno.txt     ): PASS (count = 731, pos error =  7.3953 arcmin, vel error =  9.4322 arcmin)
C GravSimFile(1 : geostate/Ceres.txt    ): PASS (count = 731, pos error =  8.5754 arcmin, vel error =  8.4810 arcmin)
C GravSimFile(1 : geostate/Pallas.txt   ): PASS (count = 731, pos error = 13.2944 arcmin, vel error = 10.4513 arcmin)
C GravSimFile(1 : geostate/Vesta.txt    ): PASS (count = 731, pos error =  7.1130 arcmin, vel error =  8.4571 arcmin)
C GravSimFile(1 : geostate/Juno.txt     ): PASS (count = 731, pos error =  5.5835 arcmin, vel error =  7.0996 arcmin)
C GravSimFile(2 : geostate/Ceres.txt    ): PASS (count = 731, pos error =  8.5754 arcmin, vel error =  8.4810 arcmin)
C GravSimFile(2 : geostate/Pallas.txt   ): PASS (count = 731, pos error = 13.2944 arcmin, vel error = 10.4513 arcmin)
C GravSimFile(2 : geostate/Vesta.txt    ): PASS (count = 731, pos error =  7.1130 arcmin, vel error =  8.4571 arcmin)
C GravSimFile(2 : geostate/Juno.txt     ): PASS (count = 731, pos error =  5.5835 arcmin, vel error =  7.0996 arcmin)
C GravitySimulatorTest: PASS (pos score = 13.2944 arcmin, vel score = 12.7938 arcmin)
2022-05-10 21:20:05 -04:00
Don Cross
b31a66eba8 C gravity simulator: work in progress
Starting implementation of a generalized gravity simulator.
Already calculating the movement of Ceres, but with less
accuracy than I had hoped. I don't know if the lack of modeling
pull of the other asteroids has a larger effect than I expected,
or there is just something wrong with the implementation.
2022-05-09 17:13:51 -04:00
Don Cross
2247084943 C/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 10:26:25 -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
8c923d49d6 Kotlin: added more data types.
Ported the following types to the Kotlin code:

    GlobalSolarEclipseInfo
    EclipseEvent
    LocalSolarEclipseInfo
    TransitInfo
    ShadowInfo
    IllumInfo
    AxisInfo
    NodeEventKind
    NodeEventInfo

Made some wording fixes in the documentation for the
other languages.
2022-03-25 15:52:27 -04:00
Don Cross
f0c4eb05db Kotlin: Ported some more data types.
Ecliptic
Topocentric
SeasonsInfo
MoonQuarterInfo
LibrationInfo
HourAngleInfo
ElongationInfo
ApsisKind
ApsisInfo
EclipseKind
LunarEclipseInfo
2022-03-24 20:17:14 -04:00
Don Cross
0943f058c9 Fixed #165 - expose sidereal time function.
There was already an internal function for calculating
Greenwich Apparent Sidereal Time (GAST). By request,
I have exposed this function for outside users.

Added a minimal unit test to verify the function is
callable and returns the correct result for one case.
This function is already exhaustively tested by unit
tests that verify other functions that already called
this function when it was internal, so minimal testing
is sufficient in this case.
2022-03-15 20:48:02 -04:00
Don Cross
d843775122 Fixed #148 - calculate Lagrange points.
Added the following new functions to all 4 languages:

MassProduct: find the GM product for all Solar System bodies.

LagrangePoint: calculate L1..L5 state vectors for a pair of bodies.

LagrangePointFast: calculate L1..L5 state vectors given
state vectors and GM products of a pair of bodies.
2022-03-13 20:56:32 -04:00
Don Cross
3952ebd9af C Lagrange: Add simpler-to-use function for most cases.
In most cases, people calculating Lagrange points will just
want to pass in the bodies and not have to worry about calculating
their state vectors and masses.

Renamed Astronomy_LagrangePoint to Astronomy_LagrangePointFast.
Added new function Astronomy_LagrangePoint that accepts body enum
values instead of state vectors and masses. It knows to optimize
the precision of the calculation by calling GeoMoonState for the
Earth/Moon case.
2022-02-19 14:24:20 -05:00
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
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
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
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
c36f16e1be PY RotationAxis function. 2021-12-02 16:11:50 -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
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
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
b2101c6cfe C HelioState: calculates heliocentric position and velocity.
This is the C version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 14:31:48 -05:00
Don Cross
64785cecf4 C version calculates geocentric and barycentric EMB.
Now the C version of Astronomy Engine supports calculating
the Earth/Moon Barycenter (EMB) state vector (position and velocity)
relative to the Earth's center (geocentric) or relative
to the Solar System Barycenter (SSB).

Astronomy_BaryState() now supports body == BODY_EMB.

Added a new function Astronomy_GeoEmbState() to calculate
the geocentric state for the EMB.

Both have been verified using test data generated by JPL Horizons.
2021-11-13 20:58:42 -05:00
Don Cross
3ad637f225 Implemented C function Astronomy_GeoMoonState.
I wanted to test the geocentric Moon state vector I
calculate for the sake of the Moon state relative to
the Solar System Barycenter (SSB). Because the geocentric
portion has such a small magnitude, I decided to go ahead
and expose GeoMoonState as part of the API, and create
a test for it specifically. I used JPL Horizons to generate
the test file GeoMoon.txt.
2021-11-13 20:12:55 -05:00