Loops to be used in Processing
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Loops to be used in Processing
![Exercise 4. Computers do not draw perfect circles. Because there is only a limited
number of pixels, a circle in a computer can only be an approximation of a perfect circle.
Usually, any smart program does a good job and uses a lot of tricks to make it look good
enough that you see it as a perfect circle. At the right, you see a circle approximated by 9
line segments (a 9-sided polygon). As more sides are added, the circle gets smoother. In
this exercise you will draw polygons of various sizes, controlled by the mouse, to
approximate a circle. Use a radius of 100 (diameter 200) as shown
a. First, use a for loop to draw the example given here, with exactly 9 points. The starting
point for the first is at angle 0 (straight out to the right). Every point after that will be at
an angle of, in this example, 1/9th, 2/9ths, 9/9ths of the way around the whole circle
(21 radians). Use a for loop to go through the point numbers (use integers!) then calculate the radians from that number. Use
a line to connect each point to the previous point. You will have to keep track of the previous point using variables. Remember
that for a circle with centre (xc, yo), radius r. the point at an angle of 8 radians around the circle is ( X +r cos(@), y. + r sin(@).
b. Onc a is working, use the value mousex/20 to determine the value of points instead. In the draw() block, orase the window
and draw a new polygon every time. Watch what happens as you move the mouse from left to right.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2c82f75e-c620-45ee-b3da-4cdbd6439bc9%2Fe7e68e16-6e50-47c0-91df-f58894e9b9bc%2Fh5as9kt_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Exercise 4. Computers do not draw perfect circles. Because there is only a limited
number of pixels, a circle in a computer can only be an approximation of a perfect circle.
Usually, any smart program does a good job and uses a lot of tricks to make it look good
enough that you see it as a perfect circle. At the right, you see a circle approximated by 9
line segments (a 9-sided polygon). As more sides are added, the circle gets smoother. In
this exercise you will draw polygons of various sizes, controlled by the mouse, to
approximate a circle. Use a radius of 100 (diameter 200) as shown
a. First, use a for loop to draw the example given here, with exactly 9 points. The starting
point for the first is at angle 0 (straight out to the right). Every point after that will be at
an angle of, in this example, 1/9th, 2/9ths, 9/9ths of the way around the whole circle
(21 radians). Use a for loop to go through the point numbers (use integers!) then calculate the radians from that number. Use
a line to connect each point to the previous point. You will have to keep track of the previous point using variables. Remember
that for a circle with centre (xc, yo), radius r. the point at an angle of 8 radians around the circle is ( X +r cos(@), y. + r sin(@).
b. Onc a is working, use the value mousex/20 to determine the value of points instead. In the draw() block, orase the window
and draw a new polygon every time. Watch what happens as you move the mouse from left to right.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY