05-LineRast

05-LineRast - Rasterizing lines Rasterization Array of...

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

View Full Document Right Arrow Icon
Rasterizing lines
Background image of page 1

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

View Full DocumentRight Arrow Icon
Rasterization Array of pixels 0 01 234 1 2 3
Background image of page 2
Rasterizing Lines Given two endpoints, find the pixels that make up the line. ) , ( ), , ( 1 1 0 0 y x y x
Background image of page 3

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

View Full DocumentRight Arrow Icon
Rasterizing Lines Requirements * No gaps * Minimize error (distance to line)
Background image of page 4
Rasterizing Lines ) ( x f b mx y = + = Taylor Expansion: x x f y x x y + = + ) ( ' ) ( Equation of a Line: So if we have an x,y on the line, we can find the next point incrementally.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Rasterizing Lines Line(int x0, int y0, int x1, int y1) float dx = x1 – x0; float dy = y1 – y0; float m = dy/dx; float x = x0, y= y0; for(x = x0; x <= x1; x++) setPixel(x,round(y)); y = y+m; Assume –1 < m < 1, x0 < x1
Background image of page 6
Rasterizing Lines Problems with previous algorithm 1. round takes time 2. uses floating point arithmetic
Background image of page 7

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

View Full DocumentRight Arrow Icon
Midpoint Algorithm NE E P=(x,y) M Q If Q <= M, choose E. If Q > M, choose NE
Background image of page 8
Implicit Form of a Line dx B c b dy a B y x B x y c by ax = = = = + + = = + + 0 0 Implicit form Explicit form An arbitrary point (x,y), when plugged into ax+by+c yields: • a positive value if (x,y) is below the line • a negative value if (x,y) is above the line zero if (x,y) lies right on the line [duh!]
Background image of page 9

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

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

This note was uploaded on 09/27/2010 for the course CSCI 480 taught by Professor Sathyanaraya during the Spring '08 term at USC.

Page1 / 19

05-LineRast - Rasterizing lines Rasterization Array of...

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

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