Click here to load reader
Upload
conan-dyer
View
40
Download
3
Embed Size (px)
DESCRIPTION
计算机图形学. 武汉大学电子信息学院 王泉德 [email protected]. 第五章 图形生成和计算. 一、 区域填充. 一个区域是指一组相邻而又相连的象素,且具有同样的属性。区域的建立和定义通常可采用两种方式: 内定义区域( Interior-Defined ):区域内部所有象素具有同一种颜色或亮度值,而区域外的所有象素具有其他颜色或亮度值。 边界定义区域( Boundary-Defined ):区域边界上所有象素均具有特定的颜色或亮度值,而在区域内、外的象素则具有不同于边界值的颜色或亮度值。. - PowerPoint PPT Presentation
Citation preview
Interior-Defined
Boundary-Defined
123
1.1.1
P4P0P3P2P1
1.2
113223P4
1 xmin,ymin,xmax,ymax
2PPPi ;PPi ;P
P=P0P1PnP0Framebuffer(x,y)(x,y) for y:= ymin to ymax do for x:= xmin to xmax do if inside(p, x, y) then setpixel(framebuffer, x, y, polygon-color) else setpixel(framebuffer, x, y, back-color);
P
1.3
yk+1ykykyk+1P
y=yky=yk+1PPP{yk , yk+1}PP zPP
ykPX1,X2,.XL
L(Xk, Xk+1),k=1,3,5PP
dd=e-1PPr-1Pry=dy=exexd(mr)
PPPi ;P (yi+1-yi)*(yi-1-yi)>0 Pi ;P
()
3x x(2,4,9,13)24913
p1,p3,p4,p5 y=7(2,7,13)(7,7)(2,7,7,13)p2p6p1p2p3p4p5p6p1p2p3p4p5p6
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
10
11
P2(5,1)
E
P3(11,3)
D
P4(11,8)
G
F
C
B
P5(5,5)
P6(2,7)
A
P1(2,2)
(AET)x xxx()ymaxymax
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
10
11
P2(5,1)
E
P3(11,3)
D
P4(11,8)
G
F
C
B
P5(5,5)
P6(2,7)
A
P1(2,2)
(ET)yminyminxxxxymaxymax
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
10
11
P2(5,1)
E
P3(11,3)
D
P4(11,8)
G
F
C
B
P5(5,5)
P6(2,7)
A
P1(2,2)
ETyETyAELyETAELwhile AELET do begin AELxmin AELx if y=ymaxthen AEL AELx=x+1/m y=y+1yETAEL endend of algorithm
1.4 MM (x,y)
1y=eM for x:= xmin to xmax do setpixel(framebuffer, x, e, M);2xi, for i:= 1 to m do for x:= xi to xmax do complement(framebuffer, x, e) y=e
1.5
1boundary-colorP2boundary-colorx
For y:= ymin to ymax doBegin interior-point := false; for x:= xmin to xmax do begin if getpixel(framebuffer,x,y) = boundary-color then interior-point = not interior-point; if interior-point then setpixel(framebuffer,x,y,polygon-color) else setpixel(framebuffer,x,y,background-color); endend
2. ()
2.1 484
8
2.2 4 procedure flood-fill-4(x,y) begin if getpixel(framebuffer,x,y) = old-color then begin setpixel(framebuffer,x,y,new-color); flood-fill-4(x,y+1); flood-fill-4(x,y-1); flood-fill-4(x-1,y); flood-fill-4(x+1,y); endend of algorithm;
4
2.3
282112272620191125182423171683357234373936384143454042442215141051396302913332431
while do begin xleft xright ifxleftxxright then goto 2 xleftxxright endend of algorithm
2.4
3. (aliasing)(antialiasing)
3.1
3.2 2*23*3()
5)D2/2m4)D - m/21 - D2/m
0
1
1
2
2
3
3
4
4
5
5
6
7
8
9
10
11
1 577 9881616P88
bufferbxi, yixi+1, yic90 x, yydn
buffer
22.4.2BB{a, b, c, d, e, f, e, g, h, I, j, k ,a, l}
polyline
3880~701 B B8{000012344400012344440666666}
xy45
4676372X7272X72X6763/8=4.4
Bezier/
AppleMicrosoftTrueTypeWindowsMs-WindowsCAD
CADCAD
2 =10-6
11P1P2Q1Q2P(t)=A+Bt (0 t 1)Q(s)=C+Ds (0 s 1)A=P1B=P2-P1C=Q1D=Q2-Q1A+Bt=C+Ds s, tti, siP(ti)=A+Bti
st A+Bt=C+Ds(C D) (A+Bt)=(C D) (C+Ds)C DCD
2 f(x, y)=0, (x, y)=(x1+t(x2-x1), y1+t(y2-y1)), f(x1+t(x2-x1), y1+t(y2-y1))=0at2+bt+c=0t
3 /NURBS
4 P(u, w)=A+uB+wCQ(t)=D+tERR=P(u, w)=Q(t)A+uB+wC=D+tEB CB CA+uB+wC=B CD+tE
B CBC B CA=B CD+tE
5
6
21 P(u, w), Q(s, t), u, w, s, t[0, 1]P(u, w)-Q(s, t)=0u=0, u=1, w=0, w=1, s=0, s=1, t=0, t=1
AB 1AB 2BA 3yx 4ABAB
2 1 Ax2+By2+Cz2+2Dxy+2Eyz+2Fxz+2Gx+2Hy+2Iz+J=0
XOYz=0z
z=0
2
ppp.b, p.wss.c, s.rplane_sphere_intersect(p, s)plane p;sphere s;{ d= if(abs(d)=s.r) { s.c-d * p.w;} else if (abs(d)>s.r) { } else { c=s.c-d * p. w; r=sqr t(s.r2-d2); w=p.w; }}
3 x(s,t), y(s,t), z(s,t) ax+by+cz+d=0st ax(s,t)+by(s,t)+cz(s,t)+d=0 xoy x*, y*, z*=x*(s,t), y*(s,t), z*(s,t) z*(s, t)=0
123Bezier
2 (x, y, z)(x0,y0,z0)r12 (x) ax+by+cz+d=0x0, y0r1 2P(x, y)P:Px0, y0r
P
3 P(x, y, z)Q(t)=(x(t), y(t), z(t))1tPQ(t) R(t)=(P-Q(t))(P-Q(t))=|P-Q(t)|22t[01]3Q(t)P
4 P(x, y, z)ax+by+cz+d=0 d=
d<
1P0P1P2PnVi=Pi-P0, i=1, 2, , n, Vn+1=V1P0ViVi+1(i=1, 2, , n)
2 P0P1P2P3P4P5P0PiVi=Pi-P0 PiP0Pi+1=ai P02.5.3(a) P02.5.3(b)aiSi=Vi Vi+1, Ci=ViVi+1tg(ai)=|Si|/Ciai=arctg(|Si|/Ci)ai
3
4/P(x0, y0, z0)Q(x, y, z)=0|Q(x0, y0, z0)|< BezierB
xyxminxxmaxyminyymaxxminxxmaxyminyymaxzminzzmax
BezierBNURBS