(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 ()
(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))
(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)