bresenham s midpoint algorithm n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Bresenham’s Midpoint Algorithm PowerPoint Presentation
Download Presentation
Bresenham’s Midpoint Algorithm

Loading in 2 Seconds...

play fullscreen
1 / 70

Bresenham’s Midpoint Algorithm - PowerPoint PPT Presentation


  • 352 Views
  • Uploaded on

Bresenham’s Midpoint Algorithm. CS5600 Computer Graphics Rich Riesenfeld Spring 2006. Lecture Set 1. Line Characterizations. Explicit: Implicit: Constant slope: Constant derivative: . Line Characterizations - 2. Parametric: where , Intersection of 2 planes

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Bresenham’s Midpoint Algorithm' - margie


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
bresenham s midpoint algorithm

Bresenham’s Midpoint Algorithm

CS5600Computer Graphics

Rich Riesenfeld

Spring 2006

Lecture Set 1

line characterizations
Line Characterizations
  • Explicit:
  • Implicit:
  • Constant slope:
  • Constant derivative:

CS 5600

line characterizations 2
Line Characterizations - 2
  • Parametric:

where,

  • Intersection of 2 planes
  • Shortest path between 2 points
  • Convex hull of 2 discrete points

CS 5600

discrete lines
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

good discrete line 1
“Good” Discrete Line - 1
  • No gaps in adjacent pixels
  • Pixels close to ideal line
  • Consistent choices; same pixels in same situations

CS 5600

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

CS 5600

incremental fn eval
Incremental Fn Eval
  • Recall
  • Characteristics
    • Fast
    • Cumulative Error
  • Need to define

CS 5600

case 0 trivial situations
Case 0: Trivial Situations
  • Do not need Bresenham

CS 5600

case 1 translate to origin1
Case 1: Translate to Origin
  • Need only consider lines emanating from the origin.

CS 5600

restricted form
Restricted Form
  • Line segment in first octant with

0 < m < 1

  • Let us proceed

CS 5600

two line equations
Two Line Equations
  • Explicit:
  • Implicit:

Define:

Hence,

CS 5600

from previous
From previous

We have,

Hence,

CS 5600

relating explicit to implicit eq s
Relating Explicit to Implicit Eq’s

Recall,

Or,

where,

CS 5600

investigate sign of f
Verify that

Look at extreme values of y

Investigate Sign ofF

below line

on line

above line

CS 5600

the picture
The Picture

above line

below line

CS 5600

key to bresenham algorithm
“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

decision variable d logical
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

the picture1
The Picture

NE

Q

midpoint

M

idealline

previous

E

CS 5600

the picture again
The Picture (again)

NE

Q

midpoint

M

idealline

E

previous

CS 5600

observe the relationships
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

the picture again1
The Picture (again)

NE

midpoint

Q

idealline

E

previous

CS 5600

observe the relationships1
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

m midpoint
M= Midpoint = :
  • Want to evaluate at M
  • Will use an incr decision var d
  • Let,

CS 5600

how will d be used
How will d be used?

Recall,

Therefore,

CS 5600

slide35
...

Case 1: Suppose E is chosen

CS 5600

case 1
Case 1: .

CS 5600

case 2
Case 2: .

CS 5600

slide41

Case 2: .

CS 5600

summary
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

what is initial value of d
What is initial value of d ?
  • First point is
  • First midpoint is
  • What is initial midpoint value?

CS 5600

what does 2 x do
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

more summary
More Summary
  • Initial value
  • Case 1:
  • Case 2:

CS 5600

more summary1
More Summary

Choose

CS 5600

example
Example
  • Line end points:
  • Deltas:

CS 5600

graph
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

example dx 4 dy 3
Example ( dx = 4; dy = 3 )
  • Initial value of

CS 5600

graph1
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

example dx 4 dy 31
Example (dx=4; dy=3)
  • Update value of d

CS 5600

example dx 4 dy 3 2
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

graph2
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

example dx 4 dy 32
Example (dx=4; dy=3 )
  • Previous move was E

CS 5600

graph3
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

example dx 4 dy 33
Example (dx=4; dy=3 )
  • Previous move was

CS 5600

graph4
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

graph5
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

graph6
Graph

13

12 11 10 9 8 7 6

4 5 6 7 8 9 10 11

CS 5600

more raster line issues
More Raster Line Issues
  • Fat lines with multiple pixel width
  • Symmetric lines
  • How should end pt geometry look?
  • Generating curves, e.g., circles, etc.
  • Jaggies, staircase effect, aliasing...

CS 5600