05-LineRast

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

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

Rasterizing lines

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

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

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

View Full Document
Rasterizing Lines Requirements * No gaps * Minimize error (distance to line)
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.

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

View Full Document
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
Rasterizing Lines Problems with previous algorithm 1. round takes time 2. uses floating point arithmetic

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

View Full Document
Midpoint Algorithm NE E P=(x,y) M Q If Q <= M, choose E. If Q > M, choose NE
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!]

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

View Full Document
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
Ask a homework question - tutors are online