Commit Graph

538 Commits

Author SHA1 Message Date
Don Cross
6753e6b8e6 Raytracer: Explicitly build astronomy.c as C++.
Based on a discovery made by someone helping me get
Astronomy Engine building on the Mac. In some versions
of g++ (aliased to clang), if you don't explicitly tell
the compiler to treat .c files as C++, it gives a warning
that escalates to an error due to -Werror.

So I added the same fix to the raytracer build:
pass in the option '-x c++'.
2022-01-04 20:03:28 -05:00
Don Cross
b2f9219b56 Updated copyrights for 2022. 2022-01-04 18:55:20 -05:00
Don Cross
a23a3c7efb Raytracer: finished planet color table. 2022-01-03 19:56:18 -05:00
Don Cross
590218d139 Raytrace: fixed problem rendering Pluto.
Pluto is so far away that is angular size seen from Earth
is very small. I had to tweak my internal scaling constants
so that the raytracer was able to resolve it.
2022-01-02 20:47:28 -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
2277b5c26d Raytrace: Refactor scale constants to be global. 2022-01-02 19:20:22 -05:00
Don Cross
8a95ff0ee3 Raytrace: Default to auto-spinning the planet. 2022-01-02 19:05:16 -05:00
Don Cross
4fee2659da Raytracer: auto-zoom to planet's angular diameter. 2022-01-02 17:18:14 -05:00
Don Cross
7a3d1bd085 Jupiter raytrace: factor out code for adding moons. 2022-01-01 19:59:24 -05:00
Don Cross
6aac859020 Saturn raytrace: forgot to orient the planet's equator. 2022-01-01 19:36:48 -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
3502906204 Raytracer: added -v option to print verbose messages. 2021-12-28 19:54:35 -05:00
Don Cross
1de7085ac2 Raytracer: auto-rotate image for planet's axis.
The raytracer now includes the option -s (without a numeric
spin angle on the command line) to automatically calculate
the spin angle needed to bring the planet's north pole
exactly upward in the generated image.
2021-12-27 21:37:52 -05:00
Don Cross
082194d2b6 Jupiter raytracer: better rotation matrix.
Improved the way I create the rotation matrix that
aims the virtual camera at Jupiter. The camera still
aims exactly at Jupiter, but this time it defaults
to having the left/right pixel direction aligning
with the Earth's equator. By experiment, I can spin
the longitudinal camera axis by -10 degrees and get
a good fit with Jupiter's equatorial plane. I will
adjust this more exactly in a future commit.
2021-12-20 21:44:58 -05:00
Don Cross
e57dd0a26b Added aim test sanity check in raytracer.
Instead of just printing both unit vectors that should be the same,
actually check that they point the same direction with a very
tight tolerance.
2021-12-19 21:33:34 -05:00
Don Cross
70489c3dc6 Raytracer: allow specifying non-square images.
Now the raytracer requires the user to pass in
both the pixel width and pixel height on the command line.
This allows for generating non-square images, which will
be necessary for the general case of imaging the moons
with respect to the planet.
2021-12-19 17:27:33 -05:00
Don Cross
707382aaf2 Raytracer: minor coding style fixes. 2021-12-18 17:27:36 -05:00
Don Cross
51260bcbc1 Raytracer: modernized C++ iterator loops. 2021-12-18 17:23:01 -05:00
Don Cross
60728cf8b5 Raytracer: eliminated unnecessary class Optics.
Now that I have eliminated refraction and reflection
from the astronomy raytracer, there is no need for an
Optics class that represents matte, gloss, and index
of refraction.
2021-12-18 17:12:04 -05:00
Don Cross
503ee86bef Removed more fossils from the raytracer. 2021-12-18 17:05:27 -05:00
Don Cross
05db236ae1 Removed reflection and refraction from raytracer.
Reflections and transparent refractions are not needed
for planet images. I removed all this unnecessary code.
2021-12-18 16:53:22 -05:00
Don Cross
8ef54a58cf More efficient raytrace of Jupiter's moons.
Model Jupiter's moons using the Sphere class, rather
than the Spheroid class. Sphere is more efficient
to calculate.
2021-12-18 16:43:29 -05:00
Don Cross
216f2628d8 Trimmed more stuff from raytracer. 2021-12-18 16:35:00 -05:00
Don Cross
8ae0b7e16c Trimmed some debug code from the raytracer. 2021-12-18 16:23:20 -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
232cc9480b Added spin and zoom options to Jupiter raytracer. 2021-12-15 19:32:38 -05:00
Don Cross
cfe633af8f Allow flipping the raytraced image.
The raytracer now accepts a -f option to
flip the image, to match the inverted view
through some telescopes.
2021-12-15 19:15:17 -05:00
Don Cross
680fb48627 I had incorrect date/time for the Jupiter image.
I went back and discovered I made an error
converting local time to UTC when I calculated
the Jupiter raytrace image. Now it matches the
actual photo.
2021-12-14 21:40:26 -05:00
Don Cross
415d1c57d1 Fixed raytracer problems due to numeric scale.
I had lots of problems with using AU as my scale units.
By changing to 10000*km units, the vector equation solver
works correctly again, and I actually get an image of Jupiter
and its moons. However, it does not match the test photo:
Ganymede does not appear close to the planet, nor is there
a shadow of it on the planet. I will have to debug that
separately.
2021-12-14 20:35:42 -05:00
Don Cross
bc93faeb04 More work in progress: Jupiter imager.
Starting to work through adaptation of existing
raytracer code to generate geometrically accurate
images of Jupiter and its moons. Not yet working,
but I believe I am at least aiming the camera in
the right direction.
2021-12-13 21:00:04 -05:00
Don Cross
88a1ab7290 Work in progress: Jupiter raytracer. 2021-12-13 16:37:10 -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
82a4d2c996 Starting to work on a rendering demo of Jupiter and its moons. 2021-12-09 21:43:34 -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
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
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
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
Don Cross
19f157e71c Full support for geocentric and barycentric EMB.
Now the Python 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).

This completes support for this feature across C, C#, JavaScript, and Python.
2021-11-14 11:54:57 -05:00
Don Cross
926eae349a C demos allow getting observer from environment.
The function ParseArgs (used by many of the C demo programs)
now allows an alternative command line usage. If the '-e'
option is specified, it looks for the environment variable setting:

ASTRONOMY_ENGINE_OBSERVER='latitude longitude'

This form allows the demo programs to be configured for a given site.
2021-11-14 09:53:45 -05:00
Don Cross
029588da06 JavaScript: Calculate state vectors for barycentric/geocentric moon, EMB. 2021-11-14 00:37:52 -05:00
Don Cross
71cb92df08 Calculate barycentric state of Pluto.
The BaryState function did not support Pluto before.
Refactored the code so that the internal CalcPluto function
returns both the position and velocity, and its caller
can select from heliocentric or barycentric coordinates.
HelioVector asks for heliocentric coordinates and keeps
only the position vector. BaryState asks for barycentric
coordinates and returns both position and velocity.

I added test data for Pluto generated by JPL Horizons.
It turns out the Pluto system barycenter is the best fit
for TOP2013, presumably because Charon causes Pluto to
wobble quite a bit.

I also generated JPL Horizons test data for the Moon
and the Earth/Moon barycenter, anticipating that I will
support calculating their barycentric state vectors soon.

I had to increase the enforced size limit for minified
JavaScript from 100000 bytes to 120000 bytes.
I guess this is like raising the "debt ceiling".

Fixed a bug in Python unit tests: if "-v" verbose option
was specified, it was printing a summary line for every
single line of input, instead of a single summary after
processing the whole file, as was intended. This is one
of those Python whitespace indentation bugs!
2021-11-13 16:07:00 -05:00
Don Cross
4e6cb282f5 Use original Pluto gravsim with finer time steps.
I'm getting much better accuracy sticking with my original
gravity simulator, just with smaller time increments, than
I was with the Runge-Kutta 4 method. The PlutoStateTable
gets a bit larger (51 state vectors instead of 41), but the
accuracy is so much higher.

Removed the Runge-Kutta code because I won't be going back to it.
2021-11-12 16:22:14 -05:00
Don Cross
a5fd814ba1 Finished single-source-of-truth for Pluto constants.
The Pluto gravity simulator constants now come from
a single source: pluto_gravsim.h. This will allow me
to experiment with the Pluto state table to get a better
compromise between size and accuracy.
2021-11-12 15:30:56 -05:00