Вы находитесь на странице: 1из 23

1

Raster

URL: http://www.school30.spb.ru/cgsg/cgc/
E-mail: CGSG@yandex.ru

..
- 30
Computer Graphics Support Group
2
Raster



( ,
)



..
- 30
Computer Graphics Support Group
3
Line Raster

(x2,y2)

(x1,y1)

..
- 30
Computer Graphics Support Group
4
Line: Digital Differential Analyzer (DDA) Raster

y2-y1

slope

(x,y) x2-x1

..
- 30
Computer Graphics Support Group
5
Line: ( ) Raster

x x1 y y1
y
x 2 x1 y 2 y1
( x x1) ( y 2 y1) ( y y1) ( x 2 x1) 0
(x2,y2)
dy x dx y ( x1 dy y1 dx) 0
f ( x, y ) dy x dx y ( x1 dy y1 dx)
f ( x, y ) 0
(x,y)
(x,y)
(x1,y1)
f ( x, y ) 0 (x,y)
x
f ( x, y ) 0 (x,y)

..
- 30
Computer Graphics Support Group
6
Line: ( ) Raster

M f:
NE f(x,y)
f(M) > 0 N
f(M) <= 0
M(x+1,y+1/2)

P(x,y) E

..
- 30
Computer Graphics Support Group
7
Line: ( ) Raster

M f:
f(x,y) f(M) > 0 N
f(M) <= 0
MNE(x+2,y+3/2)
NE
f(M)
(E NE):
ME(x+2,y+1/2)
M

f ( M ) f ( x 1, y 1 ) dy ( x 1) dx ( y 1 ) C
E 2 2
P(x,y)
dy x dy dx y dx C
2
f ( M E ) f ( x 2, y 1 ) dy ( x 2) dx ( y 1 ) C
2 2
dy x 2 dy dx y dx C f ( M ) dy
2
f ( M NE ) f ( x 2, y 3 ) dy ( x 2) dx ( y 3 ) C
2 2
dy x 2 dy dx y 3 dx C f ( M ) dy dx
2

..
- 30
Computer Graphics Support Group
8
Line: ( ) Raster

f.


f(x,y) (x1,y1)

M0(x+1,y+1/2)

P1(x1,y1) f ( M 0 ) f ( x1 1, y1 1 )
2
dy ( x1 1) dx ( y1 1 ) ( x1 dy y1 dx)
2
dy dx
2

..
- 30
Computer Graphics Support Group
9
Line: ( ) Raster


.
: 2f = e

:
e = 2 * dy - dx;
e > 0
e = e + 2 * dy - 2 *dx;
e = e + 2 * dy
e .

..
- 30
Computer Graphics Support Group
10
Line: ( ) Raster

..
- 30
Computer Graphics Support Group
11
Line: Fixed Point (DDA) Raster

Fixed Point
.
4- :

2b 2b

1/65536
x y fixed point,
(x+y)
(x-y)

16 (x >> 16)
: x = a << 16

..
- 30
Computer Graphics Support Group
12
Circle Raster

R
x

..
- 30
Computer Graphics Support Group
13
Circle: ( ) Raster

y
f ( x, y) x 2 y 2 R 2
(0,R)
x<=y
f ( x, y ) 0 (x,y)

f ( x, y ) 0 (x,y)
x f ( x, y ) 0 (x,y)

P(x,y)
E

M(x+1,y-1/2)

f(x,y)
SE
M f:
f(M) >= 0 S
f(M) < 0

..
- 30
Computer Graphics Support Group
14
Circle: ( ) Raster

P(x,y)
E
f(M)
ME (E SE):
M f(x,y)

SE
MSE f ( M ) f ( x 1, y 1 ) ( x 1) 2 ( y 1 ) 2 R 2
2 2
x2 2 x 1 y 2 y 1 R2
4
f ( M E ) f ( x 2, y 1 ) ( x 2) 2 ( y 1 ) 2 R 2
2 2
x2 4 x 4 y 2 y 1 R2 f (M ) 2 x 3
4
f ( M NE ) f ( x 2, y 3 ) ( x 2) 2 ( y 3 ) 2 R 2
2 2
x2 4 x 4 y 2 3 y 9 R2 f (M ) 2 x 2 y 5
4

..
- 30
Computer Graphics Support Group
15
Circle: ( ) Raster

f.

(x1,y1)
P(0,R)
E f ( M 0 ) f (1, R 1 ) 12 ( R 1 )2 R 2
2 2
1 R2 R 1 R2 5 R
M0(1,R-1/2) 4 4

f(x,y)
SE

- . f
0 : <.
f
1/4..

..
- 30
Computer Graphics Support Group
16
Circle: ( ) Raster

:
E SE
(incrE=2*x+3 incrSE=2*(x-y)+5)
.
E, x 1 :
incrE=incrE+2 incrSE=incrSE+2

SE, x 1, y 1 :
incrE=incrE+2 incrSE=incrSE+4
:
incrE=3 incrSE=5-2*R

..
- 30
Computer Graphics Support Group
17
Circle: ( ) Raster

..
- 30
Computer Graphics Support Group
18
Polygon Raster

..
- 30
Computer Graphics Support Group
19
Flood Fill Raster

..
- 30
Computer Graphics Support Group
20
Flood Fill Raster

..
- 30
Computer Graphics Support Group
21
Text Raster

..
- 30
Computer Graphics Support Group
22
Text Raster

0x3C
0x46
0x86
0x86
0x86
0xFE
0x86
0x00



( )

..
- 30
Computer Graphics Support Group
23
Raster



.

.

..
- 30
Computer Graphics Support Group

Оценить