1 / 36

Scan-Converting a LINE

Chapter 4 元素. Scan-Converting a LINE. 畫出顯示一條線. Simple DDA. Digital Differential Analyzer. ( x 2 ,y 2 ). ( x 1 ,y 1 ). 第一象限 first octant. x end > x start y end > y start Length=(x end - x start )>(y end - y start ) Slope=(y end - y start ) /Length. Simple DDA.

ismail
Download Presentation

Scan-Converting a LINE

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. Chapter 4 元素 Scan-Converting a LINE 畫出顯示一條線 Simple DDA Digital Differential Analyzer (x2,y2) (x1,y1)

  2. 第一象限 first octant xend> xstart yend>ystart Length=(xend-xstart)>(yend-ystart) Slope=(yend-ystart) /Length

  3. Simple DDA Digital Differential Analyzer (x2,y2) (x2,y2) (x1,y1) (x1,y1)

  4. Left to Right (Left to Right) (Left to Right)

  5. Right to Left ( Right to Left) x1 x2 ( Right to Left) y1 y2

  6. Simple DDA (x2,y2) (x1,y1) +m

  7. Simple DDA (x2,y2) (x1,y1) -m

  8. Simple DDA Example : From (2,2) to (7,8) (x1,y1) (x2,y2) (7,8) , (2,2)

  9. Simple DDA Example From (6,-2) to (-4,2) (x1,y1) (x2,y2)

  10. Bresenham’s Line Algorithm 1. Left end point (x1,y1) Right end point (x2,y2) 2. First point (x1,y1)

  11. Bresenham’s Line Algorithm(Cont.) 3. if if 4. Until X2 is reached

  12. Bresenham’s Line Example (8,5) From (1,1) to (8,5) (1,1) 解:

  13. Bresenham’s Line Algorithm 1. Left end point (x1,y1) Right end point (x2,y2) 2. First point (x1,y1)

  14. Bresenham’s Line Algorithm(Cont.) 3. if if 4. Until X2 is reached

  15. Bresenham’s Line Example (7,8) From (2,2) to (7,8) (2,2) 解:

  16. Ⅰ Ⅲ Ⅳ Quadrantal DDA 4 個象限的DDA Use line error (tracking sum) No float point calculation 4 Quadrant 象限 開始 e=0

  17. 4 Quadrant 象限 Ⅱ Ⅰ Ⅲ Ⅳ Ⅰ Quadrant 1 Rules 1.if error <0, move +x ,add to error 2.if error 0, move +y ,add to error Ⅱ Quadrant 2 Rules 1.if error <0, move –x ,add to error 2.if error 0, move +y ,add to error Ⅲ Quadrant 3 Rules 1.if error <0, move –x ,add to error 2.if error 0, move –y ,add to error Ⅳ Quadrant 4 Rules 1.if error <0, move +x ,add to error 2.if error 0, move –y ,add to error

  18. Quadrantal DDA Example x2>x1 From (2,2) to (7,8) I{ y2>y1 開始 e=0

  19. Quadrantal DDA Example(Cont.) From (2,2) to (7,8)

  20. Octantal DDA 2 3 4 1 8 octants 象限 5 8 6 7 Octant 1 Rules: 1.if error <0, move +x ,add to error 2.if error 0, move +x+y ,add to error

  21. 2 3 8 octants 象限 4 1 8 5 Octant 2 Rules: 6 7 1.if error <0, move +x+y ,add to error 2.if error 0, move +y ,add to error Octant 3,4,5,6 Rules: Swap start point and End point , Draw as 1,2,7,8 Octant 7 Rules: 1.if error <0, move +x-y ,add to error 2.if error 0, move –y ,add to error Octant 8 Rules : 1.if error <0, move +x ,add to error 2.if error > 0, move +x–y ,add to error

  22. Octantal DDA Example From (2,2) to (7,8) 2 Octant 2 Ⅱ

  23. Octantal DDA Example(Cont.) From (2,2) to (7,8)

  24. Scan-Converting a Circle y Pythagoream Theorem x Stepping along x axis Unit steps from x = (xc-r) to x = (xc+r) Calculate y Not Uniform

  25. Parametric Polar r fixed step angular value step size 1/r

  26. Bresenham’s Circle Algorithm 1. first point (x1 , y1)=(0 , r) 2.P1= 3-2r if P1<0, If P1 0, 3. Plot 8 points (x,y), (-x,y) , (x,-y) , (-x,-y) , (y,x) , (-y,x) , (y,-x) , (-y,-x) 4. Until x y

  27. Bresenham’s Circle 1/8圓

  28. r =10 , (0 , 0) 圓心 , P1 =3-2r ,

  29. Incremental Drawing 圓上的連續兩點產生 Two consecutive points (x1,y1) , (x2,y2) is a fixed angular step size { (x3,y3) (x2,y2) 先畫1/8 circle , 再畫全圖 (x1,y1)

  30. Mid point Circle Algorithm Input r , (xc,yc) 1. First point (x0,y0)=(0 , r) 2. 3. k =0,… If ,Next point (xk+1,yk) Otherwise , Next point (xk+1,yk-1) 4.決定其他對稱象限 5. 圓心 6. 直到

  31. 例: r =10 第一象限 from x = 0 to x = y P0=1-r = -9 (x0,y0)=(0,10) 2x0 =0 , 2y0=20

More Related