@menu
* Introduction::
+* Terrain Viewer::
* GNU Free Documentation License::
@end menu
-@node Introduction, GNU Free Documentation License, Top, Top
+@node Introduction, Terrain Viewer, Top, Top
@chapter Introduction
This planetarium currently is just a simple tellurion that shows the
(t 'GO)
@end example
-@node GNU Free Documentation License, , Introduction, Top
+@node Terrain Viewer, GNU Free Documentation License, Introduction, Top
+
+This planetarium includes a viewer for visualizing meshes. It can
+generate meshes from a few mathematical functions, and it can download
+elevation data from Google Earth.
+
+To generate a terrain from a simple mathematical function, startup
+mit-scheme and enter the following three s-expressions at the REPL
+prompt.
+
+@example
+ (load-option 'planetarium)
+ (ge '(planetarium terrain))
+ (write-function-terrain
+ "sample-terrain.txt"
+ -3 3 50
+ -3 3 50
+ (lambda (x y)
+ (let ((d^2+1 (+ (* x x) (* y y) 1)))
+ (* 1000 (/ (sin d^2+1) d^2+1)))))
+@end example
+
+A @file{sample-terrain.txt} file will be created in the current
+directory and filled with 2500 samples of the given function as x and
+y vary between -3 and 3. The function is scaled by 1000 because it
+is interpreted as meters given degrees of longitude and latitude.
+
+To view your sample terrain enter the following four s-expressions.
+
+@example
+ (define v (make-terrain
+ 'filename "sample-terrain.txt"
+ 'rows 50 'columns 50
+ 'latitude 0. 'longitude 0.
+ 'step .001))
+ (v 'position -.02 -.02 4000.)
+ (v 'heading 45.)
+ (v 'tilt -40.)
+@end example
+
+A viewer window should appear and display an image like
+the one at this URL:
+@code{http://birchwood-abbey.net/~matt/Scheme/sample-terrain.png}.
+@c How do I inset a small image?
+
+In the viewer window your up/down arrow keys should move the camera
+forward/backward approximately 100 meters. The left/right keys turn
+the camera. Hold the Ctrl key and press up/down to tilt the camera.
+
+Generating a terrain by querying Google Earth can take a while, so you
+will want to create a restartable script and run it in the background.
+Here is an example that downloads 10201 elevations in a 101 by 101
+grid across 1 degree of latitude and longitude centered on Monterey
+Bay, California.
+
+@example
+ #!/bin/bash
+ mit-scheme --batch-mode <<\EOF
+ (begin
+ (load-option 'planetarium)
+ (request-google-elevations "monterey.txt"
+ (make-latitudes/longitudes
+ (iota 101 36. .01)
+ (iota 101 -122.5 .01)))
+ )
+ EOF
+@end example
+
+You might name the script @file{~/job.sh} and run it in the background
+using the Unix @code{at} command, as shown below, then wait for email
+notifying you that the job is complete. If it fails, you might submit
+it again just as before; it will pick up where it left off. It will
+request elevations only as fast as Google's free service allows, so
+you might wait an entire day for 10201 elevations to download.
+
+@example
+ $ chmod +x ~/job.sh
+ $ at now
+ > ~/job.sh
+ > ^D
+@end example
+
+Tomorrow, after you get email saying your job has successfully
+completed, you can view the data by entering the following four
+s-expressions.
+
+@example
+ (ge '(planetarium terrain))
+ (define v (make-terrain
+ 'filename "monterey.txt" 'rows 101 'columns 101
+ 'latitude 36. 'longitude -122.5 'step .01
+ 'color-function height-color))
+ (v 'position 36.5 -122.7 15000.)
+ (v 'heading 85.)
+ (v 'tilt -25.)
+@end example
+
+A viewer window should appear and display an image like
+the one at this URL:
+@code{http://birchwood-abbey.net/~matt/Scheme/monterey-bay-1.png}.
+
+@node GNU Free Documentation License, , Terrain Viewer, Top
@appendix GNU Free Documentation License
@cindex FDL, GNU Free Documentation License