planetarium: Turn write-sample-terrain into write-function-terrain.
authorMatt Birkholz <puck@birchwood-abbey.net>
Fri, 29 Apr 2016 23:28:11 +0000 (16:28 -0700)
committerMatt Birkholz <puck@birchwood-abbey.net>
Sat, 30 Apr 2016 20:03:24 +0000 (13:03 -0700)
src/planetarium/mit-check.sh
src/planetarium/terrain.scm

index 1c7b4b06100126ecb99397789fd7bbe818a17a2f..e03f40e84b29f8192c3073741f747b6a47dcd02d 100755 (executable)
@@ -47,16 +47,20 @@ ${MIT_SCHEME_EXE} --prepend-library . <<\EOF
              (warn "Could not test terrain viewer.")
              (begin
                ((access test-normals env))
-               (if (not (file-exists? "sample-terrain.txt"))
-                   ((access write-sample-terrain env)
-                    "sample-terrain.txt" 20 20))
+               ((access write-function-terrain env)
+                "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)))))
                (let ((view (make-terrain 'filename "sample-terrain.txt"
-                                         'rows 20 'columns 20
+                                         'rows 50 'columns 50
                                          'latitude 0. 'longitude 0.
                                          'step .001)))
-                 (view 'position -.01 0. 2000.)
-                 (view 'heading 25.)
-                 (view 'tilt -45.)))))
+                 (view 'position -.02 -.02 4000.)
+                 (view 'heading 45.)
+                 (view 'tilt -40.)))))
 
        (let ((env (->environment '(gtk gtk-widget))))
          (let loop ()
index 4d974d677b31b431094e38c91c6b025cc6de3c17..171ede38ebb46e348445fe9f66a0e4560ae3b179 100644 (file)
@@ -462,13 +462,14 @@ USA.
                  (matrix-set! matrix columns x y height))))))))
     matrix))
 
-(define (write-sample-terrain filename x-samples y-samples)
+(define (write-function-terrain filename
+                               x-min x-max x-samples
+                               y-min y-max y-samples
+                               function)
   (with-output-to-file filename
     (lambda ()
       (let ((time-string
-            (universal-time->local-time-string (get-universal-time)))
-           (x-min -3) (x-max 3)
-           (y-min -2) (y-max 2))
+            (universal-time->local-time-string (get-universal-time))))
        (let ((x-step (/ (- x-max x-min) x-samples)) 
              (y-step (/ (- y-max y-min) y-samples)))
          (do ((x x-min (+ x x-step))
@@ -483,10 +484,7 @@ USA.
              (write-char #\,)
              (write-string (number->string y '(fix 3)))
              (write-char #\tab)
-             (write-string (number->string
-                            (* 1000 ;One kilometer tall mountain.
-                               (/ 1 (+ (* x x) (* y y) 1)))
-                            '(fix 3)))
+             (write-string (number->string (function x y) '(fix 3)))
              (write-char #\newline))))))))
 
 (define-integrable (matrix-set! m c x y v)