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

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

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

Recommended textbooks for you

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…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

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)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY