Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the following problem, modify the program to read a text file (input.txt) that contains a number of lines and a circle (format and example

For the following problem, modify the program to read a text file (input.txt) that contains a number of lines and a circle (format and example below)

image text in transcribedimage text in transcribed

text file format:

N (int: number of lines up to 10)

X1a Y1a X1b Y1b (int: endpoints of line 1)

X2a Y2a X2b Y2b (int: endpoints of line 2)

XNa YNa XNb YNb (int: endpoints of line N)

Xc Yc R (int: Center point co-ordinates and Radius of circle)

example input.txt

8 14 14 10 26 20 50 50 20 1 40 30 30 50 4 50 24 45 40 60 40 10 70 40 18 70 12 70 80 30 20 60 45 28 28 15
4.4 Since normal pixels are very small, they do not show very clearly which of them are selected by Bresenham's algorithms. Use a grid to simulate a screen with a very low resolution. Demonstrate both the method drawLine (with g as its first argument) of Sect. and the method drawCircle of Sect. 3. Only the gridpoints of your grid are to be used as the centers of superpixels'. The method putPixel is to draw a small circle with such a center and the distance dGrid of two neighboring gridpoints as its diameter. Do not change the methods drawLine and drawCircle that we have developed, but use dGrid, just mentioned, in a method putPixel that is very different from the one shown at the beginning of Sect. 1. Figure 4.19 shows a grid (with dGrid 10) and both a line and a circle drawn in this way. As in Fig. 4.1, the line shown here has the endpoints P 1) and Q(12, 5) but this time the positive y-axis points Fig. 4.19 Bresenham algorithms for a line and for a circle (see also Figs. 4.1 and 4.6) downward and the origin is the upper-left corner of the drawing rectangle. The circle has radius r-8, and is approximated by the same pixels as shown in Fig. 4.6 for one eighth of this circle. The line and circle were produced by the following calls to the methods drawLine and drawCircle of Sects. and 3 (but with a different method putPixel) drawLine(g, 1, 1. 12, 5) I/ g, xP, yP, xQ, yo drawCircle ( g, 23, 10, 8); // g, xc, , r

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

CL I P COL Astro- L(1-cas0) Lsing *A=2 L sin(0/2)

Answered: 1 week ago