1 / 12

Computer Graphics

Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting a line from screen co-ordinate (1,0) to (10,3 ).

adler
Download Presentation

Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting a line from screen co-ordinate (1,0) to (10,3). • Reflect the diamond shape polygon whose vertices are A(-2,0), B(0,-1), C(2,0), D(0,1) about an arbitrary line L which is represented by equations y=0.5x+1. • Discuss Breshnham’s Circle algorithm with suitable example. • Explain DDA algorithm for generation of line. • What is a geometric transformation? Define and explain the following With respect to 2-D transformations (any three) : (i) Translation (ii) rotation (iii) scaling (iv) reflection

  2. A rectangle is formed by the four point ABCD, whose co-ordinates are: A = (25,25), B = (25,125), C = (75, 125) and D = (75, 25) Calculate the new co-ordinates: (i) If it is changed by scaling factors Sx=0.4 and Sy=0.6 (ii) When after scaling Centre is remained at same position and scaling factor is 1.5 • Using transformation matrix determine the new coordinates of triangle A(0,0), B(3,2) and C(2,3) after it is rotated 45 degree clockwise about origin • A triangle ABC with vertices A(0,0), B(4,0) and C(2,3). Perform the following operations for it. (i) Translation through 4 and 2 units along X and Y directions respectively. (ii) Rotation through 900 In counterclockwise direction about the new position of point C. • A rectangle formed by four points PQRS whose coordinates are P(50,50), Q(100,50), R(100,80), S(50,80).Find the new coordinates of the rectangle in reduced size using scaling factors SX = 0.5 and SY = 0.6 • Explain 3-D geometric transformations (any three) in detail.

  3. Computer Graphics Introduction Computer graphics deals with the generation of a two-dimensional of a three dimensional model of an object using a graphics software. The process begins with the data input and ends with the generation of a model. We can generate a model either with the help of a programming or by using the software.

  4. Application of computer graphics: • The computer graphics is commonly used in areas such as: science, engineering medicine, business, entertainment, advertising, education, art, industry etc. • The computer graphics has contributed significantly for developments in the fields involving simulation and animation.

  5. Line generating algorithms: • Bresenham’s line algorithm • An accurate and efficient raster line-generating algorithm developed by Bresenham. • Vertical axis- scan line position • Horizontal axis- pixel column • At x intervals in these examples, we need to decide which of two possible pixel positions is closer to the line path at each sample step. Starting from the left endpoint shown in fig. we need to determine at the next sample position whether to plot the pixel at position (11,11) or the one at (11,12).

  6. To illustrate Bresenham’s approach, we first consider the scan-conversion process for lines with positive slope less than 1. • Pixel positions along a line path are then determined by sampling at unit x intervals. • Starting from the left endpoint (x0,y0) of a given line, we step to each successive column and plot the pixel whose y value is closest to the line path. • Fig demonstrates the kth step in this process. Assuming we have determined that the pixel at (xk,yk) is to be displayed, we next need to decide which pixel to plot in column xk+1. • Our choices are the pixels at positions (xk+1,yk) and (xk+1,yk+1).

  7. At sampling position xk+1, we label vertical pixel separations from the mathematical line path as d1 and d2. • The y coordinate on the mathematical line at pixel column position xk+1 is calculated as y = m(xk+1) + b Then d1 = y - yk = m(xk+1) + b – yk

  8. and d2 = (yk+1) – y = yk+1 - m(xk+1) + b The difference between these two separations is d1 - d2 = m(xk+1) + b – yk- yk+1 - m(xk+1) + b A decision parameter pk for the kth step in the line algorithm can be obtained as per the following. We accomplish this by substituting m = ∆y/∆x, where ∆y and ∆x are the vertical and horizontal separations of the endpoint positions, and defining: pk= ∆x(d1 - d2) = 2 ∆y.xk- 2 ∆x. yk + c The sign of pkis same as the sign of d1 - d2, since ∆x>0 for our example. Parameter c is constant and has the value 2∆y+∆x(2b-1), which is independent of pixel. If the pixel at yk is closer to the line path then pixel at yk+1 (that is d1is less than d2) then decision parameter pk is negative. In that case, we plot the lower pixel, otherwise we plot the upper pixel.

  9. Coordinate change along the line occur in unit steps in either the x or y directions. Therefore we can obtain the values of successive decision parameters using incremental integer calculations. At step k+1, the decision parameter is evaluated following equation pk+1 = 2 ∆y. xk+1- 2 ∆x. yk+1+ c Subtracting this equation from preceding equation, we have pk+1 - pk= 2 ∆y.( xk+1 – xk)- 2 ∆x.(yk+1 – yk) But xk+1 = xk+1 pk+1= pk+2 ∆y- 2 ∆x.(yk+1 – yk) Where the term yk+1 – yk is either 0 or 1, depending on the sign of parameter pk.

  10. Midpoint Circle Algorithm • Input radius r and circle center (xc , yc) and obtain the first point on the circumference of a circle centered on the origin as (x0, y0) = (0,r) • Calculate the initial value of the decision parameter as p0 = 5/4 – r • At each xkposition, starting at k = 0 perform the following test. If pk˂0, the next point along the circle centered on (0,0) is (xk+1, yk) and pk+1 = pk + 2xk+1 + 1 Otherwise, the next point along the circle is (xk+1, yk-1) and pk+1 = pk + 2xk+1 + 1- 2yk+1 where 2xk+1 = 2xk + 2 and 2yk+1= 2yk - 2 • Determine symmetry points in the other seven octants • Move each calculated pixel position (x,y) onto the circular path centered on (xc , yc)and plot the coordinate values. x = x+xc , y = y+yc • Repeat steps 3 through 5 until x≥ y.

More Related