1 / 57

Bresenham’s Midpoint Algorithm

Bresenham’s Midpoint Algorithm. CS5600 Computer Graphics Rich Riesenfeld Spring 2006. Lecture Set 1. Line Characterizations. Explicit: Implicit: Constant slope: Constant derivative:. Discrete Lines. Lines vs. Line Segments What is a discrete line segment?

Download Presentation

Bresenham’s Midpoint Algorithm

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. Bresenham’s Midpoint Algorithm CS5600Computer Graphics Rich Riesenfeld Spring 2006 Lecture Set 1

  2. Line Characterizations • Explicit: • Implicit: • Constant slope: • Constant derivative: CS 5600

  3. Discrete Lines • Lines vs. Line Segments • What is a discrete line segment? • This is a relatively recent problem • How to generate a discrete line? CS 5600

  4. “Good” Discrete Line - 1 • No gaps in adjacent pixels • Pixels close to ideal line • Consistent choices; same pixels in same situations CS 5600

  5. “Good” Discrete Line - 2 • Smooth looking • Even brightness in all orientations • Same line for as for • Double pixels stacked up? CS 5600

  6. Restricted Form • Line segment in first octant with 0 < m < 1 • Let us proceed CS 5600

  7. Two Line Equations • Explicit: • Implicit: Define: Hence, CS 5600

  8. From previous We have, Hence, CS 5600

  9. Relating Explicit to Implicit Eq’s Recall, Or, where, CS 5600

  10. Verify that Look at extreme values of y Investigate Sign ofF below line on line above line CS 5600

  11. The Picture above line below line CS 5600

  12. “Reasonable assumptions” have reduced the problem to making a binary choice at each pixel: Key to Bresenham Algorithm NE (next) E (next) (Previous) CS 5600

  13. Define a logical decision variable d linear in form incrementally updated (with addition) tells us whether to go E or NE Decision Variable d(logical) CS 5600

  14. The Picture NE Q midpoint M idealline previous E CS 5600

  15. The Picture (again) NE Q midpoint M idealline E previous CS 5600

  16. Observe the relationships • Suppose Q is above M, as before. • Then , M is below the line • So, means line is above M, • Need to move NE, increasey value CS 5600

  17. The Picture (again) NE midpoint Q idealline E previous CS 5600

  18. Observe the relationships • Suppose Q is below M, as before. • Then F(M) < 0 , implies M is above the line • So, F(M) < 0 , means line is below M, • Need to move to E; don’t increasey CS 5600

  19. M= Midpoint = : • Want to evaluate at M • Will use an incr decision var d • Let, CS 5600

  20. How will d be used? Recall, Therefore, CS 5600

  21. Case 1: Suppose E is chosen • Recall • ... CS 5600

  22. ... Case 1: Suppose E is chosen CS 5600

  23. Recall, Or, where, Review of Explicit to Implicit CS 5600

  24. Case 1: . CS 5600

  25. Case 2: Suppose NE chosen Recall ... CS 5600

  26. Case 2: Suppose NE ... CS 5600

  27. Case 2: . CS 5600

  28. Case 2: . CS 5600

  29. Summary • At each step of the procedure, we must choose between moving E or NE based on the sign of the decision variable d • Then update according to CS 5600

  30. What is initial value of d ? • First point is • First midpoint is • What is initial midpoint value? CS 5600

  31. What is initial value of d ? CS 5600

  32. What is initial value of d ? Hence, CS 5600

  33. What is initial value of d ? Hence, CS 5600

  34. What Does “2 x ” Do ? • Has the same 0-set • Changes the slope of the plane • Rotates plane about the 0-set line CS 5600

  35. What is initial value of d ? CS 5600

  36. What is initial value of d ? CS 5600

  37. More Summary • Initial value • Case 1: • Case 2: CS 5600

  38. More Summary Choose CS 5600

  39. Example • Line end points: • Deltas: CS 5600

  40. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

  41. Example ( dx = 4; dy = 3 ) • Initial value of CS 5600

  42. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

  43. Example (dx=4; dy=3) • Update value of d CS 5600

  44. Example (dx=4; dy=3) -2 • Update value of d • Last move was NE, so 2d(6,9) = 2d(y - dy) = 2(4 - 3) = - 2 d = 2 – 2 = 0  E CS 5600

  45. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

  46. Example (dx=4; dy=3 ) • Previous move was E CS 5600

  47. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

  48. Example (dx=4; dy=3 ) • Previous move was CS 5600

  49. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

  50. Graph 13 12 11 10 9 8 7 6 4 5 6 7 8 9 10 11 CS 5600

More Related