1 / 7

CS U540 Computer Graphics

CS U540 Computer Graphics. Prof. Harriet Fell Spring 2009 Lecture 6 – January 15, 2009. (x, y). Drawing Circles - 1. x = Rcos(  ) y = Rsin(  ) for  = 0 to 360 do x = Rcos(  ) y = Rsin(  ) draw(x, y). R. (0, 0). . (x, y). Drawing Circles 2. x 2 + y 2 = R 2

kenyon
Télécharger la présentation

CS U540 Computer Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS U540Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 6 – January 15, 2009

  2. (x, y) Drawing Circles - 1 x = Rcos() y = Rsin() for = 0 to 360 do x = Rcos() y = Rsin() draw(x, y) R (0, 0) 

  3. (x, y) Drawing Circles 2 x2 + y2 = R2 forx = -R to R do y = sqrt(R2 - x2) draw(x, y) draw(x, -y) R (0, 0) 

  4. (-x, y) (x, y) (-y, x) (y, x) (-y, -x) (y, -x) (-x, -y) (x, -y) Circular Symmetry (0, 0)

  5. Midpoint Circle Algorithm IN THE TOP OCTANT: If (x, y) was the last pixel plotted, either (x + 1, y) or (x + 1, y - 1) will be the next pixel. Making a Decision Function: d(x, y) = x2 + y2 – R2 d(x, y) < 0 (x, y) is inside the circle. If d(x, y) = 0 (x, y) is on the circle. d(x, y) > 0 (x, y) is outside the circle.

  6. Decision Function Evaluate d at the midpoint of the two possible pixels. d(x + 1, y - ½) = (x + 1)2 + (y - ½)2 – R2 d(x + 1, y - ½)< 0 midpoint inside circle choose y If d(x + 1, y - ½)= 0 midpoint on circle choose y d(x + 1, y - ½)> 0 midpoint outside circle choose y - 1

  7. Computing D(x,y) Incrementally D(x, y) = d(x + 1, y - ½) = (x + 1)2 + (y - ½)2 – R2 D(x + 1, y) – D(x, y)= (x+2)2 + (y - ½)2 – R2 – ((x + 1)2 + (y - ½)2 – R2) =2(x + 1)+ 1  integer D(x + 1, y - 1) – D(x, y)= (x+2)2 + (y – 3/2)2 – R2 – ((x + 1)2 + (y - ½)2 – R2) =2(x+1) + 1 – 2(y – 1)  integer D(0, R) = 5/4 – R but we can round to 1 – R without changing any decisions.  integer You can also compute the differences incrementally.

More Related