diff --git a/collects/2htdp/private/image-more.rkt b/collects/2htdp/private/image-more.rkt index 31c94ada08..91a2e05477 100644 --- a/collects/2htdp/private/image-more.rkt +++ b/collects/2htdp/private/image-more.rkt @@ -545,7 +545,7 @@ (let* ([unrotated (translate-shape simple-shape)] [rotated (rotate-atomic θ unrotated)]) (let-values ([(dx dy) - (c->xy (* (make-polar 1 (degrees->radians θ)) + (c->xy (* (degrees->complex θ) (xy->c (translate-dx simple-shape) (translate-dy simple-shape))))]) (make-translate dx dy rotated)))])) @@ -748,8 +748,18 @@ (make-point x y))) (define (rotate-c c θ) - (* (make-polar 1 (degrees->radians θ)) - c)) + (* (degrees->complex θ) c)) + +(define (degrees->complex θ) + (unless (and (<= 0 θ) + (< θ 360)) + (error 'degrees->complex "~s" θ)) + (case (modulo θ 360) + [(0) 1+0i] + [(90) 0+1i] + [(180) -1+0i] + [(270) 0-1i] + [else (make-polar 1 (degrees->radians θ))])) ;; rotate-xy : x,y angle -> x,y (define (rotate-xy x y θ) diff --git a/collects/2htdp/tests/test-image.rkt b/collects/2htdp/tests/test-image.rkt index 550175d995..9b5225133a 100644 --- a/collects/2htdp/tests/test-image.rkt +++ b/collects/2htdp/tests/test-image.rkt @@ -1860,12 +1860,12 @@ (test (pinhole-y (flip-vertical (put-pinhole 1 2 (rectangle 10 20 'solid 'red)))) => 18) -(test (pinhole-x (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red)))) - => - 9.0) -(test (pinhole-y (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red)))) - => - 2.0) +(check-= (pinhole-x (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red)))) + 9.0 + 0) +(check-= (pinhole-y (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red)))) + 2.0 + 0) (test (equal? (center-pinhole (rectangle 10 12 'solid 'blue)) (rectangle 10 12 'solid 'blue)) =>