乐正

Actions speak louder than words.

Sicp-ex2-52

问题

在上面描述的各个层次上工作,修改图2-9中所示的方块的限制。特别是:

a) 给练习2.49的基本wave画家加入某些线段(例如,加上一个笑脸) b) 修改corner-split的构造模式(例如,只用up-splitright-split的各一个副本 而不是两个) c) 修改square-limit,换一种使用square-of-four的方式,以另一种不同模式组合起 各个边角区(例如,你可以让大的Rogers先生从正方形的每个角向外看)。

解答

练习2.52 (ex2-52.scm) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
;; 加上一个X
(define (wave frame)
  (let ((lp1 (make-vect (xcor-vect (edge1-frame frame))
                        (* 2 (/ (ycor-vect (edge1-frame frame) 3)))))
        (lp2 (make-vect (xcor-vect (edge1-frame frame))
                        (* 5 (/ (ycor-vect (edge1-frame frame) 6)))))i
        (tp1 (make-vect (* 2 (/ (xcor-vect (edge2-frame frame) 5)))
                        (ycor-vect (edge1-frame frame))))
        (tp2 (make-vect (* 3 (/ (xcor-vect (edge2-frame frame) 5)))
                        (ycor-vect (edge1-frame frame))))
        (rp1 (make-vect (xcor-vect (edge2-frame frame))
                        (* 1 (/ (ycor-vect (edge1-frame frame)) 3))))
        (rp2 (make-vect (xcor-vect (edge2-frame frame))
                        (* 1 (/ (ycor-vect (edge1-frame frame)) 6))))
        (bp1 (make-vect (* 3 (/ (xcor-vect (edge2-frame frame)) 4))
                        (ycor-vect (edge2-frame frame))))
        (bp2 (make-vect (* 5 (/ (xcor-vect (edge2-frame frame)) 8))
                        (ycor-vect (edge2-frame frame))))
        (bp3 (make-vect (* 3 (/ (xcor-vect (edge2-frame frame)) 8))
                        (ycor-vect (edge2-frame frame))))
        (bp4 (make-vect (* 1 (/ (xcor-vect (edge2-frame frame)) 4))
                        (ycor-vect (edge2-frame frame))))
        (cp1 (make-vect (* 1 (/ (xcor-vect (edge2-frame frame)) 8))
                        (* 3 (/ (ycor-vect (edge1-frame frame)) 8))))
        (cp2 (make-vect (xcor-vect bp4)
                        (ycor-vect lp1)))
        (cp3 (make-vect (* 1 (/ (xcor-vect (edge2-frame frame)) 3))
                        ((/ (ycor-vect (edge1-frame frame)) 2))))
        (cp4 (make-vect (/ (xcor-vect (edge2-frame frame)) 2)
                        ((/ (ycor-vect (edge1-frame frame)) 4))))
        (cp5 (make-vect (xcor-vect bp2)
                        (/ (ycor-vect (edge1-frame frame)) 2)))
        (cp6 (make-vect (xcor-vect bp1)
                        (/ (ycor-vect (edge1-frame frame) 3))))
        (cp7 (make-vect (xcor-vect bp2)
                        (ycor-vect cp6)))
        (cp8 (make-vect (xcor-vect cp2)
                        (ycor-vect lp2)))
        (cp9 (make-vect (xcor-vect bp4)
                        (ycor-vect lp2)))
        (cp10 (make-vect (xcor-vect bp3)
                         (ycor-vect cp6)))
        (cp11 (make-vect (xcor-vect cp2)
                         (ycor-vect cp6)))
        (cp12 (make-vect (xcor-vect cp1)
                         (ycor-vect lp1))))

    (segments->painter (list (make-segment lp1 cp1)
                             (make-segment cp1 cp2)
                             (make-segment cp2 cp3)
                             (make-segment cp3 bp4)
                             (make-segment bp3 cp4)
                             (make-segment cp4 bp2)
                             (make-segment bp1 cp5)
                             (make-segment cp5 rp2)
                             (make-segment rp1 cp6)
                             (make-segment cp6 cp7)
                             (make-segment cp7 cp8)
                             (make-segment cp8 tp2)
                             (make-segment tp1 cp9)
                             (make-segment cp9 cp10)
                             (make-segment cp10 cp11)
                             (make-segment cp11 cp12)
                             (make-segment cp12 lp2)
                             (make-segment cp5 cp10)
                             (make-segment cp3 cp7)))))

draft

« sicp-ex2-51 sicp-ex2-53 »

Comments