1 / 9

Computer graphics

Computer graphics. Scan conversion of Line , circle & ellipse. Scan conversion. is the process of converting basic, low level objects in to their corresponding pixel map representations. This is often an approximation to the object, since the frame buffer is a discrete grid.

aldis
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. Computer graphics Scan conversion of Line , circle & ellipse

  2. Scan conversion is the process of converting basic, low level objects in to their corresponding pixel map representations. This is often an approximation to the object, since the frame buffer is a discrete grid.

  3. Line Drawing algorithms • Direct or floating or simple algorithm • Digital Differential Analyzer algorithm (DDA) • Bresenham's algorithm or midpoint algorithm • General Bresenham's algorithm Description: • Given the specification for a straight line (parameters). • find the collection of addressable pixels which most closely approximates this line (mathematical equations) . • Draw the scan conversion of lines (frame buffer map). Goals • Straight lines should appear straight. • Lines should start and end accurately. • Lines should be drawn as rapidly as possible. • matching endpoints with connecting lines. • Lines should have constant brightness.

  4. Octant Slope(m) ratio Y2 I positive dy > dx y1 II positive dy < dx III negative dy < dx IV negative dy > dx x1 x2 V positive dy > dx VI positive dy < dx VII negative dy < dx VIII negative dy > dx Direct method Description: 1. A straight line may be defined by two endpoints and an equation If the two endpoints used to specify a line are (X1,Y1) and (X2,Y2) ,then the equation of the line is used to describe the X , Y coordinates of all the pointes that lie between these two endpoints. 2. The line equation depend on octant which contain line Octant covering in 2D space Dx = x2 - x1 Dy = y2 - y1

  5. 3. The equation of straight line in octants Dx > Dy 0 1 2 3 4 0 1 2 3 4 5 Y= M * X + B Where:M is the slope of the line. B is the Y intercept. B= Y – M * X Note :The slope between any point (X1,Y1) on the line and (X2,Y2) M = DY/ DX x go from x1 to x2 with values (+1) or (-1) EX1:- draw line between(0,1) and ( 5,4) Sol:- M= 4 -1 / 5-0 = 3/5 = 0.6 , B=1 , y= (0.6)*X+1 x go from x1 to x2 with integer values (+1) in each step

  6. 4. The equation of straight line in octants Dy > Dx X= Y – B / M y go from y1 to y2with values (+1) or (-1) Ex: draw line between(1,2) and ( 3,6) sol:- m= 2 , B= 0

  7. 2 3 4 5 6 -2 -3 -4 -5 -6 Ex: draw line between(2,-2) and ( 6,-6) Sol:- m= -4 / 4 = -1 , B= -2 – (-1*2) = 0

  8. features: • The algorithm performs a floating-point multiplication for every step in x. This method therefore requires an enormous number of floating-point multiplications, and is therefore expensive. • int() functions are needed • Can get gaps in the line. example: y = 10.x + 2 x=1, y=12; x=2, y=22.

  9. Algorithm for first octant with x1<x2 Dim img As New Bitmap(1, 1) img.SetPixel(0, 0, Color.Blue) dx = x2 - x1 dy = y2 - y1 m = dy / dx b = y1 - m * x1 For x = x1 To x2 e.Graphics.DrawImage(img, x, Int(y)) y = m * x + b Next

More Related