Define the transformation
flip-horiz, which flips painters horizontally, and transformations that rotate painters counterclockwise by 180 degrees and 270 degrees. Okay, so first of all here's our default frame:
origin is at (0, 0), edge1 is the horizontal edge, ending at (1,0) and edge2 is the vertical edge, ending at (0, 1). And for comparison with later images, here's what we get when we invoke (wave window):
origin is at (1, 0), edge1 is still the horizontal edge, but goes in the oposite direction and ends at (0,0) and edge2 is still the vertical edge, but is on the right of the frame, ending at (1, 1). This translates directly into the following transformation:
(define (flip-horiz painter)
(transform-painter painter
(make-vect 1.0 0.0)
(make-vect 0.0 0.0)
(make-vect 1.0 1.0)))
Calling ((flip-horiz wave) window) gives us:
origin to the opposite corner and pulls the edges around with it:
origin is at (1, 1), edge1 is still the horizontal edge, but is at the top of the frame and goes in the oposite direction, ending at (0, 1), and edge2 is still the vertical edge, but is on the right of the frame and is inverted, ending at (1, 0). This gives us the following transformation:
(define (rotate180 painter)
(transform-painter painter
(make-vect 1.0 1.0)
(make-vect 0.0 1.0)
(make-vect 1.0 0.0)))
Calling ((rotate180 wave) window) gives us:
origin is at (0, 1), edge1 is now the (inverted) vertical edge on the left-hand side, ending at (0, 0), and edge2 is now the horizontal edge at the top, ending at (1, 1). So our final transformation is:
(define (rotate270 painter)
(transform-painter painter
(make-vect 0.0 1.0)
(make-vect 0.0 0.0)
(make-vect 1.0 1.0)))
Calling ((rotate270 wave) window) gives us:
No comments:
Post a Comment