Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.
- Design the function circle-pt:
- (define CENTER (make-posn 200 200))
- (define RADIUS 200) ; the radius in pixels
- ; Number -> Posn
- ; determines the point on the circle with CENTER
- ; and RADIUS whose angle is
- ; examples
- ; what are the x and y coordinates of the desired
- ; point, when given: 120/360, 240/360, 360/360
- (define (circle-pt factor)
- (make-posn 0 0))
- 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