special case the four cardinal directions during rotation so they rotate
exactly (this also makes flip-horizontal and flip-vertical work equally well) closes PR 12323
This commit is contained in:
parent
48f9b8895c
commit
0dff5ca92b
|
@ -545,7 +545,7 @@
|
||||||
(let* ([unrotated (translate-shape simple-shape)]
|
(let* ([unrotated (translate-shape simple-shape)]
|
||||||
[rotated (rotate-atomic θ unrotated)])
|
[rotated (rotate-atomic θ unrotated)])
|
||||||
(let-values ([(dx dy)
|
(let-values ([(dx dy)
|
||||||
(c->xy (* (make-polar 1 (degrees->radians θ))
|
(c->xy (* (degrees->complex θ)
|
||||||
(xy->c (translate-dx simple-shape)
|
(xy->c (translate-dx simple-shape)
|
||||||
(translate-dy simple-shape))))])
|
(translate-dy simple-shape))))])
|
||||||
(make-translate dx dy rotated)))]))
|
(make-translate dx dy rotated)))]))
|
||||||
|
@ -748,8 +748,18 @@
|
||||||
(make-point x y)))
|
(make-point x y)))
|
||||||
|
|
||||||
(define (rotate-c c θ)
|
(define (rotate-c c θ)
|
||||||
(* (make-polar 1 (degrees->radians θ))
|
(* (degrees->complex θ) c))
|
||||||
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
|
;; rotate-xy : x,y angle -> x,y
|
||||||
(define (rotate-xy x y θ)
|
(define (rotate-xy x y θ)
|
||||||
|
|
|
@ -1860,12 +1860,12 @@
|
||||||
(test (pinhole-y (flip-vertical (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
(test (pinhole-y (flip-vertical (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
||||||
=>
|
=>
|
||||||
18)
|
18)
|
||||||
(test (pinhole-x (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
(check-= (pinhole-x (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
||||||
=>
|
9.0
|
||||||
9.0)
|
0)
|
||||||
(test (pinhole-y (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
(check-= (pinhole-y (flip-horizontal (put-pinhole 1 2 (rectangle 10 20 'solid 'red))))
|
||||||
=>
|
2.0
|
||||||
2.0)
|
0)
|
||||||
(test (equal? (center-pinhole (rectangle 10 12 'solid 'blue))
|
(test (equal? (center-pinhole (rectangle 10 12 'solid 'blue))
|
||||||
(rectangle 10 12 'solid 'blue))
|
(rectangle 10 12 'solid 'blue))
|
||||||
=>
|
=>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user