Bresenham画圆算法(2/7)
v圆弧与点(xi,yi)附近光栅网格的相交关系有5种v右下角像素D (xi,yi)与实际圆弧的近似程度???i=(xi+1)2+(yi-1)2-R2
??当?i<0时,D在圆内,①②??当?i>0时,D在圆外,③④??当?i=0时,D在圆上,⑤
②Pi(xi,yi)H(xi+1,yi)①④V③D(x+1,y-1)ii(xi,yi-1)⑤Bresenham画圆算法(3/7)当?i<0时,D在圆内,①②v情形①,选mH ,mD 中最小者vd=mH - mD
222222 =|(xi+1)+yi-R| - |(xi+1)+(yi-1)-R|222222 =(xi+1)+yi-R + (xi+1)+(yi-1)-R
=2 (?i+yi)-1
v
②Pi(xi,yi)H(xi+1,yi)①D(xi+1,yi-1)V(xi,yi-1)??若d<0,则选H??若d>0,则选D??若d=0,则选H
情形②也适用Bresenham画圆算法(4/7)当?i>0时,D在圆外,③④
)v情形③,选mv ,mD 中最小者④V③D(xi+1,yi-1)vd’=mD - mV
(xi,yi-1) =|(xi+1)2+(yi-1)2-R2 | - |xi2+(yi-1)2-R2| =(xi+1)2+(yi-1)2-R2 + xi2+(yi-1)2-R2 =2 (?i-xi)-1情形④也v
Pi(xi,yi)H(xi+1,yi??若d’<0,则选D ??若d’>0,则选V??若d’=0,则选D
适用Bresenham画圆算法(5/7)
v当?i=0时,D在圆上,⑤v按d判别,有d>0,应选Dv按d’判别,有d’<0,应选D
Pi(xi,yi)VH(xi+1,yi)D(xi+1,yi-1)(xi,yi-1)⑤Bresenham画圆算法(6/7)
v当?i<0时,
??若d≤0,选H??若d>0,选D
v当?i>0时,
??若d’ ≤0,选D ??若d’>0,选V
v当?i=0时,选D
Pi(xi,yi)VH(xi+1,yi)D(xi+1,yi-1)(xi,yi-1)