midpoint line - ScanConversionorRasterization

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
168 471 Computer Graphics, KKU. Lecture 6 1 Scan Conversion or Rasterization Drawing lines, circles, and etc. on a grid implicitly  involves approximation.  The general process: Scan Conversion or  Rasterization Ideally, the following properties should be considered smooth continuous pass through specified points uniform brightness efficient
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
168 471 Computer Graphics, KKU. Lecture 6 2 Line Drawing and Scan Conversion There are three possible choices which are potentially  useful. Explicit: y = f(x) y = m (x - x0) + y0 where m = dy/dx Parametric: x = f(t), y = f(t) x = x0 + t(x1 - x0),                 t in [0,1] y = y0 + t(y1 - y0) Implicit: f(x, y) = 0 F(x,y) = (x-x0)dy - (y-y0)dx if F(x,y) = 0 then (x,y) is on line    F(x,y) > 0 then (x,y) is below line    F(x,y) < 0 then (x,y) is above line
Background image of page 2
168 471 Computer Graphics, KKU. Lecture 6 3 Line Drawing - Algorithm 1 A Straightforward Implementation DrawLine(int x1,int y1, int x2,int y2, int color) {     float y;     int x;     for (x=x1; x<=x2; x++)      {          y = y1 + (x-x1)*(y2-y1)/(x2-x1)          WritePixel(x, Round(y), color );     } }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
168 471 Computer Graphics, KKU. Lecture 6 4 Line Drawing - Algorithm 2 A Better Implementation DrawLine(int x1,int y1,int x2,int y2, int color) {     float m,y;     int dx,dy,x;     dx = x2 - x1;     dy = y2 - y1;     m = dy/dx;     y = y1 + 0.5;     for (x=x1; x<=x2; x++)      {          WritePixel(x, Floor(y), color );          y = y + m;     } }
Background image of page 4
168 471 Computer Graphics, KKU. Lecture 6 5 Line Drawing Algorithm Comparison Advantages over Algorithm 1 eliminates multiplication improves speed
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

midpoint line - ScanConversionorRasterization

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online