# Indian institute of information technology allahabad

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nstitute of Information Technology - Allahabad Testing for the side of a line. • Need a test to determine which side of a line a pixel lies. • Write the line in implicit form: F ( x, y ) = ax + by + c = 0 • Easy to prove F&lt;0 for points above the line, F&gt;0 for points below. Indian Institute of Information Technology - Allahabad Testing for the side of a line. F ( x, y ) = ax + by + c = 0 • Need to find coefficients a,b,c. • Recall explicit, slope-intercept form : • So: dy y = mx + b and so y = x+b dx F ( x, y ) = dy.x − dx. y + c = 0 Indian Institute of Information Technology - Allahabad Decision variable. 1 d = F ( x p + 1, y p + ) 2 Evaluate F at point M Referred to as decision variable NE M E Previous Pixel (xp,yp) Choices for Current pixel Choices for Next pixel Indian Institute of Information Technology - Allahabad Decision variable. Evaluate d for next pixel, Depends on whether E or NE Is chosen : If E chosen : d new 1 1 = F ( x p + 2, y p + ) = a ( x p + 2) + b( y p + ) + c 2 2 But recall : NE M E Previous Pixel (xp,yp) Choices for Current pixel Choices for Next pixel 1 d old = F ( x p + 1, y p + ) 2 1 = a ( x p + 1) + b( y p + ) + c 2 So : d new = d old + a = d old + dy Indian Institute of Information Technology - Allahabad Decision variable. If NE was chosen : 3 3 d new = F ( x p + 2, y p + ) = a ( x p + 2) + b( y p + ) + c 2 2 M NE d new = d old + a + b = d old + dy − dx E Previous Pixel (xp,yp) Choices for Current pixel So : Choices for Next pixel Indian Institute of Information Technology - Allahabad Summary of mid-point algorithm • Choose between 2 pixels at each step based upon sign of decision variable. • Update decision variable based upon which pixel is chosen. • Start point is simply first endpoint (x1,y1). • Need to calculate initial value for d Indian Institute of Information Technology - Allahabad Initial value of d. Start...
View Full Document

Ask a homework question - tutors are online