Welcome to mpost-wrapper.
1 ex-1
1.1 source code in ex-1.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (draw (call-with-values A-B-C op--)))
1.2 the result of ex-1
Examples: | |||||
|
2 ex-2
2.1 source code in ex-2.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (draw (call-with-values A-B-C (lambda (A B C) (op-- A B C 'cycle)))))
2.2 the result of ex-2
Examples: | |||||
|
3 ex-3
3.1 source code in ex-3.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op-- A B C D 'cycle)) (draw (op-- A C)) (draw (op-- B D)))))
3.2 the result of ex-3
Examples: | |||||
|
4 ex-4
4.1 source code in ex-4.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (point 0 0) #:withpen (scale '4bp 'pencircle)))
4.2 the result of ex-4
Examples: | |||||
|
5 ex-5
5.1 source code in ex-5.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (for ((p (in-list (list A B C)))) (draw p #:withpen (scale '4bp 'pencircle))) )))
5.2 the result of ex-5
Examples: | |||||
|
6 ex-6
6.1 source code in ex-6.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op-- A B C D 'cycle)) (draw (op-- A C)) (draw (op-- B D)) (for ((p (in-list (list A B C D)))) (draw p #:withpen (scale '4bp 'pencircle))))))
6.2 the result of ex-6
Examples: | |||||
|
7 ex-7
7.1 source code in ex-7.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (draw (op-- (mediation '.5 B C) A)) (draw (op-- (mediation '.5 A C) B)) (draw (op-- (mediation '.5 B A) C)) )))
7.2 the result of ex-7
Examples: | |||||
|
8 ex-8
8.1 source code in ex-8.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (draw (op-- (mediation 0.5 B C) A)) (draw (op-- (mediation 0.5 A C) B)) (draw (op-- (mediation 0.5 B A) C)) (draw (op* 1/3 (op+ A B C)) #:withpen (scale '4bp 'pencircle)) )))
8.2 the result of ex-8
Examples: | |||||
|
9 ex-9
9.1 source code in ex-9.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (draw (op-- A B) #:withpen (scale '4bp 'pencircle)) )))
9.2 the result of ex-9
Examples: | |||||
|
10 ex-10
10.1 source code in ex-10.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (draw (op-- A B) #:withcolor (op+ 'green 'red)) )))
10.2 the result of ex-10
Examples: | ||||||
|
11 ex-11
11.1 source code in ex-11.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B)) (draw (op-- B C) #:dashed 'evenly) (draw (op-- C A) #:dashed 'withdots) )))
11.2 the result of ex-11
Examples: | ||||||
|
12 ex-12
12.1 source code in ex-12.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (for ((p (in-list (list (op-- A B) (op-- B C) (op-- C A) ))) (color (in-list (list 0.8 0.6 0.4)))) (draw p #:withpen (scale '2bp 'pencircle) #:withcolor (op* color 'white))) )))
12.2 the result of ex-12
Examples: | ||||||
|
13 ex-13
13.1 source code in ex-13.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op-- A B C 'cycle)) (draw (op-- (mediation '.5 B C) A) #:dashed 'evenly) (draw (op-- (mediation '.5 A C) B) #:dashed 'evenly) (draw (op-- (mediation '.5 B A) C) #:dashed 'evenly) (draw (op* 1/3 (op+ A B C)) #:withpen (scale '4bp 'pencircle) #:withcolor 'red) )))
13.2 the result of ex-13
Examples: | ||||||
|
14 ex-14
14.1 source code in ex-14.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (op-- (point 0 0) (point '3cm 0)) #:dashed (scale 2 'evenly)))
14.2 the result of ex-14
Examples: | ||||||
|
15 ex-15
15.1 source code in ex-15.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (op-- (point 0 0) (point '3cm 0)) #:dashed (dashpattern "on 2bp off 3bp")))
15.2 the result of ex-15
Examples: | ||||||
|
16 ex-16
16.1 source code in ex-16.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (op-- (point 0 0) (point '3cm 0)) #:dashed (dashpattern "on 1bp off 2bp on 10bp off 2bp")))
16.2 the result of ex-16
Examples: | ||||||
|
17 ex-17
17.1 source code in ex-17.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (drawarrow (op-- C B A)) (drawarrow (op-- A C) #:withpen (scale '2bp 'pencircle)))))
17.2 the result of ex-17
Examples: | ||||||
|
18 ex-18
18.1 source code in ex-18.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (drawdblarrow (op-- C B A 'cycle)) (drawdblarrow (op-- A C) #:withpen (scale '2bp 'pencircle)))))
18.2 the result of ex-18
Examples: | ||||||
|
19 ex-19
19.1 source code in ex-19.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (op-- (point '-1.5cm 0) (point '1.5cm 0))))
19.2 the result of ex-19
Examples: | ||||||
|
20 ex-20
20.1 source code in ex-20.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (fill (op-- A B C 'cycle) #:withcolor (op* 0.8 'white)))))
20.2 the result of ex-20
Examples: | ||||||
|
21 ex-21
21.1 source code in ex-21.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (fill (op-- A B C 'cycle) #:withcolor (op* 0.8 'white)) (draw (op-- A B C 'cycle)))))
21.2 the result of ex-21
Examples: | ||||||
|
22 ex-22
22.1 source code in ex-22.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (fill (op-- A B C 'cycle) #:withcolor (op* 0.8 'white)) (draw (op-- A B C 'cycle) #:withpen (scale '2bp 'pencircle)))))
22.2 the result of ex-22
Examples: | ||||||
|
23 ex-23
23.1 source code in ex-23.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle) #:withpen (scale '2bp 'pencircle)) (fill (op-- A B C 'cycle) #:withcolor (op* 0.8 'white)))))
23.2 the result of ex-23
Examples: | ||||||
|
24 ex-24
24.1 source code in ex-24.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (fill (op-- A C B D 'cycle) #:withcolor (op* 0.8 'white)))))
24.2 the result of ex-24
Examples: | ||||||
|
25 ex-25
25.1 source code in ex-25.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (let ((p (op-- A C B D 'cycle))) (fill p #:withcolor (op* 0.8 'white)) (draw p)))))
25.2 the result of ex-25
Examples: | ||||||
|
26 ex-26
26.1 source code in ex-26.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((A (point '-1.5cm '-1.5cm)) (B (point '1.5cm '-1.5cm)) (C (point '1.5cm '1.5cm)) (D (point '-1.5cm '1.5cm))) (fill (op-- A C B D 'cycle) #:withcolor (op* 0.8 'white)) (draw (op-- (point '-1.5cm 0) (point '1.5cm '0))) (draw (op-- (point 0 '-1.5cm) (point 0 '1.5cm))) (drawarrow (op-- (point 0 0) (point '1cm 0)) #:withpen (scale '2bp 'pencircle)) (drawarrow (op-- (point 0 0) (point 0 '1cm)) #:withpen (scale '2bp 'pencircle))))
26.2 the result of ex-26
Examples: | ||||||
|
27 ex-27
27.1 source code in ex-27.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (main) (let ((A (point 0 0))) (draw A #:withpen (scale '4bp 'pencircle)) (label-top (btex "Au dessus") A) (label-bot (btex "En dessous") A) (label-rt (btex "^^c0 droite") A) (label-lft (btex "^^c0 gauche") A)))
27.2 the result of ex-27
Examples: | ||||||
|
28 ex-28
28.1 source code in ex-28.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (main) (let ((A (point 0 0))) (draw A #:withpen (scale '4bp 'pencircle)) (label-ulft (btex "En haut ^^e0 gauche") A) (label-urt (btex "En haut ^^e0 droite") A) (label-llft (btex "En bas ^^e0 gauche") A) (label-lrt (btex "En bas ^^e0 droite") A)))
28.2 the result of ex-28
Examples: | ||||||
|
29 ex-29
29.1 source code in ex-29.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (main) (dot-label-urt (btex "$A$") (point 0 0)))
29.2 the result of ex-29
Examples: | ||||||
|
30 ex-30
30.1 source code in ex-30.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (dot-label-llft (btex "$A$") A) (dot-label-lrt (btex "$B$") B) (dot-label-top (btex "$C$") C))))
30.2 the result of ex-30
Examples: | ||||||
|
31 ex-31
31.1 source code in ex-31.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (label-bot (btex "$1$") (mediation 0.5 A B)) (label-lft (btex "$1$") (mediation 1/2 A C)) (label-urt (btex "$\\sqrt 2$") (mediation 1/2 B C)))))
31.2 the result of ex-31
Examples: | ||||||
|
32 ex-32
32.1 source code in ex-32.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (ex-32-points y xs) (map(lambda (x) (point x y)) xs)) (define (main) (let* ((u '1cm) (xs (list (op* -1 u) 0 u)) (u-points (ex-32-points u xs)) (l-points (ex-32-points 0 xs))) (for* ((a (in-list l-points)) (b (in-list u-points))) (draw (op-- a b))) (for ((ut (in-list (list "$a$" "$b$" "$c$"))) (a (in-list u-points)) (lt (in-list (list "$a'$" "$b'$" "$c'$"))) (b (in-list l-points))) (dot-label-top (btex ut) a) (dot-label-bot (btex lt) b))))
32.2 the result of ex-32
Examples: | ||||||
|
33 ex-33
33.1 source code in ex-33.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (fullcircle)))
33.2 the result of ex-33
Examples: | ||||||
|
34 ex-34
34.1 source code in ex-34.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (point 0 0 ) #:withpen (scale '4bp 'pencircle)))
34.2 the result of ex-34
Examples: | ||||||
|
35 ex-35
35.1 source code in ex-35.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (point 0 0 ) #:withpen (scale '4bp 'pencircle)))
35.2 the result of ex-35
Examples: | ||||||
|
36 ex-36
36.1 source code in ex-36.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C) (values (point 0 0) (point '1cm 0) (point 0 '1cm))) (define (main) (call-with-values A-B-C (lambda (A B C) (draw (op-- A B C 'cycle)) (for ((a-point (in-list (list A B C)))) (fill (fullcircle '4bp a-point) #:withcolor 'white)) (for ((a-point (in-list (list A B C)))) (draw (fullcircle '4bp a-point))))))
36.2 the result of ex-36
Examples: | ||||||
|
37 ex-37
37.1 source code in ex-37.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op.. A D B C)) (for ((A (in-list (list A B C D)))) (draw A #:withpen (scale '4bp 'pencircle))))))
37.2 the result of ex-37
Examples: | ||||||
|
38 ex-38
38.1 source code in ex-38.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A '-- D '.. B '.. C)) )))
38.2 the result of ex-38
Examples: | ||||||
|
39 ex-39
39.1 source code in ex-39.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A '--- D '.. B '.. C)) )))
39.2 the result of ex-39
Examples: | ||||||
|
40 ex-40
40.1 source code in ex-40.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A '.. D '.. B '.. C)) )))
40.2 the result of ex-40
Examples: | ||||||
|
41 ex-41
41.1 source code in ex-41.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op.. A B C D 'cycle) ))))
41.2 the result of ex-41
Examples: | ||||||
|
42 ex-42
42.1 source code in ex-42.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (op.. A C 'cycle) ))))
42.2 the result of ex-42
Examples: | ||||||
|
43 ex-43
43.1 source code in ex-43.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec (point 0 1)) ".." (point '2cm 0) (dir-spec (point 1 0)))))
43.2 the result of ex-43
Examples: | ||||||
|
44 ex-44
44.1 source code in ex-44.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec (dir 90)) ".." (point '2cm 0) (dir-spec (dir 0)))))
44.2 the result of ex-44
Examples: | ||||||
|
45 ex-45
45.1 source code in ex-45.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec 'up) ".." (point '2cm 0) (dir-spec 'right))))
45.2 the result of ex-45
Examples: | ||||||
|
46 ex-46
46.1 source code in ex-46.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec 'up) ".." (point '2cm 0) (dir-spec 'up))))
46.2 the result of ex-46
Examples: | ||||||
|
47 ex-47
47.1 source code in ex-47.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec 'up) ".." (point '2cm 0) (dir-spec 'up) ".." 'cycle)))
47.2 the result of ex-47
Examples: | ||||||
|
48 ex-48
48.1 source code in ex-48.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (arc O A B rou) (let ((alpha (op-angle (op- A O))) (beta (op-angle (op- B O)))) (path (op+ O (polar rou alpha)) (dir-spec (dir (op+ alpha 90))) ".." (op+ O (polar rou beta )) (dir-spec (dir (op+ beta 90)))))) (define (main) (let* ((O (point 0 0)) (alpha 30) (A (polar '2cm 0)) (B (polar '2cm alpha))) (draw (path O ".." A)) (draw (path O ".." B)) (draw (arc O A B '1cm))))
48.2 the result of ex-48
Examples: | ||||||
|
49 ex-49
49.1 source code in ex-49.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (arc O A B rou) (let ((alpha (op-angle (op- A O))) (beta (op-angle (op- B O)))) (path (op+ O (polar rou alpha)) (dir-spec (dir (op+ alpha 90))) ".." (op+ O (polar rou beta )) (dir-spec (dir (op+ beta 90)))))) (define (main) (let* ((O (point 0 0)) (alpha 30) (A (polar '2cm 0)) (B (polar '2cm alpha))) (draw (path O ".." A)) (draw (path O ".." B)) (draw (arc O A B '1cm)) (draw (arc O A B '1.1cm))))
49.2 the result of ex-49
Examples: | ||||||
|
50 ex-50
50.1 source code in ex-50.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (arc O A B rou) (let ((alpha (op-angle (op- A O))) (beta (op-angle (op- B O)))) (path (op+ O (polar rou alpha)) (dir-spec (dir (op+ alpha 90))) ".." (op+ O (polar rou beta )) (dir-spec (dir (op+ beta 90)))))) (define (draw-angle A B C n) (let ((rou '4.5mm)) (if (> n 0) (begin (draw (arc A B C (op+ rou (op* n '0.5mm)))) (draw-angle A B C (- n 1))) (void)))) (define (main) (let ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm))) (draw (op-- A B C 'cycle)) (draw-angle A B C 1) (draw-angle B C A 2) (draw-angle C A B 3)))
50.2 the result of ex-50
Examples: | ||||||
|
51 ex-51
51.1 source code in ex-51.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (p (path (point u 0) (dir-spec 'up) ".." (point (op* -1 u) 0) (dir-spec 'down) "--" 'cycle))) (fill p #:withcolor (op* 0.8 'white)) (draw p #:withpen (scale '1bp 'pencircle)) ))
51.2 the result of ex-51
Examples: | ||||||
|
52 ex-52
52.1 source code in ex-52.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (p (path (point u 0) (dir-spec 'up) ".." (point (op* -1 u) 0) (dir-spec 'down) "--" (point (op* -0.2 u) 0) (dir-spec 'up) ".." (point (op* 0.2 u) 0) (dir-spec 'down) "--" 'cycle))) (fill p #:withcolor (op* 0.8 'white)) (draw p #:withpen (scale '1bp 'pencircle)) ))
52.2 the result of ex-52
Examples: | ||||||
|
53 ex-53
53.1 source code in ex-53.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (A (point (op* 0.2 u) (op* 0.05 u))) (AA (point (op* 0.2 u) (op* -0.05 u))) (B (point (op* 1.0 u) (op* 0.05 u))) (BB (point (op* 1.0 u) (op* -0.05 u))) (C (point (op* -0.2 u) (op* 0 0))) (D (point (op* -1.0 u) (op* 0 0))) (p (path B (dir-spec 'up) ".." D (dir-spec 'down) ".." BB (dir-spec 'up) "--" AA (dir-spec 'down) ".." C (dir-spec 'up) ".." A (dir-spec 'down) "--" 'cycle))) (fill p #:withcolor (op* 0.8 'white)) (draw p #:withpen (scale '1bp 'pencircle)) ))
53.2 the result of ex-53
Examples: | ||||||
|
54 ex-54
54.1 source code in ex-54.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (A (point 0 0)) (B (polar u 60)) (C (polar u -60)) (D (point (op* 2 u) 0))) (for ((x (in-list (list A B C D)))) (draw x #:withpen (scale '4bp 'pencircle))) (draw (op-- A D B D C)) (for ((x (in-list (list (path A (dir-spec 'up) ".." B) (path A (dir-spec 'down) ".." C) (path A (dir-spec (dir 30)) ".." B) (path A (dir-spec (dir -30)) ".." C))))) (draw x) )))
54.2 the result of ex-54
Examples: | ||||||
|
55 ex-55
55.1 source code in ex-55.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (op.. (point 0 0) (point '1cm '1cm) (point '2cm 0))))
55.2 the result of ex-55
Examples: | ||||||
|
56 ex-56
56.1 source code in ex-56.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) '.. "tension 2" '.. (point '1cm '1cm) '.. (point '2cm 0))))
56.2 the result of ex-56
Examples: | ||||||
|
57 ex-57
57.1 source code in ex-57.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((u '1cm)) (draw (path (polar u 90) (dir-spec (dir 0)) '.. (polar u -150) (dir-spec (dir 120)) '.. (polar u -30 ) (dir-spec (dir -120)) '.. 'cycle))))
57.2 the result of ex-57
Examples: | ||||||
|
58 ex-58
58.1 source code in ex-58.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((u '1cm) (tension " tension 2 ")) (draw (path (polar u 90) (dir-spec (dir 0)) '.. tension '.. (polar u -150 ) (dir-spec (dir 120)) '.. tension '.. (polar u -30 ) (dir-spec (dir -120)) '.. tension '.. 'cycle))))
58.2 the result of ex-58
Examples: | ||||||
|
59 ex-59
59.1 source code in ex-59.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((u '1cm) (tension " tension 4 ")) (draw (path (polar u 90) (dir-spec (dir 0)) '.. tension '.. (polar u -150 ) (dir-spec (dir 120)) '.. tension '.. (polar u -30 ) (dir-spec (dir -120)) '.. tension '.. 'cycle))))
59.2 the result of ex-59
Examples: | ||||||
|
60 ex-60
60.1 source code in ex-60.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '0.5cm) (A (point 0 0)) (B (point (op* -1 u) (op* 2 u))) (C (point (op* 4 u) (op* 3 u))) (D (point (op* 3 u) 0))) (draw (path A ".." " controls " B " and " C ".." D) #:withpen (scale '2pt 'pencircle)) (draw (op-- B C) #:dashed 'evenly) (drawarrow (op-- A B)) (drawarrow (op-- D C))))
60.2 the result of ex-60
Examples: | ||||||
|
61 ex-61
61.1 source code in ex-61.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (f z1 zn) (if (null? zn) z1 (let ((x (f2 z1 zn))) (f (car x) (cdr x))))) (define (f2 z1 zn) (if (null? (cdr zn)) (list (mediation 1/2 z1 (car zn))) (cons (mediation 1/2 z1 (car zn)) (f2 (car zn) (cdr zn))))) (let* ((u '1cm) (A (point 0 0)) (B (point (op* -1 u) (op* 2 u))) (C (point (op* 3 u) (op* 3 u))) (D (point (op* 2 u) 0))) (for ((A (in-list (list A B C D)))) (draw A #:withpen (scale '4bp 'pencircle))) (draw (path A ".." " controls " B " and " C ".." D)) (draw (f A (list B C D)) #:withpen (scale '4bp 'pencircle))))
61.2 the result of ex-61
Examples: | ||||||
|
62 ex-62
62.1 source code in ex-62.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (bezier n A B C D) (let* ((a1 A) (a2 B) (a3 C) (a4 D) (a12 (mediation 1/2 a1 a2)) (a23 (mediation 1/2 a2 a3)) (a34 (mediation 1/2 a3 a4)) (a123 (mediation 1/2 a12 a23)) (a234 (mediation 1/2 a23 a34)) (a1234(mediation 1/2 a123 a234))) (if (> n 0) (begin (bezier (- n 1) a1 a12 a123 a1234) (bezier (- n 1) a1234 a234 a34 a4)) (draw a1234 #:withpen (scale '2bp 'pencircle))))) (let* ((u '1cm) (A (point 0 0)) (B (point (op* -1 u) (op* 2 u))) (C (point (op* 3 u) (op* 3 u))) (D (point (op* 2 u) 0))) (for ((A (in-list (list A B C D)))) (draw A #:withpen (scale '4bp 'pencircle))) ;; (draw (path A ".." " controls " B " and " C ".." D)) (bezier 5 A B C D)))
62.2 the result of ex-62
Examples: | ||||||
|
63 ex-63
63.1 source code in ex-63.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec 'up) '.. (point '1cm '1mm) ".." (point '2cm 0) (dir-spec 'down))))
63.2 the result of ex-63
Examples: | ||||||
|
64 ex-64
64.1 source code in ex-64.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (path (point 0 0) (dir-spec 'up) '... (point '1cm '1mm) "..." (point '2cm 0) (dir-spec 'down))))
64.2 the result of ex-64
Examples: | ||||||
|
65 ex-65
65.1 source code in ex-65.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A " {curl 0} " ".." D ".." B ".." C )))))
65.2 the result of ex-65
Examples: | ||||||
|
66 ex-66
66.1 source code in ex-66.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A " {curl 1} " ".." D ".." B ".." C )))))
66.2 the result of ex-66
Examples: | ||||||
|
67 ex-67
67.1 source code in ex-67.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (A-B-C-D) (values (point 0 0) (point '1cm 0) (point '1cm '1cm) (point 0 '1cm))) (define (main) (call-with-values A-B-C-D (lambda (A B C D) (draw (path A " {curl 2} " ".." D ".." B ".." C )))))
67.2 the result of ex-67
Examples: | ||||||
|
68 ex-68
68.1 source code in ex-68.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((A (unknown-point)) (B (unknown-point)) (C (unknown-point)) (D (unknown-point))) (eqn= (xpart A) (ypart A) (ypart B) (xpart C) 0) (eqn= (xpart B) (ypart C) (xpart D) (ypart D) '2cm) (draw (op-- A B C D 'cycle) #:withpen (scale '2bp 'pencircle))))
68.2 the result of ex-68
Examples: | ||||||
|
69 ex-69
69.1 source code in ex-69.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '2cm '3cm)) (C (point '1cm 0)) (D (point '-1cm '2cm)) (M (unknown-point)) (lambda1 (unknown-numeric)) (mu (unknown-numeric))) (eqn= M (mediation lambda1 A B) (mediation mu C D)) (draw (op-- A B)) (draw (op-- C D)) (draw M #:withpen (scale '4bp 'pencircle))))
69.2 the result of ex-69
Examples: | ||||||
|
70 ex-70
70.1 source code in ex-70.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '2cm '3cm)) (C (point '1cm 0)) (D (point '-1cm '2cm)) (M (unknown-point))) (eqn= M (mediation (whatever) A B) (mediation (whatever) C D)) (draw (op-- A B)) (draw (op-- C D)) (draw M #:withpen (scale '4bp 'pencircle))))
70.2 the result of ex-70
Examples: | ||||||
|
71 ex-71
71.1 source code in ex-71.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm)) (AA (mediation 0.5 B C)) (BB (mediation 0.5 A C)) (CC (mediation 0.5 A B)) (G (unknown-point))) (eqn= G (mediation (whatever) A AA) (mediation (whatever) B BB)) (draw (op-- A B C 'cycle)) (for ((a (list A B C)) (b (list AA BB CC))) (draw (op-- a b) #:dashed 'withdots)) (draw G #:withpen (scale '4bp 'pencircle))))
71.2 the result of ex-71
Examples: | ||||||
|
72 ex-72
72.1 source code in ex-72.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((p (fullcircle '5mm)) (x (point '1mm '2mm))) (for ((n (in-range 5))) (draw (shift (op* n x) p )))))
72.2 the result of ex-72
Examples: | ||||||
|
73 ex-73
73.1 source code in ex-73.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((p (path (point '5mm '-5mm) (dir-spec 'right) '.. (point '2cm 0)))) (for ((n (in-range 10))) (draw (rotate (* 10 n) p)))))
73.2 the result of ex-73
Examples: | ||||||
|
74 ex-74
74.1 source code in ex-74.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((p (fullcircle '5mm)) (x (point '1mm '2mm))) (for ((n (in-range 1 5))) (draw (xscale n p)))))
74.2 the result of ex-74
Examples: | ||||||
|
75 ex-75
75.1 source code in ex-75.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point '1cm 0)) (B (rotate 72 A)) (C (rotate 72 B)) (D (rotate 72 C)) (E (rotate 72 D))) (draw (op-- A B C D E 'cycle))))
75.2 the result of ex-75
Examples: | ||||||
|
76 ex-76
76.1 source code in ex-76.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point '1cm 0)) (B (rotate 72 A)) (C (rotate 72 B)) (D (rotate 72 C)) (E (rotate 72 D))) (draw (op-- A C E B D 'cycle))))
76.2 the result of ex-76
Examples: | ||||||
|
77 ex-77
77.1 source code in ex-77.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point '1cm 0)) (B (rotate 72 A)) (C (rotate 72 B)) (D (rotate 72 C)) (E (rotate 72 D)) (AA (unknown-point)) (BB (unknown-point)) (CC (unknown-point)) (DD (unknown-point)) (EE (unknown-point))) (eqn= AA (mediation (whatever) A C)) (eqn= AA (mediation (whatever) B D)) (eqn= BB (mediation (whatever) B D)) (eqn= BB (mediation (whatever) C E)) (eqn= CC (mediation (whatever) C E)) (eqn= CC (mediation (whatever) D A)) (eqn= DD (mediation (whatever) D A)) (eqn= DD (mediation (whatever) E B)) (eqn= EE (mediation (whatever) E B)) (eqn= EE (mediation (whatever) A C)) (fill (op-- A C E B D 'cycle) #:withcolor (op* 0.8 'white)) (fill (op-- AA BB CC DD EE 'cycle) #:withcolor 'white) (draw (op-- A C E B D 'cycle))))
77.2 the result of ex-77
Examples: | ||||||
|
78 ex-78
78.1 source code in ex-78.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((p (path (op-- (point 0 0) (point '1cm 0))))) (drawarrow p #:withpen (scale '2bp 'pencircle)) (drawarrow (zscale (point 1 2) p))))
78.2 the result of ex-78
Examples: | ||||||
|
79 ex-79
79.1 source code in ex-79.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (p (path (op-- (point 0 0) (point u 0)))) (A (point u (op* -1 u))) (alpha 90)) (drawarrow p #:withpen (scale '1bp 'pencircle)) (drawarrow ((rotate-around A alpha) p)) (drawarrow (shift A (rotate alpha (shift (op* -1 A) p))) #:withpen (scale '1bp 'pencircle) #:dashed 'withdots)))
79.2 the result of ex-79
Examples: | ||||||
|
80 ex-80
80.1 source code in ex-80.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (main) (let* ((p (path (point 0 0) '-- (point '1cm 0))) (A (point '1cm '-1cm)) (alpha 90)) (drawarrow p #:withpen (scale '1bp 'pencircle)) (draw A #:withpen (scale '4bp 'pencircle)) (label-ulft (btex "$A$") A) (draw (point 0 0) #:withpen (scale '4bp 'pencircle)) (label-bot (btex "$O$") (point 0 0)) (let loop ((i 0)) (if (< i 10) (begin (drawarrow (shift (op* -1 (op/ (op* i A) 10)) p) #:withcolor 'red) (drawarrow (rotate (op/ (op* i alpha) 10) (shift (op* -1 A) p)) #:withcolor 'green) (drawarrow (shift (op/ (op* i A) 10) (rotate alpha (shift (op* -1 A) p))) #:withcolor 'blue) (loop (+ 1 i))) (void)))))
80.2 the result of ex-80
Examples: | ||||||
|
81 ex-81
81.1 source code in ex-81.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (f AA A B C) (eqn= (op- AA A) (rotate 90 (op* (unknown-numeric) (op- B C)))) (eqn= AA (mediation (whatever) B C))) (let* ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm)) (AA (unknown-point)) (BB (unknown-point)) (CC (unknown-point)) (H (unknown-point))) (f AA A B C) (f BB B A C) (f CC C B A) (eqn= H (mediation (whatever) A AA)) (eqn= H (mediation (whatever) B BB)) ; (for ((x (in-list (list (op-- A B C 'cycle) (op-- A AA) (op-- B BB) (op-- C CC))))) (draw x)) (draw H #:withpen (scale '4bp 'pencircle)) ))
81.2 the result of ex-81
Examples: | ||||||
|
82 ex-82
82.1 source code in ex-82.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm)) (H (unknown-point))) (eqn= (op- H A) (rotate 90 (op* (whatever) (op- B C)))) (eqn= (op- H B) (rotate 90 (op* (whatever) (op- A C)))) (draw (op-- A B C 'cycle)) (draw H #:withpen (scale '4bp 'pencircle)) ))
82.2 the result of ex-82
Examples: | ||||||
|
83 ex-83
83.1 source code in ex-83.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm)) (O (unknown-point))) (define (f B C) (eqn= (op- O (mediation 1/2 B C)) (op* (whatever) (rotate 90 (op- B C))))) (f B C) (f A B) (draw (op-- A B C 'cycle)) (draw O #:withpen (scale '4bp 'pencircle)) (draw (fullcircle (op* 2 (op-abs (op- O A))) O))))
83.2 the result of ex-83
Examples: | ||||||
|
84 ex-84
84.1 source code in ex-84.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '2cm) (A (point 0 0)) (B (point u 0)) (C (point u u)) (D (point 0 u)) (T (unknown-transform)) (p (op-- A B C D 'cycle)) ) (eqn= (transform T A) (mediation 1/5 A B)) (eqn= (transform T B) (mediation 1/5 B C)) (eqn= (transform T C) (mediation 1/5 C D)) (draw p) (draw (transform T p))))
84.2 the result of ex-84
Examples: | ||||||
|
85 ex-85
85.1 source code in ex-85.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '2cm) (A (point 0 0)) (B (point u 0)) (C (point u u)) (D (point 0 u)) (Tx (unknown-transform)) (p (op-- A B C D 'cycle)) ) (eqn= (transform Tx A) (mediation 1/5 A B)) (eqn= (transform Tx B) (mediation 1/5 B C)) (eqn= (transform Tx C) (mediation 1/5 C D)) (for/fold ((p p)) ((i (in-range 0 100))) (draw p) (transform Tx p)) ))
85.2 the result of ex-85
Examples: | ||||||
|
86 ex-86
86.1 source code in ex-86.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point '1cm 0)) (B (rotate 72 A)) (C (rotate 72 B)) (D (rotate 72 C)) (E (rotate 72 D)) (p (op-- A B C D E 'cycle)) (T (unknown-transform))) (eqn= (transform T A) (mediation 1/5 A B)) (eqn= (transform T B) (mediation 1/5 B C)) (eqn= (transform T C) (mediation 1/5 C D)) (for/fold ((p p)) ((i (in-range 0 3))) (draw p) (transform T p))))
86.2 the result of ex-86
Examples: | ||||||
|
87 ex-87
87.1 source code in ex-87.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '3mm) (p (fullcircle (op* 2 u))) (p2 (scale 0.5 p))) (for ((x (in-list (list p (shift (op* u (dir 30)) p2) (shift (op* u (dir 150)) p2) )))) (fill x #:withcolor (op* 0.8 'white)))))
87.2 the result of ex-87
Examples: | ||||||
|
88 ex-88
88.1 source code in ex-88.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '3mm) (p (fullcircle (op* 2 u))) (p2 (scale 0.5 p)) (T (unknown-transform))) (eqn= (transform T (point 0 0)) (point 0 0)) (eqn= (transform T (point 1 0)) (point 1 1)) (eqn= (transform T (point 0 1)) (point 1 0)) (for ((p (in-list (list p (shift (op* u (dir 30)) p2) (shift (op* u (dir 150)) p2) )))) (fill (transform T p) #:withcolor (op* 0.8 'white)))))
88.2 the result of ex-88
Examples: | ||||||
|
89 ex-89
89.1 source code in ex-89.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '3mm) (p (fullcircle (op* 2 u))) (p2 (scale 0.5 p)) (T (unknown-transform))) (eqn= (xpart T) (ypart T) 0) (eqn= (xxpart T) 1) (eqn= (yxpart T) 2) (eqn= (xypart T) 3) (eqn= (yypart T) 4) (for ((p (in-list (list p (shift (op* u (dir 30)) p2) (shift (op* u (dir 150)) p2) )))) (fill (transform T p) #:withcolor (op* 0.8 'white)))))
89.2 the result of ex-89
Examples: | ||||||
|
90 ex-90
90.1 source code in ex-90.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((pic-1 (new-picture (lambda () (let ((p1 (fullcircle '1cm)) (p2 (fullcircle '5mm))) (draw p1) (draw (shift (polar '1cm 45) p2)) (draw (shift (polar '1cm 135) p2))))))) (for ((a (in-list (list (point 0 0) (point '1mm '1mm) (point '2mm '2mm))))) (draw (shift a pic-1)))))
90.2 the result of ex-90
Examples: | ||||||
|
91 ex-91
91.1 source code in ex-91.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((pic (unknown-picture))) (addto pic 'contour (fullcircle '1cm) #:withcolor (op* 0.8 'white)) (addto pic 'doublepath (fullcircle '1cm) #:withpen (scale '0.5bp 'pencircle)) (addto pic 'also (shift (point '1mm '1mm) pic)) (draw pic)))
91.2 the result of ex-91
Examples: | ||||||
|
92 ex-92
92.1 source code in ex-92.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((u '3mm) (mickey (unknown-picture))) (addto mickey 'contour (fullcircle (op* 2 u)) #:withcolor (op* 0.8 'white)) (addto mickey 'contour (fullcircle u (polar u 150)) #:withcolor (op* 0.8 'white)) (addto mickey 'contour (fullcircle u (polar u 30)) #:withcolor (op* 0.8 'white)) (draw mickey)))
92.2 the result of ex-92
Examples: | ||||||
|
93 ex-93
93.1 source code in ex-93.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((u '3mm) (mickey (unknown-picture)) (T (unknown-transform))) (addto mickey 'contour (fullcircle (op* 2 u)) #:withcolor (op* 0.8 'white)) (addto mickey 'contour (fullcircle u (polar u 150)) #:withcolor (op* 0.8 'white)) (addto mickey 'contour (fullcircle u (polar u 30)) #:withcolor (op* 0.8 'white)) (eqn= (transform T (point 0 0 )) (point 0 0)) (eqn= (transform T (point 1 0 )) (point 1 1)) (eqn= (transform T (point 0 1 )) (point 1 0)) (draw (transform T mickey))))
93.2 the result of ex-93
Examples: | ||||||
|
94 ex-94
94.1 source code in ex-94.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((mickey (new-picture (lambda () (let ((u '3mm)) (for ((p (in-list (list (fullcircle (op* 2 u)) (fullcircle u (polar u 150)) (fullcircle u (polar u 30)))))) (fill p #:withcolor (op* 0.8 'white))))))) (T (unknown-transform))) (for ((v1 (in-list (list (point 0 0) (point 1 0) (point 0 1)))) (v2 (in-list (list (point 0 0) (point 1 1) (point 1 0))))) (eqn= (transform T v1) v2)) (draw (transform T mickey))))
94.2 the result of ex-94
Examples: | ||||||
|
95 ex-95
95.1 source code in ex-95.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 '1cm)) (B (rotate 120 A)) (p (path A (dir-spec (dir 0)) '.. 'tension 2 '.. B (dir-spec (dir 120))))) (for ((p (in-list (list p (rotate 120 p) (rotate -120 p))))) (draw p)) ))
95.2 the result of ex-95
Examples: | ||||||
|
96 ex-96
96.1 source code in ex-96.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((n 5) (alpha (/ (* 2 360) n)) (A (point 0 '1cm)) (B (rotate alpha A)) (p (path A (dir-spec (dir 180)) '.. 'tension 4 '.. B (dir-spec (dir (+ 180 alpha)))))) (draw p #:withcolor 'red) (for ((i (in-range 1 5))) (draw (rotate (* i (/ 360 n)) p))) ))
96.2 the result of ex-96
Examples: | ||||||
|
97 ex-97
97.1 source code in ex-97.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((c0 (fullcircle '1cm (point 0 '1cm) 1 0.5)) (c1 (rotate 120 c0)) (c2 (rotate 120 c1)) (A (point '-0.5cm '1cm)) (l0 (path A (dir-spec 'down) '.. (rotate 120 (xscale -1 A)) (dir-spec (rotate 120 (op* -1 'down))))) (l1 (rotate 120 l0)) (l2 (rotate 120 l1))) (for ((x (in-list (list c0 c1 c2 l0 l1 l2 )))) (draw x) )))
97.2 the result of ex-97
Examples: | ||||||
|
98 ex-98
98.1 source code in ex-98.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((c0 (fullcircle '1cm (point 0 '1cm) 1 0.5)) (c1 (rotate 90 c0)) (c2 (rotate 90 c1)) (c3 (rotate 90 c2)) (A (point '-0.5cm '1cm)) (l0 (path A (dir-spec 'down) '.. (rotate 90 (xscale -1 A)) (dir-spec (rotate 90 (op* -1 'down))))) (l1 (rotate 90 l0)) (l2 (rotate 90 l1)) (l3 (rotate 90 l2))) (for ((x (in-list (list c0 c1 c2 c3 l0 l1 l2 l3 )))) (draw x) )))
98.2 the result of ex-98
Examples: | ||||||
|
99 ex-99
99.1 source code in ex-99.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '2cm '1cm)) (p (fullcircle (op-abs (op- B A)) (mediation 0.5 A B)))) (for ((x (in-list (list A B)))) (draw x #:withpen (scale '4bp 'pencircle))) (draw p)))
99.2 the result of ex-99
Examples: | ||||||
|
100 ex-100
100.1 source code in ex-100.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((origin (point 0 0)) (A (point '2cm '2cm))) (for ((i (in-range 4))) (drawarrow (rotate (op* (* i -1/3) (op-angle A)) (op-- origin A))))))
100.2 the result of ex-100
Examples: | ||||||
|
101 ex-101
101.1 source code in ex-101.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((origin (point 0 0)) (A (point '1cm '2cm)) (B (point '2cm '1cm)) (alpha (op- (op-angle A) (op-angle B)))) (drawarrow (op-- origin A)) (drawarrow (op-- origin B)) (for ((i (in-range 3))) (drawarrow (rotate (op* (* i -1/3) alpha) (op-- origin A)))) ))
101.2 the result of ex-101
Examples: | ||||||
|
102 ex-102
102.1 source code in ex-102.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (require (planet wcy/mpost-wrapper/label)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm))) (draw (op-- A B C 'cycle)) (label-llft (TEX (decimal (op- (op-angle (op- C A)) (op-angle (op- B A))))) A) (label-lrt (TEX (decimal (op- (op-angle (op- A B)) (op-angle (op- C B))))) B) (label-urt (TEX (decimal (op- (op-angle (op- B C)) (op-angle (op- A C))))) C) ))
102.2 the result of ex-102
Examples: | ||||||
|
103 ex-103
103.1 source code in ex-103.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 0)) (B (point '3cm 0)) (C (point '1cm '2cm)) (AA (mediation 0.5 B C)) (BB (mediation 0.5 A C)) (CC (mediation 0.5 A B)) (O (unknown-point)) (polar (unknown-numeric))) (eqn= (op- O (mediation 0.5 BB CC)) (op* (whatever) (rotate 90 (op- BB CC)))) (eqn= (op- O (mediation 0.5 AA BB)) (op* (whatever) (rotate 90 (op- AA BB)))) (draw (op-- A B C 'cycle)) (for ((x (in-list (list AA BB CC)))) (draw x #:withpen (scale '4bp 'pencircle ))) (draw (fullcircle (op* 2 (op-abs (op- O AA))) O)) (let ((AA (unknown-point)) (BB (unknown-point)) (CC (unknown-point)) (H (unknown-point))) (for ((vAA (in-list (list AA BB CC))) (vA (in-list (list A B C))) (vB (in-list (list B C A))) (vC (in-list (list C A B)))) (eqn= (op- vAA vA) (op* (whatever) (rotate 90 (op- vB vC)))) (eqn= vAA (mediation (whatever) vB vC))) (for ((vA (in-list (list A B C))) (vAA (in-list (list AA BB CC)))) (draw (op-- vA vAA))) (for ((x (in-list (list AA BB CC)))) (draw x #:withpen (scale '4bp 'pencircle ))) (eqn= H (mediation (whatever) A AA)) (eqn= H (mediation (whatever) B BB)) (for ((x (in-list (list A B C)))) (draw (mediation 0.5 x H) #:withpen (scale '4bp 'pencircle))) )))
103.2 the result of ex-103
Examples: | ||||||
|
104 ex-104
104.1 source code in ex-104.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '2cm) (A (point 0 0)) (B (point (op* 2 u) (op* -0.5 u))) (C (point u u)) (M (unknown-point)) (h (unknown-point))) (draw (op-- A B C 'cycle)) (eqn= (op- M A) (op* (whatever) (rotate (op* 0.5 (op- (op-angle (op- B A)) (op-angle (op- C A)))) (op- A C)))) (eqn= (op- M B) (op* (whatever) (rotate (op* 0.5 (op- (op-angle (op- C B)) (op-angle (op- A B)))) (op- B A)))) (for ((x (in-list (list A B C)))) (draw (op-- M x))) (eqn= (op- M h) (op* (whatever) (rotate 90 (op- B C)))) (eqn= h (mediation (whatever) B C) ) (draw (fullcircle (op* 2 (op-abs (op- M h))) M))))
104.2 the result of ex-104
Examples: | ||||||
|
105 ex-105
105.1 source code in ex-105.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (path (point 0 0) (dir-spec 'up) '.. (point '2cm 0) (dir-spec 'down)))) (draw p) (for ((i (in-list (list 0 0.5 1)))) (draw (point-of i p) #:withpen (scale '4bp 'pencircle))) ))
105.2 the result of ex-105
Examples: | ||||||
|
106 ex-106
106.1 source code in ex-106.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (path (point 0 0) (dir-spec 'up) '.. (point '2cm 0) (dir-spec 'down))) (A (point-of 0 p))) (draw p) (for ((i (in-list (list 0 0.5 1)))) (let* ((A (point-of i p)) (B (op+ A (polar '1cm (op-angle (direction-of i p)))))) (drawarrow (op-- A B) #:withpen (scale '1bp 'pencircle))))))
106.2 the result of ex-106
Examples: | ||||||
|
107 ex-107
107.1 source code in ex-107.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '5mm) (p (path (point 0 0) (dir-spec '(curl 0)) '.. (point u (op* 2 u)) '.. (point (op* 2 u) (op* 1.5 u)) '.. (point (op* 3 u) (op* 2 u)) '.. (dir-spec '(curl 0)) (point (op* 4 u) 0)))) (draw (subpath-of 0 1 p) #:withcolor 'red) (draw (subpath-of 1 2 p) #:withcolor 'green) (draw (subpath-of 2 3 p) #:withcolor 'blue) (draw (subpath-of 3 3.5 p) #:dashed 'evenly) (draw (subpath-of 3.5 4 p) #:dashed 'withdots)))
107.2 the result of ex-107
Examples: | ||||||
|
108 ex-108
108.1 source code in ex-108.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (p (path (point 0 0) (dir-spec 'up) '.. (point u (op* 2 u)) (dir-spec 'up))) (q (path (point u 0) (dir-spec 'up) '.. (point 0 (op* 2 u)) (dir-spec 'up)))) (draw p) (draw (subpath-of 0 0.4 q) #:withpen (scale '1bp 'pencircle)) (draw (subpath-of 0.6 1 q) #:withpen (scale '1bp 'pencircle))))
108.2 the result of ex-108
Examples: | ||||||
|
109 ex-109
109.1 source code in ex-109.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (a (path (point (op* -1 u) (op* -0.2 u)) '.. 'tension 1.2 '.. (point u (op* -0.2 u)) (dir-spec 'down))) (b (rotate 90 a)) (c (rotate 90 b)) (d (rotate 90 c))) (fill (buildcycle a b c d) #:withcolor (op* 0.8 'white)) (map draw (list a b c d))))
109.2 the result of ex-109
Examples: | ||||||
|
110 ex-110
110.1 source code in ex-110.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (c1 (fullcircle u)) (c2 (fullcircle u (point 0 (op* 0.5 u))))) (draw c1 #:dashed 'evenly) (draw c2 #:dashed 'evenly) (draw (buildcycle c1 c2) #:withpen (scale '1bp 'pencircle))))
110.2 the result of ex-110
Examples: | ||||||
|
111 ex-111
111.1 source code in ex-111.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (a (fullcircle (op* 2 u) (point (op* 0.5 u) 0))) (b (rotate (/ 360 3) a)) (c (rotate (/ 360 3) b))) (fill a #:withcolor 'red) (fill b #:withcolor 'green) (fill c #:withcolor 'blue) (fill (buildcycle a b) #:withcolor (op+ 'red 'green)) (fill (buildcycle b c) #:withcolor (op+ 'green 'blue)) (fill (buildcycle c a) #:withcolor (op+ 'blue 'red)) (fill (buildcycle a b c) #:withcolor 'white) (draw a) (draw b) (draw c) ))
111.2 the result of ex-111
Examples: | ||||||
|
112 ex-112
112.1 source code in ex-112.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (compute_curve f xmin xmax xinc) (apply op.. (for/list ((x (in-range xmin xmax xinc))) (point x (f x))))) (define (f x) (op+ 1 (op** x 2))) (define (g x) (op- 2 (op** (op- x 1) 2))) (let* ((p (scale '1cm (compute_curve f -1 1.5 0.1))) (q (scale '1cm (compute_curve g -0.5 2 0.1)))) (fill (buildcycle p (op-reverse q)) #:withcolor (op+ 'red 'green)) (draw p #:withpen (scale '1bp 'pencircle)) (draw q #:withpen (scale '1bp 'pencircle)) (draw (op-- (point '-1cm 0) (point '2cm 0))) (draw (op-- (point 0 (op* (g -0.5) '1cm)) (point 0 (op* (f 1.5) '1cm)))) ))
112.2 the result of ex-112
Examples: | ||||||
|
113 ex-113
113.1 source code in ex-113.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (path (point 0 0) (dir-spec 'up) '.. (point '2cm 0) (dir-spec 'up))) (q (path (point 0 '1cm) (dir-spec (dir -60)) '.. (point '1cm '-1cm) '.. (dir-spec (dir 60)) (point '2cm '1cm)))) (draw p) (draw q) (draw (intersectionpoint p q) #:withpen (scale '4bp 'pencircle))))
113.2 the result of ex-113
Examples: | ||||||
|
114 ex-114
114.1 source code in ex-114.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (path (point 0 0) (dir-spec 'up) '.. (point '2cm 0) (dir-spec 'up))) (q (path (point 0 '1cm) (dir-spec (dir -60)) '.. (point '1cm '-1cm) '.. (dir-spec (dir 60)) (point '2cm '1cm))) (a (unknown-numeric)) (b (unknown-numeric))) (draw p) (draw q) (eqn= (point a (whatever)) (intersectiontimes p q)) (draw (point-of a p) #:withpen (scale '4bp 'pencircle))))
114.2 the result of ex-114
Examples: | ||||||
|
115 ex-115
115.1 source code in ex-115.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((A (point 0 '1cm)) (B (rotate 120 A)) (p (path A (dir-spec (dir 0)) '.. 'tension 2 '.. B (dir-spec (dir 120)))) (a (unknown-numeric))) (eqn= (point a (whatever)) (intersectiontimes p (rotate 120 p))) (draw (subpath-of 0 (op- a 0.02) p)) (draw (subpath-of (op+ a 0.02) 1 p)) (draw (subpath-of 0 (op- a 0.02) (rotate 120 p))) (draw (subpath-of (op+ a 0.02) 1 (rotate 120 p))) (draw (subpath-of 0 (op- a 0.02) (rotate -120 p))) (draw (subpath-of (op+ a 0.02) 1 (rotate -120 p)))))
115.2 the result of ex-115
Examples: | ||||||
|
116 ex-116
116.1 source code in ex-116.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (draw-extra n p op-x) (let ((pn (point-of n p))) (draw (op-- pn (op-x pn (op* '4mm (unitvector (direction-of n p)))))))) (define (main) (let* ((u '2cm) (A0 (op* u 'up)) (A (reverse (for/fold ((r (list A0))) ((i (in-range 1 11))) (cons (rotate 72 (car r)) r)))) (B* (for/list ((A_i (in-list A)) (A_i+1 (in-list (cdr A))) (i (in-range 0 10))) (mediation 0.5 A_i A_i+1))) (B (for/list ((b_i (in-range 0 10))) (list-ref B* (if (= b_i 5) 0 b_i)))) (C (for/list ((b_i (in-list B))) (op* 0.8 b_i)))) (for ((A_i (in-list A)) (A_i+1 (in-list (cdr A)))) (let* ((p_i (op-- A_i A_i+1))) (draw p_i) (draw-extra 1 p_i op+) (draw-extra 0 p_i op-))) (let ((p (for/list ((i (in-range 0 5))) (let* ((p_i (path (list-ref B i) '--- (list-ref C i) '.. (list-ref C (+ 2 i)) (dir-spec (dir (* 72 i))) ))) (draw p_i) (draw-extra 2 p_i op+ ) (draw-extra 0 p_i op- ) p_i)))) (for ((p_i (in-list p))) (draw (subpath-of 1 1.4 p_i) #:withpen (scale '4bp 'pencircle) #:withcolor 'white) (draw (subpath-of 0 1.5 p_i) )) (for ((A_i (in-list A)) (B_i (in-list B)) (C_i (in-list C))) (for ((x (in-list (list A_i B_i C_i)))) (draw x #:withpen (scale '4bp 'pencircle)))))))
116.2 the result of ex-116
Examples: | ||||||
|
117 ex-117
117.1 source code in ex-117.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '2cm) (A (op* u 'up)) (B (mediation 0.5 A (rotate 72 A))) (C (op* 0.8 B)) (p (op-- (mediation -0.2 A (rotate 72 A)) (mediation 1.2 A (rotate 72 A))))) (for ((i (in-range 6))) (draw (rotate (* i 72) p))) (let* ((p* (path B '--- C '.. (rotate (* 2 72) C) (dir-spec 'right))) (p (op& (path (op- (point-of 0 p*) (op* '4mm (unitvector (direction-of 0 p*)))) '-- (point-of 0 p*)) p* (path (point-of 2 p*) '-- (op+ (point-of 2 p*) (op* '4mm (unitvector (direction-of 2 p*))))))) (E (intersectionpoint p (rotate 72 p))) (q (cutbefore p (fullcircle '-2mm E))) (r (cutafter p (fullcircle '2mm E)))) (for ((i (in-range 6))) (let ((rotate-it (lambda (x) (rotate (* 72 i) x)))) (for ((x (in-list (list q r A)))) (draw (rotate-it x))) (for ((x (in-list (list A B C)))) (draw (rotate-it x) #:withpen (scale '4bp 'pencircle))))))))
117.2 the result of ex-117
Examples: | ||||||
|
118 ex-118
118.1 source code in ex-118.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (for ((i (in-range 4))) (draw (rotate (* i 90) (op* '1cm 'right)) #:withpen (scale '4bp 'pencircle))))
118.2 the result of ex-118
Examples: | ||||||
|
119 ex-119
119.1 source code in ex-119.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (draw (apply op-- `(,@(for/list ((i (in-range 4))) (rotate (* i 90) (op* '1cm 'right))) cycle))))
119.2 the result of ex-119
Examples: | ||||||
|
120 ex-120
120.1 source code in ex-120.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((n 5)) (draw (apply op-- `(,@(for/list ((i (in-range n))) (rotate (/ (* i 360) n) (op* '1cm 'up))) cycle)))))
120.2 the result of ex-120
Examples: | ||||||
|
121 ex-121
121.1 source code in ex-121.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let ((n 7)) (draw (apply op-- `(,@(for/list ((i (in-range n))) (rotate (/ (* i 360) n) (op* '1cm 'up))) cycle)))))
121.2 the result of ex-121
Examples: | ||||||
|
122 ex-122
122.1 source code in ex-122.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (op.. (point 0 0) (point '-1cm '2cm) (point '2cm '1cm) (point '1cm 0))) (n 10) (length-p (length p))) (draw p) (for ((i (in-range (+ 1 n)))) (draw (point-of (op* (/ i n) length-p) p) #:withpen (scale '4bp 'pencircle)))))
122.2 the result of ex-122
Examples: | ||||||
|
123 ex-123
123.1 source code in ex-123.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((p (op.. (point 0 0) (point '-1cm '2cm) (point '2cm '1cm) (point '1cm 0))) (n 10) (length-p (length p))) (draw p) (for ((i (in-range 0 1 (/ 1 n)))) (let ((pi (point-of (op* i length-p) p))) (drawarrow (op-- pi (shift pi (op* '1cm (unitvector (direction-of (op* i length-p) p))))))))))
123.2 the result of ex-123
Examples: | ||||||
|
124 ex-124
124.1 source code in ex-124.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm)) (draw (op-- (point (op* -2 u) 0) (point (op* 2 u) 0))) (draw (op-- (point 0 (op* -2 u)) (point 0 (op* 2 u)))) (for ((i (in-range -2 3 1))) (draw (op-- (point (op* i u) (op/ u 20)) (point (op* i u) (op/ u -20)))) (draw (op-- (point (op/ u 20) (op* i u)) (point (op/ u -20) (op* i u)))))))
124.2 the result of ex-124
Examples: | ||||||
|
125 ex-125
125.1 source code in ex-125.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm)) (draw (op-- (point (op* -2 u) 0) (point (op* 2 u) 0))) (draw (op-- (point 0 (op* -2 u)) (point 0 (op* 2 u)))) (for ((i (in-range -2 3 1))) (draw (op-- (point (op* i u) (op/ u 10)) (point (op* i u) (op/ u -10)))) (draw (op-- (point (op/ u 10) (op* i u)) (point (op/ u -10) (op* i u))))) (for ((i (in-range -2 2.01 0.2))) (draw (op-- (point (op* i u) (op/ u 20)) (point (op* i u) (op/ u -20)))) (draw (op-- (point (op/ u 20) (op* i u)) (point (op/ u -20) (op* i u)))))))
125.2 the result of ex-125
Examples: | ||||||
|
126 ex-126
126.1 source code in ex-126.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm)) (draw (op-- (point (op* -2 u) 0) (point (op* 2 u) 0))) (draw (op-- (point 0 (op* -2 u)) (point 0 (op* 2 u)))) (for ((i (in-range -2 2.01 1))) (draw (op-- (point (op* i u) (op* u 2)) (point (op* i u) (op* u -2)))) (draw (op-- (point (op* u 2) (op* i u)) (point (op* u -2) (op* i u)))) )))
126.2 the result of ex-126
Examples: | ||||||
|
127 ex-127
127.1 source code in ex-127.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm)) (draw (op-- (point (op* -2 u) 0) (point (op* 2 u) 0))) (draw (op-- (point 0 (op* -2 u)) (point 0 (op* 2 u)))) (for ((i (in-range -2 2.01 1))) (draw (op-- (point (op* i u) (op* u 2)) (point (op* i u) (op* u -2)))) (draw (op-- (point (op* u 2) (op* i u)) (point (op* u -2) (op* i u)))) ) (for ((i (in-range -2 2.01 0.2))) (draw (op-- (point (op* i u) (op* u 2)) (point (op* i u) (op* u -2))) #:withpen (scale '0.2bp 'pencircle)) (draw (op-- (point (op* u 2) (op* i u)) (point (op* u -2) (op* i u))) #:withpen (scale '0.2bp 'pencircle)) )))
127.2 the result of ex-127
Examples: | ||||||
|
128 ex-128
128.1 source code in ex-128.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '5mm)) (define (f x) (op- (op** x 2 ) 0.1)) (define (my-draw x) (draw (scale u x))) (define (f-x x) (point x (f x))) (define (axes xmin xmax ymin ymax) (my-draw (op-- (point xmin 0) (point xmax 0))) (my-draw (op-- (point 0 ymin) (point 0 ymax)))) (define (courbe f xmin xmax M) (let ((x-range (in-range xmin xmax (/ (- xmax xmin) M)))) (my-draw (apply op-- (map f-x (stream->list x-range)))))) (define (newton f y h M) (define (diff-f x) (op/ (op- (f (op+ x h)) (f x)) h)) (define (newton-helper x) (op- x (op/ (f x) (diff-f x)))) (for/fold ((x y) (t (newton-helper y))) ((i (in-range M))) (my-draw (op-- (f-x x) (point t 0) (f-x t))) (values t (newton-helper x)))) (axes -0.5 2 -0.5 4) (courbe f -0.5 2 100) (newton f 2 0.01 10)))
128.2 the result of ex-128
Examples: | ||||||
|
129 ex-128-b
129.1 source code in ex-128-b.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '5mm)) (define (f x) (op- (op** x 2 ) 0.1)) (define (my-draw x) (draw (scale u x))) (define (f-x x) (point x (f x))) (define (axes xmin xmax ymin ymax) (my-draw (op-- (point xmin 0) (point xmax 0))) (my-draw (op-- (point 0 ymin) (point 0 ymax)))) (define (courbe f xmin xmax M) (let ((x-range (in-range xmin xmax (/ (- xmax xmin) M)))) (my-draw (apply op-- (map f-x (stream->list x-range)))))) (define (newton f y h M) (define (diff-f x) (op/ (op- (f (op+ x h)) (f x)) h)) (define (newton-helper x) (op- x (op/ (f x) (diff-f x)))) (for/fold ((x y) (t (newton-helper y))) ((i (in-range M))) (my-draw (op-- (f-x x) (point t 0) (f-x t))) (values t (newton-helper x)))) (axes -0.5 2 -0.5 4) (courbe f -0.5 2 100) (newton f 2 0.01 10)))
129.2 the result of ex-128-b
Examples: | ||||||
|
130 ex-129
130.1 source code in ex-129.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((T (unknown-transform)) (u '1cm) (z0 (point 0 0)) (z1 (point (op* 2 u) 0)) (z3 (rotate 90 z1)) (z2 (op+ z1 z3)) (p (op-- z0 z1 z2 z3 'cycle))) (for ((a (in-list (list z0 z1 z2))) (b (in-list (list z1 z2 z3)))) (eqn= (transform T a) (mediation 0.1 a b))) (fill p #:withcolor (op* 0.8 'white)) (fill (transform T p) #:withcolor 'white) ))
130.2 the result of ex-129
Examples: | ||||||
|
131 ex-130
131.1 source code in ex-130.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((T (unknown-transform)) (u '1cm) (z0 (point 0 0)) (z1 (point (op* 2 u) 0)) (z3 (rotate 90 z1)) (z2 (op+ z1 z3)) (p (op-- z0 z1 z2 z3 'cycle))) (for ((a (in-list (list z0 z1 z2))) (b (in-list (list z1 z2 z3)))) (eqn= (transform T a) (mediation 0.1 a b))) (for/fold ((p p)) ((i (in-range 201))) (fill p #:withcolor (if (= (modulo i 2) 0) (op* 0.8 'white) 'white)) (transform T p))))
131.2 the result of ex-130
Examples: | ||||||
|
132 ex-131
132.1 source code in ex-131.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((T (unknown-transform)) (u '1cm) (z (point 0 (op* 2 u))) (n 5) (zn (map (lambda (i) (rotate (/ (* 360 i) n) z)) (stream->list (in-range n)))) (p (apply op-- `(,@zn cycle)))) (for ((i (in-range 1 4))) (eqn= (transform T (list-ref zn i)) (mediation 0.1 (list-ref zn i) (list-ref zn (+ 1 i))))) (for/fold ((p p)) ((i (in-range 201))) (fill p #:withcolor (if (= (modulo i 2) 0) (op* 0.8 'white) 'white)) (transform T p))))
132.2 the result of ex-131
Examples: | ||||||
|
133 ex-132
133.1 source code in ex-132.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (n 7) (A0 (point u 0)) (An (map (lambda (i) (rotate (/ (* 360 i) n) A0)) (stream->list (in-range n))))) (for ((Ai (in-list An))) (draw Ai #:withpen (scale '4bp 'pencircle))) (for* ((i (in-range n)) (j (in-range n))) (when (not (= i j)) (draw (op-- (list-ref An i) (list-ref An j)))))))
133.2 the result of ex-132
Examples: | ||||||
|
134 ex-133
134.1 source code in ex-133.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (funcall f) (f)) (let* ((u '2cm) (n 4) (m 5) (An (map funcall (make-list n unknown-point))) (Bn (map funcall (make-list m unknown-point)))) (for ((Xn (in-list (list An Bn)))) (for ((Xi (in-list Xn)) (Xi+1 (in-list (cdr Xn)))) (eqn= (op- Xi+1 Xi) (point 0 (op* 0.2 u))))) (eqn= (apply op+ An) (point 0 0)) (eqn= (apply op+ Bn) (point (op* 4 u) 0)) (define (draw-point x) (draw x #:withpen (scale '4bp 'pencircle))) (map draw-point An) (map draw-point Bn) (for* ((Ai (in-list An)) (Bi (in-list Bn))) (draw (op-- Ai Bi)))))
134.2 the result of ex-133
Examples: | ||||||
|
135 ex-134
135.1 source code in ex-134.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (funcall f) (f)) (let* ((u '1cm) (n 3) (m 3) (An (map funcall (make-list n unknown-point))) (Bn (map funcall (make-list m unknown-point)))) (for ((Xn (in-list (list An Bn)))) (for ((Xi (in-list Xn)) (Xi+1 (in-list (cdr Xn)))) (eqn= (op- Xi+1 Xi) (point (op* 0.5 u) 0)))) (eqn= (apply op+ An) (point 0 0)) (eqn= (apply op+ Bn) (point 0 (op* 4 u))) (define (draw-point x) (draw x #:withpen (scale '4bp 'pencircle))) (map draw-point An) (map draw-point Bn) (for* ((Ai (in-list An)) (Bi (in-list Bn))) (draw (op-- Ai Bi)))))
135.2 the result of ex-134
Examples: | ||||||
|
136 ex-135
136.1 source code in ex-135.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((n 6) (P (lambda (d) (for/list ((i (in-range (+ 1 n)))) (rotate (/ (* i 360) n) (op* d 'right))))) (An (P '1cm)) (Bn (P '2cm))) (define (draw-point x) (draw x #:withpen (scale '4bp 'pencircle))) (map draw-point An) (map draw-point Bn) (for ((Ai (in-list An)) (Ai+1 (in-list (cdr An))) (Bi (in-list Bn)) (Bi+1 (in-list (cdr Bn)))) (draw (op-- Ai Ai+1 Bi+1 Bi)))))
136.2 the result of ex-135
Examples: | ||||||
|
137 ex-136
137.1 source code in ex-136.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((n 5) (O (point 0 0)) (A (op* '1cm 'up)) (B ((rotate-around A 30 ) (op* '2cm 'up))) (C (op* '2cm 'up)) (D ((rotate-around A -30) (op* '2cm 'up)))) (define (draw-point x) (draw x #:withpen (scale '4bp 'pencircle))) (define ((rotate-draw i f) obj) (f (rotate (/ (* i 360) n) obj))) (for ((i (in-range n))) ((rotate-draw i draw) (op-- O A C)) ((rotate-draw i draw) (op-- B A D)) (map (rotate-draw i draw-point) (list A B C D)))))
137.2 the result of ex-136
Examples: | ||||||
|
138 ex-137
138.1 source code in ex-137.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '1cm) (p (yscale (op* 3 u) (xscale (op* -1 u) 'fullcircle)))) (draw p) (define (draw-point x) (draw x #:withpen (scale '4bp 'pencircle))) (for ((i (in-range 2 6.1 0.5))) (draw (path (point-of 2 p) (dir-spec 'down) '.. (point-of i p))))))
138.2 the result of ex-137
Examples: | ||||||
|
139 ex-138
139.1 source code in ex-138.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (i-of-360 i n) (/ (* 360 i ) n)) (let* ((u '0.5cm) (P* (for/list ((i (in-range 5))) (rotate (i-of-360 i 5) (op* u 'down)))) (P `(,@P* ,(car P*))) (Q* (for/list ((Pi (in-list P)) (Pi+1 (in-list (cdr P)))) (op* 3 (mediation 0.5 Pi Pi+1)))) (Q `(,@Q* ,(car Q*))) (R* (for/list ((Qi (in-list Q)) (Qi+1 (in-list (cdr Q))) (Pi+1 (in-list (cdr P)))) (op* 1/3 (op+ Qi Qi+1 Pi+1)))) (R `(,@R* ,(car R*))) (S (map (curry op* 1.5) Q))) (for ((Pi (in-list P)) (Pi+1 (in-list (cdr P))) (Qi (in-list Q)) (Qi+1 (in-list (cdr Q))) (Ri (in-list R)) (Si (in-list S)) (Si+1 (in-list (cdr S)))) (draw (op-- Pi Pi+1)) (draw (op-- Pi+1 Ri)) (draw (op-- Qi Ri)) (draw (op-- Ri Qi+1)) (draw (op-- Qi Si)) (draw (op-- Si Si+1)) )))
139.2 the result of ex-138
Examples: | ||||||
|
140 ex-139
140.1 source code in ex-139.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (i-of-360 i n) (/ (* 360 i ) n)) (let* ((u '0.5cm) (P* (for/list ((i (in-range 5))) (rotate (i-of-360 i 5) (op* u 'down)))) (P `(,@P* ,(car P*))) (Q* (for/list ((Pi (in-list P)) (Pi+1 (in-list (cdr P)))) (op* 3 (mediation 0.5 Pi Pi+1)))) (Q `(,@Q* ,(car Q*))) (R* (for/list ((Qi (in-list Q)) (Qi+1 (in-list (cdr Q))) (Pi+1 (in-list (cdr P)))) (op* 1/3 (op+ Qi Qi+1 Pi+1)))) (R `(,@R* ,(car R*))) (S (map (curry op* 1.5) Q))) (for ((Pi (in-list P)) (Pi+1 (in-list (cdr P))) (Qi (in-list Q)) (Qi+1 (in-list (cdr Q))) (Ri (in-list R)) (Si (in-list S)) (Si+1 (in-list (cdr S)))) (draw (op-- Pi Pi+1)) (draw (op-- Pi+1 Ri)) (draw (op-- Qi Ri)) (draw (op-- Ri Qi+1)) (draw (op-- Qi Si)) (draw (op-- Si Si+1))) (draw (op-- (list-ref P 2) (list-ref P 3) (list-ref P 4) (list-ref P 0) (list-ref P 1) (list-ref R 0) (list-ref Q 0) (list-ref R 4) (list-ref Q 4) (list-ref R 3) (list-ref Q 3) (list-ref R 2) (list-ref Q 2) (list-ref S 2) (list-ref S 3) (list-ref S 4) (list-ref S 0) (list-ref S 1) (list-ref Q 1) (list-ref R 1) 'cycle) #:withpen (scale '2bp 'pencircle))))
140.2 the result of ex-139
Examples: | ||||||
|
141 ex-140
141.1 source code in ex-140.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (for ((i (in-range 1.0 0.0 -0.01 ))) (fill (fullcircle (op* i '2cm)) #:withcolor (op* i 'white))) (draw (fullcircle '2cm) #:withpen (scale '2bp 'pencircle)))
141.2 the result of ex-140
Examples: | ||||||
|
142 ex-141
142.1 source code in ex-141.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((u '5mm) (p (shift (point -1 0) (op.. (point 0 0) (point -1 1) (point 2 0) (point 0 -3) 'cycle)))) (for ((i (in-range 1.0 0.0 -0.01 ))) (fill (scale (op* i u) p) #:withcolor (op* i 'white))) (draw (scale u p) #:withpen (scale '2bp 'pencircle))))
142.2 the result of ex-141
Examples: | ||||||
|
143 ex-142
143.1 source code in ex-142.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((z0 (point 50 50)) (z1 (rotate 90 z0)) (z2 (rotate 90 z1)) (z3 (rotate 90 z2)) (carre (op-- z0 z1 z2 z3 'cycle)) (s 0.01) (z4 (mediation s z2 z3)) (z5 (mediation s z1 z0)) (rect (op-- z1 z2 z3 z4 z5 'cycle))) (for ((i (in-range 0.0 1.0 s ))) (fill (shift (op* i (op- z0 z1)) rect) #:withcolor (op* i 'white))) (draw carre #:withpen (scale '2bp 'pencircle))))
143.2 the result of ex-142
Examples: | ||||||
|
144 ex-143
144.1 source code in ex-143.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (let* ((z0 (point 50 50)) (z1 (rotate 90 z0)) (z2 (rotate 90 z1)) (z3 (rotate 90 z2)) (carre (op-- z0 z1 z2 z3 'cycle)) (s 0.01)) (for ((i (in-range 1 s (- s) ))) (fill (scale i carre) #:withcolor (op* i 'white)))))
144.2 the result of ex-143
Examples: | ||||||
|
145 ex-144
145.1 source code in ex-144.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (degrade q p M N) (let ((a (length p)) (b (length q))) (for ((i (in-range 0 (+ 1 M)))) (draw (apply op.. `(,(mediation (/ i M) (point-of 0 p) (point-of 0 q)) ,@(for/list ((j (in-range 0 (+ 1 N)))) (mediation (/ i M ) (point-of (op* a (/ j N)) p) (point-of (op* b (/ j N)) q))))))))) (let* ((u '1cm)) (degrade (op.. (point (op* -0.1 u) (op* -0.1 u)) (point (op* 0.1 u) (op* 0.1 u)) 'cycle) (op-- (point (op* -1 u) (op* -1 u)) (point (op* 1 u) (op* -1 u)) (point (op* 1 u) (op* 1 u)) (point (op* -1 u) (op* 1 u)) 'cycle) 10 100)))
145.2 the result of ex-144
Examples: | ||||||
|
146 ex-145
146.1 source code in ex-145.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (couleur c) (op* (- 1.0 c) 'white)) (define (degrade q p M N) (let ((a (length p)) (b (length q))) (for ((i (in-range 0 (+ 1 M)))) (draw (apply op.. `(,(mediation (/ i M) (point-of 0 p) (point-of 0 q)) ,@(for/list ((j (in-range 0 (+ 1 N)))) (mediation (/ i M ) (point-of (op* a (/ j N)) p) (point-of (op* b (/ j N)) q))))) #:withcolor (couleur (/ i M)))))) (let* ((u '1cm)) (degrade (op.. (point (op* -0.5 u) (op* -0.5 u)) (point (op* 0.5 u) (op* 0.5 u)) 'cycle) (op-- (point (op* -1 u) (op* -1 u)) (point (op* 1 u) (op* -1 u)) (point (op* 1 u) (op* 1 u)) (point (op* -1 u) (op* 1 u)) 'cycle) 70 100)))
146.2 the result of ex-145
Examples: | ||||||
|
147 ex-146
147.1 source code in ex-146.rkt
#lang racket (require (planet wcy/mpost-wrapper)) (provide main) (define (main) (define (couleur c) (op* (- 1.0 c) 'white)) (define (d-s-j-n c j M n p) (direction-of c (subpath-of (op/ (op* (- j 1) n) M) (op/ (op* j n) M) p))) (define (degrade q p N) (let* ((n (length p)) (m (length q)) (M (* 8 4);; (op* m n) )) (for ((i (in-range 0 (+ 1 N)))) (draw (apply path `(,(mediation (/ i N) (point-of 0 p) (point-of 0 q)) ,(dir-spec (mediation (/ i N) (direction-of 0 p) (direction-of 0 q))) ,@(flatten (for/list ((j (in-range 1 M))) `(.. ,(dir-spec (mediation (/ i N) (d-s-j-n 1 j M n p) (d-s-j-n 1 j M m q))) ,(mediation (/ i N) (point-of (op/ (op* j n) M) p) (point-of (op/ (op* j m) M) q)) ,(dir-spec (mediation (/ i N) (d-s-j-n 1 (+ j 1) M n p) (d-s-j-n 1 (+ j 1) M m q)))))) .. ,(dir-spec (mediation (/ i N) (direction-of n p) (direction-of m q))) ,(mediation (/ i N) (point-of n p) (point-of m q)))))))) (let* ((u '2cm) (p (fullcircle u)) (q (op-- (point (op* -1 u) (op* -1 u)) (point (op* 1 u) (op* -1 u)) (point (op* 1 u) (op* 1 u)) (point (op* -1 u) (op* 1 u)) 'cycle))) (degrade p q 10)))
147.2 the result of ex-146
Examples: | ||||||
|