Here are some C++ programs I wrote a little while ago for generating basic
It all currently runs on Unix only, though could probably be ported to
Windows without too much trouble (it will compile and run with the
cygwin tools though). Use of the
ImageMagick tools (available for Windows and Unix) is highly recommended.
Interface is command line only; of course a little TCL front end would be nice.
Images need to be converted to .ppm format, this is easily done using
the ImageMagick mogrify utility, eg:
mogrify -format ppm earth.jpg
converts earth.jpg to earth.ppm.
PPM is a simple uncompressed format (which is why we use it), but the
images can take up a lot of disk space.
The software uses mmap to
memory map the input files, so we don't have the overhead of reading
in the entire file to project eg. just a small portion of it.
We expect PPM type 6 files, with binary RGB values, so
files should begin something like:
First line of header is format identifier, followed by size in pixels
and color depth, followed by packed data bytes, 3 bytes per pixel for
as long as it takes.
Using the data in the image specified by the -f option (or
images/earth.ppm if no file specified), generate a projected image in
PPM format and write to standard output.
Not all options are covered here.
Latitude and longitude of the central point of the map are specified
with the -lat and -long parameters, in
degrees, longitude measured to the east. The -tilt
specifies a rotation about the centre point and the -turn
parameter specifies a vertical rotation of the image.
-f specifies the input file to use. As described above,
this should be a ppm file, for correct result in Plate Carree
projection (ie. x is longitude, y is latitude). Default is
Gnomonic projection, centred on North Atlantic. Note how projection
turns great circles in to straight lines.
The -x, -y
and -z parameters specify the viewing position, measured
in planet radii. Illumination from the sun may be simulated with the
-sun parameter, in which case the -date and
-time parameters are relevant. Date is day number in
year, and time is GMT (or UTC, the precise timescale probably
doesn't matter at this scale) hours from midnight, in decimal hours (so
4.5 is half past four in the morning). The equation of time, angular
radius of the sun etc. is taken in to account, so I hope that the
terminator position is fairly accurate (this is why sunrise isn't
precisely at 6-00 on the spring equinox).
Oblateness may be changed with the -ox, -oy
and -oz parameters, in case you want a picture of Jupiter
or just a mildly amusing view of earth:
Using the data in the starlist on standard input, generate a
projection image in PPM format and write to standard output.
Not all options are covered here.
The stars executable projects an image of the stars using
the chosen projection. For star projection Right Ascension
(-ra)and Declination (-dec) are used to
determine the centre of the image. RA measured in decimal hours to the
west and declination in decimal degrees. The star data (in
starlist) is taken from the Bright Star
Catalogue mangled in to a more easily readable (by scanf)
form. The format is more or less:
BV Colour Value.
RA, decimal hours.
Declination, decimal degrees.
RA proper motion, arcsecs per year.
Declination proper motion, arcsecs per year.
Comment string with catalogue number and abbreviated name.
The program reads the starlist from standard input, so we can do, for
A slightly naff attempt to show star colour based on
the BV value can be switched on with the -bv option.
The code implements both forward and backwards projection – the former
for drawing grid lines and stars, the latter for projecting
Key files are:
project.cpp: the main driver program for map projection
stars.cpp: the main driver program for star projection
transform.h, transform.cpp: the details of the projections
equations.h, equations.cpp: various mathematical and astronomical utilities.
image.h, image.cpp: image manipulation.
matrix.h, matrix.cpp: 3 x 3 matrix manipulation.
utils.h, utils.cpp: option and error handling.
Usual disclaimers; you'll be lucky if this software doesn't
make your hard disk explode etc. GPL applies. I wrote this stuff for fun
and will be happy if anyone finds it useful. Needless to say,
commercial use without permission will be frowned upon.