Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2a9dba2f9e
Fetching contributors…

Cannot retrieve contributors at this time

39 lines (30 sloc) 0.975 kb
;; Example 2.50
;; Vectors
(define (make-vect x y)
(cons x y))
(define (xcor-vect vect)
(car vect))
(define (ycor-vect vect)
(cdr vect))
(define (add-vect a b)
(make-vect (+ (xcor-vect a) (xcor-vect b))
(+ (ycor-vect a) (ycor-vect b))))
(define (sub-vect a b)
(make-vect (- (xcor-vect a) (xcor-vect b))
(- (ycor-vect a) (ycor-vect b))))
(define (scale-vect s a)
(make-vect (* (xcor-vect a) s)
(* (ycor-vect a) s)))
(define (transform-painter painter origin corner1 corner2)
(lambda (frame)
(let ((m (frame-coord-map frame)))
(let ((new-origin (m origin)))
(make-frame new-origin
(sub-vect (m corner1) new-origin)
(sub-vect (m corner2) new-origin)))))))
(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)))
Jump to Line
Something went wrong with that request. Please try again.