QUADRANT I PLANS
Purpose: Draw a right triangle with sides parallel to X and Y axis
Input - IV: Coordinates of the end points of the hyptenuse ( X1, Y1) ( X2, Y2)
Output - DV: Canvas with right triangle drawn
;;righttriangle: number number number number -> true
;;draw a right triangle given coordinates of end points of hyptenuse
(define (righttriangle X1 Y1 X2 Y2) ...)
;;QUADRANT II PLANS - EXAMPLES first drawn on graph paper
;; Example 1 with negative slope
(line (make-posn 0 25) (make-posn 0 0) 'red) ;;parallel to Y-axis
(line (make-posn 10 0) (make-posn 0 0) 'red) ;;parallel to X-axis
(line (make-posn 0 25) (make-posn 10 0) 'red) ;;hypotenue
;;Example 2 with positive slope
(line (make-posn -5 10) (make-posn -5 0) 'blue)
(line (make-posn -15 0) (make-posn -5 0) 'blue)
(line (make-posn -5 10) (make-posn -15 0)'blue)
;;Example 3 from Quadrant III to Quadrant IV
(line (make-posn -15 -20) (make-posn -15 -5) 'green)
(line (make-posn 20 -5) (make-posn -15 -5) 'green)
(line (make-posn -15 -20) (make-posn 20 -5) 'green)
;;righttriangle: n n n n -> true
;;draw a right triangle given coordinates of end points
(define (righttriangle X1 Y1 X2 Y2)
(and
(line (make-posn X1 Y1) (make-posn X1 Y2) 'black)
(line (make-posn X2 Y2) (make-posn X1 Y2) 'black)
(line (make-posn X1 Y1) (make-posn X2 Y2) 'black)))
(righttriangle -25 20 -5 15)
(righttriangle 25 20 5 15)
Planning is essential to learn the process. Please do NOT just guess and check.
PLAN ON GRAPH PAPER FIRST!!
|