Download presentation
Presentation is loading. Please wait.
1
computer graphics 2D graphics
2
contents Lines Circles DDA algorithm Bresenham’s algorithm
The midpoint algorithm Circles Symmetry algorithm
3
line drawing
4
a line can be expressed as
5
Digital Differential Analyzer Algorithm (|m| ≤ 1)
scan conversion
6
要点:增量计算,变乘法为加法
7
Example 2.1 Using the DDA line drawing algorithm, determine the pixels along a line segment that goes from [3, 4]T to [8, 6]T.
8
current x current y floor(y+0.5) next y 3 4 4.4 4.8 5 5.2 6 5.6 7 8 6.4
9
when |m| > 1
10
another solution current x current y floor(y+0.5) next y 3 4 4.4 4.8 5
5.2 6 5.6 7 8 6.4
11
special case
12
generalization general case
14
Bresenham’s algorithm
replace floating point numbers with integer numbers
16
Example 2.3 You are asked to draw a line segment between the points [1, 1] and [4, 3]. Use Bresenham’s line drawing algorithm to specify the locations of pixels that should approximate the line.
17
The Midpoint Algorithm
18
implicit equation of curve
implicit equation of line
19
derivation of incremental expression
test midpoint (x+1,y+1/2) with f(x,y) f(x+1,y+1/2) = a(x+1)+b(y+1/2)+c if f(x+1,y+1/2)>0, P2 is closer if f(x+1,y+1/2)<0, P1 is closer if f(x+1,y+1/2)=0, equal closer, chooe any
20
if P1 is selected, next midpoint to be tested is (x+2,y+1/2)
f(x+2,y+1/2) = a(x+2)+b(y+1/2)+c = a(x+1)+b(y+1/2)+c+a = f(x+1,y+1/2)+a if P2 is selected, next midpoint to be tested is (x+2,y+3/2) f(x+2,y+3/2) = a(x+2)+b(y+3/2)+c = a(x+1)+b(y+1/2)+c+a+b = f(x+1,y+1/2)+a+b
21
initial value f(x0+1,y0+1/2) = a(x0+1)+b(y0+1/2)+c = ax0+by0+c+a+b/2 = f(x0,y0)+a+b/2=a+b/2
24
Example 2.4 You are asked to draw a line segment between the points [1, 1] and [4, 3]. Use the midpoint line drawing algorithm to specify the locations of pixels that should approximate the line.
25
circle drawing x=x0+rcos(θ) y=y0+rsin(θ)
26
Two-Way Symmetry Algorithm
29
Four-Way Symmetry Algorithm
31
Eight-Way Symmetry Algorithm
33
The Midpoint Algorithm
34
derivation of the incremental expression (ref. p.28)
implicit equation of the circle centered at origin (0,0) f(x,y)=x2+y2-r2=0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.