;;; helper functions: ;; mid-point : posn posn -> posn ;; to compute the mid-point between a-posn and b-posn (define (mid-point a-posn b-posn) (make-posn (mid (posn-x a-posn) (posn-x b-posn)) (mid (posn-y a-posn) (posn-y b-posn)))) ;; mid : number number -> number ;; to compute the average of x and y (define (mid x y) (/ (+ x y) 2)) ;; distance: posn posn -> number ;; to compute the distance between two positions (define (distance posn1 posn2) (sqrt (+ (* (- (posn-x posn1) (posn-x posn2)) (- (posn-x posn1) (posn-x posn2))) (* (- (posn-y posn1) (posn-y posn2)) (- (posn-y posn1) (posn-y posn2))))) ) ;;; more helper functions? ;; sierpinski : posn posn posn -> true ;; to draw a Sierpinski triangle at a, b, and c (define A (make-posn 200 0)) (define B (make-posn 27 300)) (define C (make-posn 373 300)) (start 400 400) ;(sierpinski A B C)