Things were was executing ok until I added section that I have marked which was supposed to plot the the set union. I was very suspicious of the code that as the offending terms were never defined. Any thoughts on what it should be? And a general question, what is the significance when some identifiers are all in capitol letters, other than the obvious of differentiating it from, a keyword of same name. Is there something more too that?
I know it's a lo of questions however, I've searched through the online docs a my small library of books on Racket. Too either the answers are in there or I've finally slipped over the edge and ready to. be moved to Shady Pines Elder Estate! ![]()
Cheers,
Munroe
The Code:
#lang racket ;set theory 2 PTFW pp 97 thru top of pp 100
(require racket/draw)
(define WIDTH 150)
(define HEIGHT 100)
(define venn (make-bitmap WIDTH HEIGHT))
(define dc (new bitmap-dc% [bitmap venn]))
(send dc scale 1.0 -1.0)
(send dc translate (/ WIDTH 2) (/ HEIGHT -2))
(send dc set-smoothing 'smoothed)
(send dc set-pen "black" 2 'solid)
(define IN-BRUSH (new brush% [color "green"]))
(define OUT-BRUSH (new brush% [ color (make-object color% 220 220 220)]))
(define (rect x y w h b)
(let ([x (- x (/ w 2))]
[y (- y (/ h 2))])
(send dc set-brush b)
(send dc draw-rectangle x y w h)))
(define (circle x y r b)
(let ([x (- x r)]
[y (- y r)])
(send dc set-brush b)
(send dc draw-ellipse x y (* 2 r) (* 2 r))))
(define (universe b) (rect 0 0 (- WIDTH 10) (- HEIGHT 10) b))
(universe OUT-BRUSH)
(circle 0 0 30 IN-BRUSH)
venn
(send dc erase)
(universe IN-BRUSH)
(circle 0 0 30 OUT-BRUSH)
venn
(define (piscis x y r b)
(let* ([y (- y r)]
[2r (* 2 r)]
[y1 (sqrt (- (sqr r) (sqr x)))] ;y-intercept
[π pi]
[ø (asin (/ y1 r))]
[𝜭 (- π ø)]
[path (new dc-path%)])
(send dc set-brush b)
(send path move-to 0 (- y1))
(send path arc (- x r) y 2r 2r 𝜭 (+ π ø))
(send path arc (- (- x) r) y 2r 2r (- ø) ø)
(send dc draw-path path)))
(define SET-BRUSH (new brush% [color (make-object color% 220 255 250)]))
(define(venn-bin b1 b2 b3)
(universe OUT-BRUSH)
;Racket obviously complains that "CIRCLE-OFF is an unbound entity. I ;considering typos such as the offending term should be lower case. But more ;troubling I have no clue what that general form is trying to accomplish?
*****(circle (- CIRCLE-OFF) 0 30 b1)
*****(circle CIRCLE-OFF 0 30 b3)
*****(piscis CIRCLE-OFF 0 30 b2)
(print venn))
(venn-bin IN-BRUSH IN-BRUSH IN-BRUSH)