Planet planet generating program Copyright 1997 Torben AE. Mogensen The program generates planet maps based on recursive spatial subdivision of a box containing the globe. The output is a colour PPM bitmap. Usage: planet [options] options: -s seed Specifies seed as number between 0.0 and 1.0 -w width Specifies width in pixels, default = 800 -h height Specifies height in pixels, default = 600 -m magnification Specifies magnification, default = 1.0 -o output_file Specifies output file, default is standard output -l longitude Specifies longitude of centre in degrees, default = 0.0 -L latitude Specifies latitude of centre in degrees, default = 0.0 -G gridsize Specifies vertical gridsize in degrees, default = 0.0 (no grid) -g gridsize Specifies horisontal gridsize in degrees, default = 0.0 (no grid) -i init_alt Specifies initial altitude (default = -0.015) -c Colour depends on latitude (default: only altitude) -b Reverse background colour (default: black) -pprojection Specifies projection: m = Mercator (default) p = Peters s = Stereographic o = Orthographic g = Gnomic a = Area preserving azimuthal c = Conical (conformal) f = Find match, see below The order of the options is irrelevant, except that later options override earlier ones. As an example, to generate a stereographic projection of a planet generated from seed 0.4 with magnification 3 centered around 30° north, 35° east with gridlines every 10 degrees on latitudes and every 20 degrees on longitudes, outputting the result as a 320x256 bitmap in the file p.ppm, use the command planet -ps -s 0.4 -m 3 -L 30 -l 35 -G 10 -g 20 -w 320 -h 256 -o p.ppm The initial altitude (-i) option specifies the initial altitude of the corners of the box, before subdivison. Increasing this will increase the amount of land on the planet and vice-versa. The default value is -0.015, which gives a slight preference for water. Changing this value by +/- 0.001 will change the water percentage by approximately 1% (depending on the planet in question). If you, for example, want a planet with 70% water, you can make a world map using the -pp option (which prints the water percentage) and adjust the initial altitude using the -i option until the indicated water percentage is 70. The projections: The Mercator and Peters projection project the globe onto a cylinder wrapped around the equator of the globe. The cylinder is then unfolded to give a flat map. Hence, lines of equal longitude or latitude map to vertical or horisontal lines respectively. The Mercator projection preserves angles (it is a conformal mapping) and compass directions but distorts area quite heavily towards the poles. The Peters projection project a point horisontally out to the cylinder (which is afterwards strected by a factor of 2). It preserves relative area, but not angles or compass directions (expect for directly east, west, north or south). Areas near the equator will appear stretched up/down (by a factor of 2 at the equator) whereas areas near the poles are flattened. At latitude 45°, areas have approximately the right proportions. When the Peters projection is specified, the water percentage is printed on the stderr stream. This is mainly interesting if a full-world map is generated (magnification = 1). The Mercator or Peters map at magnification 1 is scaled to fit the Width. Assuming an Earth-sized planet of circumference 40000km we can relate this to scaling factors. To find the equatorial scaling factor, divide 4x10^9 by the width of the map (in centimeters) and then by the magnification factor. Hence, a map of width 20cm at magnification 2 has a scale of 1:1x10^8 at equator. For the Mercator projection, the scale at latitude L is 1/cos(L) times the equatorial scale. Hence, a map of width 20cm and magnification 2 has scale 1:1.416x10^8 at latitude 45° and scale 1:2x10^8 at latitude 60°. A number of azimuthal projections are available. Azimuthal projections project the globe onto a plane that touches the globe at the specified longitude and latitude. Azimuthal projections are approximately accurate at the centre of the map, but distort areas away from this. The different azimuthal projections distort in different ways: Stereographic projection projects a point on the surface by following a line that starts in the point on the globe opposite the point that touches the plane and goes through the point of interest until this line hits the plane. It preserves angles (i.e. local shape) but not area or compass directions. The entire globe is mapped onto the infinite plane, so you can get arbitrarily close to a full world map, but the distortion will be very severe when more than a hemisphere is shown. Orthographic projection projects at right angles to the plane. It preserves nothing of interest, but is what you would see if you view the planet from space (from infinite distance). It can never show more than a hemisphere (which is mapped to a circle). Gnomic projection projects along a line starting in the center of the globe. It has the property that great circles are mapped to straight lines, which makes it useful for navigating by sea or air. A hemisphere maps to the infinite plane, so it can never show all of a hemisphere and distortion gets heavy if you show an area close to a hemisphere in size. Area preserving azimuthal projection preserves relative areas, but not shapes or angles etc. It maps the entire globe onto a circle of a radius twice that of the globe, but distortion along the edges is severe. The orthographic projections are scaled so the diameter of the planet at magnification 1 is the full Height of the picture. Stereographic, gnomic and area preserving azimuthal projections use the same scale as orthographic in the center of the picture. To find the scaling factor (again assuming Earth-sized planets) at the centre of the picture, divide 1.273x10^9 by the height of the map (in centimeters) and the magnification factor. Hence, a map of height 20cm with magnification 2 will have a central scale of 1:3.18x10^7. This is independent of latitude. To obtain a scale of 1:S, multiply 1.273x10^9 by the height of the map (in cm) and divide by S to obtain the magnification factor to use with the program. To get e.g. 1:10^7 on a map of height 20cm, use -m 2546. As the size of the map in cm depends on how many pixels per cm the output media uses, the program can not calculate actual scales. The conical projection is a conformal (angle preserving) projection from the sphere onto a cone that touches the specified latitude. The cone is cut opposite the specified longitude and laid flat, so it appears like a pie section. As touching cones are not well defined for latitude 0 or ±90°, Mercator and stereographic projections (respectively) are substituted if these are specified. The scale at the center of the map is the same as for ortographic and stereographic projections. This projection is good for mapping areas that have large east-west extent and are not close to the equator (e.g. Russia). Using conical projection, all of the planet is mapped onto a finite section of a cone, so you can make complete world maps. It is, however, not really suited for this, as latitudes far away from the specified latitude are very distorted. Regardless of the projection used, on maps of small sections of the planet, the scale will differ very little across the map and the distortion will be small. Search feature: With the -pf option a map must be given on standard input. This map is 9 lines of 27 characters. The characters are: . : very strong preference for water (value=8) , : strong preference for water (value=4) : : preference for water (value=2) ; : weak preference for water (value=1) - : don't care (value=0) * : weak preference for land (value=1) o : preference for land (value=2) O : strong preference for land (value=4) @ : very strong preference for land (value=8) The program tries seeds starting from the specified and successively outputs the seed, rotation and initial altitude of the best current match, together with a small map of this. This is all ascii, no bitmap is produced. Note that the search is not (and can not be) intelligent: The seeds are tried in order and tested for matching. Hence, you should not expect exact matches or even very close unless you run the program for a _very_ long time. Note, however, that varying seeds by _very_ small amounts (at digit 13 or more) can produce maps with similar overall shape. Hence, you may want to try varying the last digits of the best matches to see if you get a better map this way. There is no way, however, that you can control the shape of the planet in advance. An example of a map specification is shown here: ,,::,,,,,:;:,:,,,,:;;:,,,,, ,,;:,,,,:;oo:o:,:;ooo;;:,,, ,:;o:,,,:ooOoOo:ooOOOo;;:,, :;oOo:,,:o:oOOOoOOOOoo;:,,, :oO@o:,,,:,:oOOOO:oo...,,,, ,:oO:,,,,,,,:oOoo:::.oO::,, ,,:o:,:;;:,,:oO;:,,,,o@O::, ,,,:,,;--;,,,:o;:,,,,:o;:,, ,,,,,;----;,,:;:,,::,:::,,, Various notes: At high magnifications, drawing grid-lines may take a long time due to a less than perfect implementation. Some colour constants are used in the source: BLACK, WHITE, BLUE0, BLUE1 (a range for sea) LAND0, LAND1 should give a range where LAND0 is green (used for low land) and LAND1 is brown or yellow (used for high land). All integer numbers between LAND0 and LAND1 are assumed to be on this scale. The colours may optionally be modified according to latitude to move the icecaps lower closer to the poles, with a corresponding change in land colours. It is assumed that pixels are square. I have included a procedure that will print the maps as ppm bitmaps (portable pixel map) on standard output. This can be replaced by routines printing in other formats by relatively little effort. I have tried to avoid using machine specific features, so it should be easy to port the program to any machine. Beware, though that due to different precision on different machines, the same seed numbers can yield very different planets. The IEEE standard should in theory guarantee identical results across IEEE compliant platforms, but this depends on whether the same default rounding modes are used. The primitive user interface is primarily a result of portability concerns. How to compile the program: On a unix platform, just write cc planet.c -o planet -lm -O or, if using Gnu C gcc planet.c -o planet -lm -O I don't know DOS enough to help you there, but I presume it is the same.