Last active
December 10, 2015 01:58
-
-
Save naoyat/4364059 to your computer and use it in GitHub Desktop.
[Gauche] 途中で xmin の値が変更されてしまう。mx, my の演算に有理数を使うとこの問題が発生しない所まで確認。(0.9.2, 0.9.3.3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define xmin 0) | |
(define xmax 0) | |
(define ymin 0) | |
(define ymax 0) | |
(define (f x0 y0 x1 y1 depth) | |
(when (>= depth 0) | |
(when (< x0 xmin) (set! xmin x0)) | |
(when (< x1 xmin) (set! xmin x1)) | |
(when (< xmax x0) (set! xmax x0)) | |
(when (< xmax x1) (set! xmax x1)) | |
(when (< y0 ymin) (set! ymin y0)) | |
(when (< y1 ymin) (set! ymin y1)) | |
(when (< ymax y0) (set! ymax y0)) | |
(when (< ymax y1) (set! ymax y1)) | |
(when (> xmin 0) (print "ERR?1 " xmin) (exit)) | |
(let* ([dx (- x1 x0)] | |
[dy (- y1 y0)] | |
[x0+ (- x0 dy)] | |
[y0+ (+ y0 dx)] | |
[x1+ (- x1 dy)] | |
[y1+ (+ y1 dx)] | |
[mx (+ x0+ (* .5 dx) (* -.5 dy))] ;; 浮動小数点演算だと駄目 | |
[my (+ y0+ (* .5 dy) (* .5 dx))]) | |
; [mx (+ x0+ (* 1/2 dx) (* -1/2 dy))] ;; 有理数だと問題ない | |
; [my (+ y0+ (* 1/2 dy) (* 1/2 dx))]) | |
(when (> xmin 0) (print "ERR?3 " xmin) (exit)) | |
(f x0+ y0+ mx my (- depth 1)) | |
(f mx my x1+ y1+ (- depth 1)) | |
(when (> xmin 0) (print "ERR?5 " xmin) (exit)) | |
))) | |
;(disasm f) | |
(f 0 0 1 0 11) | |
(format #t "x:[~a ~a] y:[~a ~a]¥n" xmin xmax ymin ymax) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment