1 / 52

Output Primitives

Output Primitives. Dr. S.M. Malaek Assistant: M. Younesi. Output Primitives. Output Primitives: Basic geometric structures (points, straight line segment, circles and other conic sections, quadric surfaces, spline curve and surfaces, polygon color areas, and character strings)

dusty
Télécharger la présentation

Output Primitives

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. Output Primitives Dr. S.M. Malaek Assistant: M. Younesi

  2. Output Primitives • Output Primitives: Basic geometric structures (points, straight line segment, circles and other conic sections, quadric surfaces, spline curve and surfaces, polygon color areas, and character strings) • These picture components are often defined in a continuous space.

  3. Output Primitives • In order to draw the primitive objects, one has to first scan convert the object. • Scan convert: Refers to he operation of finding out the location of pixels to the intensified and then setting the values of corresponding bits, in the graphic memory, to the desired intensity code.

  4. Output Primitives • Each pixel on the display surface has a finite size depending on the screen resolution and hence a pixelcannot represent a single mathematical point.

  5. Scan Converting A Point

  6. Scan Converting A Point • A mathematical point (x,y) needs to be scan converted to a pixel at location (x´, y´).

  7. Scan Converting A Point • x´=Round(x) and y´=Round(y) • All points that satisfy: are mapped to pixel (x´,y´)

  8. Scan Converting A Point • x´=Round(x+0.5) and y´=Round(y+o.5) • All points that satisfy: are mapped to pixel (x´,y´)

  9. Scan Converting A Line

  10. Scan Converting A Line • The Cartesian slope- intercept equation for a straight line is:

  11. Scan Converting A Line • These equation form the basic for determining deflection voltage in analog devices. |m|<1 |m|>1

  12. Scan Converting A Line • On raster system, lines are plotted with pixels, and step size (horizontal & vertical direction) are constrained by pixel separation.

  13. Scan Converting A Line • We must sample a line at discrete positions and determine the nearest pixel to the line at each sampled position. X2

  14. Digital Differential Analyzer (DDA Algorithm)

  15. DDA Algorithm • Algorithm is an incremental scan conversion method. • Based on calculating either or • If |m|<1,

  16. DDA Algorithm • If |m|>1, • If

  17. Bresenham’s Line Algorithm

  18. Bresenham’s Line Algorithm • A highly efficient incremental method for scan converting lines. • Using only incrementalinteger calculation. By testing the sign of an integer parameter, whose value is proportional to the difference between the separation of two pixel positions from the actual line path.

  19. Bresenham’s Line Algorithm • A highly efficient incremental method for scan converting lines. • Using only incrementalinteger calculation. By testing the sign of an integer parameter, whose value is proportional to the difference between the separation of two pixel positions from the actual line path.

  20. Bresenham’s Line Algorithm

  21. Bresenham’s Line Algorithm

  22. yk+1 yk+1 yk+1 } } } d2 d2 d2 y y y } } } d1 d1 d1 yk yk yk xk+1 xk+1 xk+1 Bresenham’s Line Algorithm

  23. Bresenham’s Line Algorithm d1 = y - yk = m (xk + 1) + b - yk d2 = (yk + 1) - y = yk + 1 - m (xk + 1) –b d1 - d2 = 2 m (xk + 1) - 2 yk + 2b -1

  24. Bresenham’s Line Algorithm Pk = ΔX ( d1 - d2) = 2 ΔY . xk - 2 ΔX . yk + c c = constante = 2 ΔY + ΔX (2b -1)

  25. Let's get rid of multiplications Pk+1 = 2 ΔY . xk+1 - 2 ΔX .y + c Pk+1 - Pk = 2 ΔY (xk+1 - xk) -2 ΔX (yk+1 - yk) (get rid of the constance) Pk+1 = Pk + 2 ΔY - 2 ΔX (yk+1 - yk) Pk+1 = Pk + 2ΔY      or      = Pk + 2(ΔY – ΔX( with (yk+1 - yk) = 0 or 1 depending on Pk sign

  26. Bresenham’s Line Algorithm P0 =ΔX (d1-d2) =ΔX[2m(x0+1)-2y0+2b-1] =ΔX[2(mx0+b-y0)+2m-1] P0=2ΔY -ΔX m=Δy/x 0

  27. Bresenham’s Line Algorithm • Example: Digitize the line with endpoint (20,10) and (30,18) ΔX=10 ΔY= 8 P0=2ΔY –Δx=6 2ΔY =16 2(ΔY – ΔX)=-4 P0=2ΔY –ΔX Pk+1 = Pk + 2ΔY      or      = Pk + 2(ΔY – ΔX(

  28. Circle Generation Algorithms

  29. Circle Generation Algorithms • The equation of a circle: We could solve for y in terms of x

  30. Circle Generation Algorithms • Computation can be reduced by considering the symmetry of circles 8 -Way symmetry

  31. Midpoint Circle Algorithm

  32. Circle Generation Algorithms • As in the line algorithm, we sample at unit intervals and determine the closet pixel position to the circle path at each step.

  33. Circle Generation Algorithms • Points are generated from 90º to 45º, moves will be made only in the +x and –y direction. • positive x direction over this octant and use a decision parameter

  34. Circle Generation Algorithms • We define a circle function:

  35. Circle Generation Algorithms • Midpoint • Consider the coordinates of the point halfway between pixel T and pixel S Midpoint

  36. Circle Generation Algorithms • We use it to define a decision parameter

  37. Circle Generation Algorithms • If is negative, the midpoint is inside the pixel, and we choose pixel T. • If we choose pixel S.

  38. Circle Generation Algorithms • Parameter for the next step is: • since

  39. Circle Generation Algorithms • If T is chosen ( ) we have: • If pixel S is chosen ( ) we have

  40. Circle Generation Algorithms In terms of

  41. Circle Generation Algorithms Initial value for the decision parameter using the original function of (0,r( When r is an integer we can simply set

  42. Circle Generation Algorithms • Example: A circle radius r=10 • x=0 to x=y • P0=1-r = -9

  43. Exercises?

  44. Scan Converting Arcs And Sectors?

  45. Character Generation

  46. Character Generation Letters, numbers, and other character can be displayed in a variety of size and styles.

  47. Character Generation • Typeface: The overall design style for a set of characters is call typeface:Zar, nazanin, Titr. • Font: Referred to a set of cast metal character forms in a particular size and forma:10 point Zar.

  48. Character Generation • Two different representation are used for storing computer fonts: • Bitmap font (or bitmapped font) • Outline font

  49. Bitmap font • Bitmap font (or bitmapped font): A simple method for representing the character shapes in a particular typeface is to use rectangular grid pattern.

  50. Bitmap font • The character grid only need to be mapped to a frame buffer position. • Bitmap fonts required more space, because each variation (size and format) must be stored in a font cash. Italic Bold

More Related