Commit Graph

35 Commits

Author SHA1 Message Date
Don Cross
33de407723 Added C++ demo for alt/az window search.
See the following discussion for context:

https://github.com/cosinekitty/astronomy/discussions/308

Added a demo program that shows how to search for when
a body enters a window defined in terms of an observer's
horizontal frame of reference, given a range of altitudes
and a range of azimuths.
2023-06-18 16:14:52 -04:00
Don Cross
591ad2b11a Fixed bug in demo: camera.c
The camera demos all have a bug where I was calculating
the angle of the sunlit side of the Moon incorrectly.
The arguments to atan2 were backwards.
Added test data for Florida, New Zealand, and Canada
that are backed up by photographic evidence and
my first-hand observation.
2023-03-24 21:46:41 -04:00
Don Cross
86fde0d5cd C demo: Calculate true solar time from the Sun's hour angle. 2023-02-12 12:03:43 -05:00
Don Cross
956ad5fa2d Added demo program: ecliptic_vector.c
This program demonstrates converting equatorial
vectors to ecliptic vectors using a rotation matrix.
2022-05-20 20:17:09 -04:00
Don Cross
efc59ae6fc Refactored demo tests.
I refactored the unit tests for all the demo programs
to follow a different pattern that makes it simpler
to add more demo tests in the future.

The main thing is that correct output and generated
output are now in separate directories `correct` and `test`.
I have moved the test scripts from `test/test` to `./demotest`
in all the langauge demo directories.

This makes it simpler to clean up any stale generated
files before each test run by `rm -f test/*.txt`.

I stumbled across this while making the Java demo tests,
and it was a better solution, so now all the other languages
are consistent with the Java demo tests.

In the C demo tests, I also decided to compile all the
binary executables into a subdirectory `bin` that can
be cleaned out before each run, to make sure there are
no stale executables from an earlier run.
2022-04-30 21:01:11 -04:00
Don Cross
edcf924806 worldmap.cpp demo now finds zenith locations.
The demo worldmap.cpp now also prints out the
geographic locations where the Sun/Moon appear
to be straight up (at the zenith) for the given time.
This illustrates that Astronomy_VectorObserver can
turn a geocentric vector into a location on the
Earth that is in the same direction from the Earth's
center that a given celestial body lies.
2022-04-09 13:12:15 -04:00
Don Cross
1315488c06 Added C++ demo for efficiently globe calculations.
The new demo worldmap.cpp generates a PNG image of
a Mercator projection of the Earth, showing color-coded
intensity of sunlight (yellow) and moonlight (blue).
This sample program shows how to efficiently calculate
horizontal altitudes of the Sun and Moon across many
different geographic locations, for a given observation time.
2022-04-09 12:10:41 -04:00
Don Cross
0c4e3dfec3 Fixed #187 - Seasons() fixes from kotlin branch.
Backported fixes to the Seasons functions in
C, C#, Python, and JavaScript. They were failing
to find equinoxes and/or solstices for distant
year values.

Also brought over some other minor code cleanup.
2022-04-08 18:18:45 -04:00
Don Cross
5744c9ebe9 Moon phase demos also calculate illuminated fraction.
The phrase "Moon phase" is ambiguous, because sometimes
it means relative ecliptic longitude, other times it means
illuminated fraction. The "moonphase" demos were only
calculating the relative ecliptic longitude, which was
confusing. Now they calculate both.
2022-02-20 15:27:46 -05:00
Don Cross
cb4c9a6549 Fixed mistake in raytracer. Stop using 'realpath'.
I found a mistake in the raytracer's Spheroid class,
thanks to a warning about an unused member variable.
I don't believe it had any effect on the currently
generated images, but it was important to fix it before
I ever do any set operations on Spheroids.

On macOS, there is no 'realpath' command by default.
So I eliminated some more attempts to use 'realpath'
in the demo test scripts.

Renamed the GitHub Actions tests to be consistent:
    Astronomy-Engine-Linux
    Astronomy-Engine-Macos
2022-01-07 18:30:15 -05:00
Don Cross
0547aafc2b Made 'camera' demo checks tolerant of floating point roundoff.
The demo tests on Mac OS failed because of very tiny
floating point discrepancies that don't matter.
Changed the output of the "Moon check" so that slight
differences in vector residue no longer fail the unit tests.
2022-01-06 21:25:26 -05:00
Don Cross
c93df6d4d4 Add raytracer test to the demo tests.
Verify that the raytracer builds and runs without error.
2021-12-15 20:04:45 -05:00
Don Cross
37084a156d C Earth gravity calculation.
Implemented the C function Astronomy_ObserverGravity.
It implements the WGS 84 Ellipsoidal Gravity Formula,
yielding the effective observed gravitational acceleration
at a location on or above the Earth's surface.
Wrote a demo program that also serves as a unit test.
I verified a few of the calculations, so the file
demo/c/test/gravity_correct.txt also serves as correct
unit test output.
2021-07-19 14:23:27 -04:00
Don Cross
2eec19fc23 Implemented C version of demo 'triangulate'.
Just like the Python version, this program calculates
the best-fit intersection point for two lines of sight
as seen by two observers. It demonstrates converting
back and forth between geographic coordinates and
geocentric vectors.
2021-06-22 10:50:47 -04:00
Don Cross
9287fedec1 Added demo galactic.c for converting GAL to HOR.
This demo program converts galactic coordinates to
local altitude an azimuth for a given geographic
location and time.
2021-06-14 11:36:14 -04:00
Don Cross
9eeafc4d16 Updated camera.c demo to print magnitude, phase angle, and Sun angle. 2021-03-23 19:37:49 -04:00
Don Cross
fcd6ec4d05 Starting to work on support for camera orientation in the C version.
Added C function Astronomy_Pivot to transform a rotation matrix
by rotating it around one of its coordinate axes by a given angle.

Added C function Astronomy_IdentityMatrix that just returns
an identity matrix that can be used as the starting point in
a series of transforms.

C function Astronomy_Equator now also returns the topocentric
equatorial location in the form of a cartesian vector.
This is in a new member of the astro_equatorial_t struct
called 'vec'.

The unit test in ctest.c "Rotation_Pivot()" could be improved
with more and better tests.

Created a demo program camera.c that illustrates using
Astronomy_Pivot() to help calculate the tilt of the sunlit
side of the Moon, as seen by a camera pointing right at it.
The resulting tilt angle is not yet verified.
I need to have some confirmation that it is correct before
porting to the other languages.
2021-03-22 22:30:04 -04:00
Don Cross
246ac47d2b Fixed a failure to find a full moon using certain start dates.
In all four versions of Astronomy Engine (C, C#, JavaScript, and Python),
starting a search for a full moon near December 19, 2020 would fail.
I added a unit test to all four languages and it failed consistently
across them all.

The root cause: I was too optimistic about how narrow I could make
the window around the approximate moon phase time in the
SearchMoonPhase functions. Finding the exact moon phase time failed
because it was outside this excessively small window around the approximate
time. I increased the window from 1.8 days to 3.0 days.
This should handle all cases with minimal impact on performance.

Now all four of the new unit tests pass.
2020-12-18 14:29:41 -05:00
Don Cross
8f16f0a5ae Pluto integrator: finished porting to Python.
I believe this wraps up the Python integrator.
It now works in all 4 languages and passes all tests.
Fixed up demo tests to match new output.
Turned on Travis CI checking in this branch again.
2020-08-24 20:54:20 -04:00
Don Cross
686401d3ef Added C function Astronomy_FormatTime.
It's surprisingly tricky to print a time rounded to the
nearest millisecond, second, or minute using the C code.
I saw a case where positions.c printed '2020-07-09 04:29:60'.
Because printing a date/time is a basic need of an astronomy program,
I added the new function Astronomy_FormatTime to do this.
All the demo programs use this new function, which required
me to update the correct reference output for the unit tests.
2020-07-09 15:25:28 -04:00
Don Cross
b31c0185df TOP2013: greatly decrease waviness in Pluto curve.
The high-frequency wobble in the Pluto position function was bothering me.
Decreased the arcminute error threshold from 1.0 to 0.5, resulting
in a much larger model, but a lot less ripple:

   547 [    78   140    94   115    21    99]
2020-07-07 15:38:39 -04:00
Don Cross
d89b9a19d5 C: Replaced Chebyshev with TOP2013 for Pluto calculations.
Now the C version of Astronomy Engine is using the TOP2013 model
of Pluto instead of resampled Chebyshev polynomials.

I added temporary hacks to ignore differences for Pluto between
C output and output from Python, JavaScript, and C#.
I will remove these after all four languages are using TOP2013.
See the variable ToleratePlutoErrors in ctest.c.

ctest.c DiffLine function now understands that longitude-like
angles (right ascension and azimuth) can wrap around, and to tolerate
very small angular differences that happen to straddle the wraparound
value. I should have done this a long time ago, but it never caused
problems before now.

C PlanetApsis has a serious problem with Pluto that I didn't expect.
I need to investigate and understand this before porting to other
languages. For now, I hack around it using ToleratePlutoErrors.
2020-07-06 13:47:05 -04:00
Don Cross
4f842627da Fixed mistake in GeoVector(SUN): we do need to correct for light-travel time.
To be consistent, when calculating the geocentric position of the Sun,
we do need to correct for light travel time just like we would for any
other object. This reduces the maximum time error for predicting transits
from 25 minutes to 11 minutes.

Also had to disable aberration when calculating moon phases
(longitude from Sun) in order to keep a good fit with test data.
2020-06-13 13:45:59 -04:00
Don Cross
d9e2ea5816 Added C version of lunar eclipse demo.
Also added better comments to Python version.
2020-05-17 13:02:18 -04:00
Don Cross
9ea6a0664f Python: Use Espenak/Meeus formula for calculating Delta T. 2020-05-15 19:28:54 -04:00
Don Cross
4354e72e52 Minor tweaks due to sun, moon radius changes for lunar eclipse calculations.
Adding support for lunar eclipse calculations in the C code
caused me to tweak the values of the Sun and Moon radii.
This in turn caused unit test failures.
Made slight changes to the unit tests to get things passing again.
2020-05-13 15:52:22 -04:00
Don Cross
c08d29e7d9 Added missing cleanup in C demo script. 2019-12-23 11:38:41 -05:00
Don Cross
c008dcdff6 Finished C demo program horizon.c.
This program demonstrates converting ecliptic coordinates
to horizontal coordinates at a given time for a given observer.
It searches for the two locations on the horizon where the
ecliptic plane intersects it.
2019-12-12 12:35:00 -05:00
Don Cross
cb22bd40eb Added culminate.py demo program. 2019-08-10 18:02:15 -04:00
Don Cross
743394b6d7 Added C example: culminate. 2019-06-18 21:00:57 -04:00
Don Cross
ab642feb21 Added C example: calculating seasons. 2019-06-16 20:39:40 -04:00
Don Cross
7b7294fff9 Print name of each C example before testing it. 2019-06-14 21:56:43 -04:00
Don Cross
3558f43d48 Added C example: rise and set times for Sun and Moon. 2019-06-14 21:50:26 -04:00
Don Cross
d476465b6d Actually test moonphase.js and moonphase.c. Test after generating code. 2019-06-13 21:38:27 -04:00
Don Cross
58fa90a0bf Reworked tests of C examples.
Moved test files into separate test directory (cleaner).
Make C and nodejs 'position' tests generate identical output.
2019-06-13 21:04:45 -04:00