21
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms

2D Line Circle

  • Upload
    tulsi

  • View
    225

  • Download
    1

Embed Size (px)

DESCRIPTION

2d line circle..

Citation preview

Larry F. Hodges (modified by Amos Johnson)1Design of Line, Circle & Ellise Algori!hmsLarry F. Hodges (modified by Amos Johnson)"y2-y1SLOPE = RISERUN= x2-x1#asic $a!h %e&ie'(loe)*n!erce! Form+la For A LineGiven a third point on the line: P = (x,y)Slope = (y - y1)/(x - x1) = (y2 - y1)/(x2 - x1)Solving For yy = [(y2-y1)/(x2-x1)]x [-(y2-y1)/(x2-x1)]x1y1there!orey = "x#$here" =[(y2-y1)/(x2-x1)] #=[-(y2-y1)/(x2-x1)]y1y1Cartesian Coordinate System243561P1 = x1!y1"P2 = x2!y2"P = x!y" 1%&'( )Larry F. Hodges (modified by Amos Johnson),-!her Helf+l Form+lasLeng!h of line segmen! be!'een .1 and ."/* = s#rt0 (x2-x1)2(y2-y1)2 ]$idoin! of a line segmen! be!'een .1 and .,/P2 = ( (x1x%)/2 , (y1y%)/2 )+$o line, are erendic+lar i!! 1)"1 =-1/"2or2)-o,ine o! the angle .et$een the/ i, 01Larry F. Hodges (modified by Amos Johnson)1.arame!ric Form -f 2he E3+a!ion -fA "D Line (egmen!Given point,P1 = (x1, y1)andP2 = (x2, y2)4 5 41 6 !(4")41)y 5 y1 6 !(y")y1)t i, 2alled the para/eter13hen! 5 7 'e ge! (41,y1)! 5 1 'e ge! (4",y")4, 0 5 t 5 1 $e get all the other point, on the line ,eg/ent .et$een (x1,y1) and (x2,y2)1Larry F. Hodges (modified by Amos Johnson)8#asic Line and Circle Algori!hms11"6,t 2o/p6te integer 2oordinate, o! pixel, $hi2h lie on or near a line or 2ir2le121Pixel level algorith/, are invo7ed h6ndred, or tho6,and, o! ti/e, $hen an i/age i, 2reated or /odi!ied1%1*ine, /6,t 2reate vi,6ally ,ati,!a2tory i/age,18 *ine, ,ho6ld appear ,traight8*ine, ,ho6ld ter/inate a226rately8*ine, ,ho6ld have 2on,tant den,ity8*ine den,ity ,ho6ld .e independent o! line length and angle1&1*ine algorith/ ,ho6ld al$ay, .e de!ined1Larry F. Hodges (modified by Amos Johnson)9(imle DDA Line Algori!hm9#a,ed on the para/etri2 e:6ation o! a line;Pro2ed6re 2 :?nteger)@Aar*ength, ? :?nteger@=,>,=in2,>in2 :Beal@#egin*ength := 4#S(=2 - =1)@?! 4#S(>2 - >1)C *ength +hen*ength := 4#S(>2->1)@=in2 := (=2 - =1)/*ength@>in2 := (>2 - >1)/*ength@= := =1@> := >1@>in2Dnd9For;Dnd@9