Advertisement
Guest User

Untitled

a guest
Apr 17th, 2020
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 1.15 KB | None | 0 0
  1. Exercise 526. To compute the endpoints of an equilateral Sierpinski triangle, draw a circle and pick three points on the circle that are 120 degrees apart, for example, 120, 240, and 360.
  2.  
  3. Design the function circle-pt:
  4.  
  5.     (define CENTER (make-posn 200 200))
  6.     (define RADIUS 200) ; the radius in pixels
  7.      
  8.     ; Number -> Posn
  9.     ; determines the point on the circle with CENTER
  10.     ; and RADIUS whose angle is
  11.      
  12.     ; examples
  13.     ; what are the x and y coordinates of the desired
  14.     ; point, when given: 120/360, 240/360, 360/360
  15.      
  16.     (define (circle-pt factor)
  17.       (make-posn 0 0))
  18.  
  19. Domain Knowledge This design problem calls on knowledge from mathematics. One way to view the problem is as a conversion of a complex number from the polar-coordinate representation to the Posn representation. Read up on make-polar, real-part, and imag-part in ISL+. Another way is to use trigonometry, sin and cos, to determine the coordinates. If you choose this route, recall that these trigonometry functions compute the sine and cosine in terms of radians, not degrees. Also keep in mind that on-screen positions grow downward, not upward.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement