Docsity

Line Drawing Algorithms - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Line Drawing Algorithms - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics 5:

Line Drawing Algorithms

Contents

  • Graphics hardware
  • The problem of scan conversion
  • Considerations
  • Line equations
  • Scan converting algorithms
    • A very simple solution
    • The DDA algorithm
  • Conclusion

Architecture Of A Graphics System

System Bus

CPU

Display Processor

System Memory

Display Processor Memory

Frame Buffer

Video Controller

MonitorMonitor

Output Devices

  • There are a range of output devices currently

available:

  • Printers/plotters
  • Cathode ray tube displays
  • Plasma displays
  • LCD displays
  • 3 dimensional viewers
  • Virtual/augmented reality headsets
  • We will look briefly at some of the more common

display devices

Raster Scan Systems

  • Draw one line at a time

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Colour CRT

  • An electron gun for each colour – red, green

and blue

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

Liquid Crystal Displays

  • Light passing

through the liquid

crystal is twisted

so it gets through

the polarizer

  • A voltage is

applied using the

crisscrossing

conductors to

stop the twisting

and turn pixels off

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

The Problem Of Scan Conversion

  • A line segment in a scene is defined by the

coordinate positions of the line end-points

x

y

(2, 2)

(7, 5)

Considerations

  • Considerations to keep in mind:
    • The line has to look good
      • Avoid jaggies
    • It has to be lightening fast!
      • How many lines need to be drawn in a typical scene?
      • This is going to come back to bite us again and again

Line Equations

  • Let’s quickly review the equations involved in

drawing lines

x

y

y 0

y end

x 0 x end

Slope-intercept line

equation:

y = m ⋅ x + b

where:

0

0

x x

y y

m

end

end

0 0

b = y − m ⋅ x

A Very Simple Solution

• We could simply work out the corresponding y

coordinate for each unit x coordinate

  • Let’s consider the following example:

x

y

(2, 2)

(7, 5)

2 7

2

5

A Very Simple Solution (cont…)

1

2

3

4

5

0

0 1 2 3 4 5 6 7

A Very Simple Solution (cont…)

  • Now just round off the results and turn on

these pixels to draw our line

y ( 3 ) = 2 ≈

y ( 4 ) = 3 ≈

y ( 5 ) = 3 ≈

y ( 6 ) = 4 ≈ 0 1 2 3 4 5 6 7 8

0

1

2

3

4

5

6

7

A Very Simple Solution (cont…)

  • However, this approach is just way too slow
  • In particular look out for:
    • The equation y = mx + b requires the

multiplication of m by x

  • Rounding off the resulting y coordinates
  • We need a faster solution