COMPUTER SCIENCE LESSONS

GRAPHIC PROGRAMS
LESSONS
  • Plan a creative design with right triangles that have sides parallel to X and Y axis.
  • Looks for patterns and create a design with triangles that are parallel and perpendicular to each other.
  • Use a combination of positive and negative slopes.
  • Make a chart and list slope, y-intercept and equation for the hypotenuse of each right triangle.
  • Use a combination of positive and negative slopes.
  • Copy the code below to test your program in DrScheme.
    Take out the examples once you understand the function
  • Add a color parameter to the triangle function to make it more user-friendly.
  • 
    
    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!!

    TO REVIEW AND LEARN COPY SAMPLE CODE INTO SCHEME,
    RUN, OBSERVE, COMPARE AND CONTRAST THE CODE!

    Home