0% found this document useful (0 votes)
28 views6 pages

pdf24 Images Merged

Jj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
28 views6 pages

pdf24 Images Merged

Jj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
COMPUTER GRAPHICS Advantages of Digital Differential Analyzer Itisa simple algorithm to implement. Itisa faster algorithm than the direct line equation. ‘We cannot use the multiplication method in Digital Differential Analyzer. Digital Differential Analyzer algorithm tells us about the overflow of the point when the point changes its location, Disadvantages of Digital Differential Analyzer ‘+ The floating-point arithmetic implementation of the Digital Differential Analyzer is time-consuming. ‘© The method of round-off is also time-consuming. ‘+ Sometimes the point position is not accurate Bresenham’s Line Drawing Algorithm This algorithm was introduced by “Jack Elton Bresenham” in 1962, This algorithm helps us to perform scan conversion of a line. It is a powerful, useful, and accurate method. We use incremental integer calculations to draw a line. The integer calculations include addition, subtraction, and multiplication, ‘In Bresenham’s Line Drawing algorithm, we have to calculate the slope (ma) between the starting point and the ending As shown inthe above figure let, we have inital coordinates of line = (Xy, Ys The next coondinates of a line = (as, Yast) The intersection point between ys and yur y. Let we assume that the distance between y and yy= dy, The distance between y and yxu1=ds Now. we have to decide which point i nearest to the intersection point. Mme I then x= xt { Unit Imerval) y=ytl { Unit Imerval} As we know the equation ofa line- y=mx+b [Now we put the value of x into the line equation, then an(ay+l) +b pa B ‘The value of d= y—y ‘Now we put the value of ds in equation 1). Dr. D. UDAYA/ Assistant Professor AAGASC / Department of Camputer Science / KKL % ‘COMPUTER GRAPHICS ‘Then, a set {We will choose the nearest x. pivel} ‘The next coordinate will be (a+, yet) pc ‘Then, ar Me {We will choose the nearest x, pixel} ‘The next coordinate will be (x ye+1) Algorithin of Bresenham’s Line Drawing Algorithm ‘ow. we consider Starting point as (xt, ys) and ending point (x2, v2) jow, we have to calculate Ax and Ay. ‘Step 4: Now, we will calculate the decision parameter px with following formula. Pr 2ay, ‘Step 5: The initial coordinates ofthe line are (xa, yu), and the next coordinates are (xin, Yue). Now, we are going to ‘calculate two cases for decision parameter pa Case 1: If Porspet2ay pod PoaspetDay-2ax Neamt yea=yetl Step 6: We will repeat step 5 until we found the ending poimt ofthe line and the total number of iterations = Ax-1. ‘Step 7: Stop. ‘Example: A line has a starting point (9,18) and ending point (14,22). Apply the Bresenhuam’s Line Drawing algorithm to plota line. Solution: We hi Starting Point two coordinates, (x,y) = (418) ay =ye— Step 2: Now, we are going to calculate the decision parameter (Px) p= 2Ay- ax x4-5 ‘The value of px= 3 (ow, we will check both the cases. Step Dr. D. UDAYA / Assistant Professor ‘AAGASC / Department af Computer Science / KKL COMPUTER GRAPHICS {OO —_———, o1?rseas 6 Fig, 2.2: - Pixel positions referenced by scan-line number and colurnn number. ‘© To load the specified color into the frame buffer at a particular position, we will assume we have available low-level procedure of the form setpixel(x, y) ‘+ Similarly for rettieve the current frame buffer intensity we assume to have procedure getpix(, ¥). Line Drawing Algorithms ‘The Line drawing algorithm is a graphical algorithm which is used to represent the line segment on diserete ‘graphical media, ic. printer and pixel-based media, ‘A line contains two points. The point is an important clement of a line. Properties of a Line Drawing Algorithm ‘There are the following properties of a good Line Drawing Algorithm, ‘+ Analgorithm should be precise: Each step of the algorithm must be adequately defined, Finiteness: An algorithm must contain finiteness, It means the algorithm stops after the execution of all steps Easy to understand; An algorithm must help learners to understand the solution in & more natural way. Correctness: An algorithm must be in the correct manner. Effectiveness: The steps of an algorithm must be valid and efficient. ‘Uniqueness: All steps of nn algorithm should be clearly and uniquely defined, and the result should be ‘based on the given input. Input: A good algorithm must accept atleast one or more input. © Output: An algorithm must generate at least one output ‘Equation of the straight line ‘We can define a straight line with the help of the following equation. ms +a Where, (x,y) = axis of the line 1m Slope ofthe line werception point Dr. 0. UDAYA// Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS. Step 3: We get m = 1, Third case is satisfied. Now move to next step. * y Bet Yea | OQae ye) 1 7 2 8 2.8) 3 9 G9 4 10 (4,10) 5 in sy 6 2 (6.12) 7 13 7.13) 8 4 14) 9 1s 9.15) 10 16 (10, 16) ut 7 ) Step 4: We will repeat step 3 until we get the endpoints of the line. Step 5: Stop. Ca) 24 6 8 1 1a te We ‘AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS ‘+ Itis fast to apply but not faster than the Digital Differential Analyzer (DDA) algorithm. ‘+ The pointing accuracy is higher than the DDA algorithm. Disadvantages of Bresenham’s Line Drawing Algorit ‘+ The Bresenham’s Line drawing algorithm only helps to draw the basie line, ‘© The resulted draw line is not smooth, Circle generating algorithm Drawing a circle om the screen is a little complex than drawing a line. There are two popular algorithms for ‘generating a circle ~ Bresenham’s Algorithm and Midpoint Circle Algorithm. These algorithms are ‘based on the idea of determining the subsequent points required to draw the circle. Let us discuss the algorithms in detail — ‘The equation of circle is X2+Y2=12,X2+¥2=12, where ris radius ay (va) (ap) (ab) (ab) bea) Bresenham's Algorithm ‘We cannot display a continuous arc on the raster display. Instead, we have to choose the nearest pixel position to complete the arc. From the following illustration, you can see that we have put the pixel at X.YX.Y location and now need to decide where to put the next pixel ~ at NX+1,YX+1,¥ or at SX+1,¥~IX+1,.Y=1 +H) vet sertaet) om ‘This can be decided by the decision parameter d. + If d.<= 0, then NX+1,YX+1,Y is to be chosen as next pixel. + Ifd>0, then SX+1,Y-IX+1,Y~1 is to be chosen as the next pixel, Dr, D, UDAYA / Assistant Professor ‘AAGASC / Department of Computer Science / KKL ‘COMPUTER GRAPHICS undied tine Attrinuton Lerren n the bunete tabhe Yor ine ttroutes on a pected workstation are Set with “set PotvlineRepresentation (wwe. HM. tw. Ke) erameter wt the morsstation Wentier and tine index perareter # defines the bbunde tao postion Parameter Rh, tr are then Gundled ang ausigned welues to set the ne tyEe, ne wth, and ine {Oo specications for designated ab'e index sctPotyinaneprasentation (1, 3, 2.0.8, 1) setPotytinenepresentation (4,3, 1,1, 7) A poly ine that is ausigned # table Index value of 3 would be daplayed using dashed tines at ha thickness in a ive color on work station 1: whe on woresation 4, ‘nis same index generates soba, stancero-sred white nes Bundle ares fl Attributes “Table entries for bunced avea-ti arerbtes are set with “setinteriorRepresentation (ws 8. pt fe) rics defes the atinbutes st cerresponding to fH index fon workstation wes Irarameter te Band Ware anangned vahaes forthe fi tye pattern inden and fi co. ‘Bundled Text Attributes ‘setTextRepresentation (ws, ti tf tp, te, ts, te) ‘Bundles values for text font, precision expansion factor size an coker io a table postion for work station ws that is specified by value assigned to text index parameter ti ‘Bundled marker Attributes setPolymarkerRepresentation (ws, mi, mt, ms, mc) ‘That defines marker type marker scale factor marker color for index mi on workstation ws. Inquiry Function Current settings for attributes and other parameters as workstanons types and status in the system lists can be retrieved with inquiry functions. inquirePoiylineindex ( tast) aod InquireinteriorcColourindex (laste) (Copy the current valves for line index and fil color nto parameter lasts and atte. Dr. D. UDAYA,/ Assistant Professor /AAGASC/Department of Computer Science / KKL

You might also like