Skip to content
Snippets Groups Projects
Commit 5f5d1bbf authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Clean up test.scm.

parent 8f8b0621
No related branches found
No related tags found
No related merge requests found
(load "main.scm")
;; (define x 2.1574)
;; (define y 2.0389)
;; (define fov (/ tau 8))
#|
dx
+---/
dy | /
| /
|/
== Om världen var enkel ==
dx = cos a
dy = sin a
|#
(define (decimals x)
(- x (truncate x)))
(define (cot a)
(/ (tan a)))
(define sgn signum)
(define (find-edge x y a)
(let ((dx-ampl (mod (* -1 (sgn (cos a)) (decimals x)) 1))
(dy-ampl (mod (* -1 (sgn (sin a)) (decimals y)) 1)))
(let* ((dx (* dx-ampl (sgn (cos a))))
(dy (* dx (tan a))))
(if (<= (abs dy) dy-ampl)
(format
#t "Try 1: a = ~,2f (~,1f, ~,1f) => (~,1f, ~,1f), + Δ(~,1f, ~,1f)~%"
(/ a tau) x y (+ x dx) (+ y dy) dx dy)
(let* ((dy (* dy-ampl (sgn (sin a))))
(dx (* dy (cot a))))
(format
#t
"Try 2: a = ~,2f (~,1f, ~,1f) => (~,1f, ~,1f), + Δ(~,1f, ~,1f)~%"
(/ a tau) x y (+ x dx) (+ y dy) dx dy))))))
(for-each
(lambda (x y)
(let ((ray-count 8))
(for-each
(lambda (theta)
(let ((a (* tau theta)))
(find-edge x y a)
#;
((if (> (abs (cos a))
(abs (sin a)))
move-horizontally-from-middle
move-vertically-from-middle)
x y a (lambda (nx ny)
(format #t "~a s = (~,2f, ~,2f), e = (~,2f, ~,2f), a = τ ~a~%"
(* theta 8) x y nx ny theta)))))
(find-next-wall
x y a
(lambda (nx ny)
(format #t "a = ~a τ (~,1f, ~,1f) => (~,1f, ~,1f), + Δ(~,1f, ~,1f)~%"
theta x y nx ny (- nx x) (- ny y))))))
(iota ray-count 0 1/8)))
(newline))
'(1.1 1.1 1.9 1.9)
'(1.1 1.9 1.1 1.9))
#;
(move-vertically-from-middle 1.1 1.1 (* tau 3/8)
(lambda (x y) (format #t "(~,2f, ~,2f)~%"
x y)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment