Date post: | 11-Jan-2016 |
Category: |
Documents |
Upload: | blaise-harmon |
View: | 215 times |
Download: | 0 times |
Geometric Objects
2001. 7. 6Computer Graphics Lab.Sun-Jeong Kim
Korea UniversityComputer Graphics-2-
PointsSingle Coordinate Position
Set the bit value(color code) corresponding to a specified screen position within the frame buffer
x
ysetPixel (x, y)
Korea UniversityComputer Graphics-3-
Lines Intermediate Positions between Two End
points DDA, Bresenham’s line algorithms
Jaggies= Aliasing
Korea UniversityComputer Graphics-4-
DDA Algorithm Digital Differential Analyzer
Slope >= 1 Unit x interval = 1
0 < Slope < 1 Unit y interval = 1
Slope <= -1 Unit x interval = -1
-1 < Slope < 0 Unit y interval = -1
x1
y1
x2
y2
myy kk 1
x1
y1
x2
y2
mxx kk
11
x1
y1
x2
y2
myy kk 1
x1
y1
x2
y2
mxx kk
11
Korea UniversityComputer Graphics-5-
Bresenham’s Line AlgorithmMidpoint Line Algorithm
Decision variable
NE
MQ
cybxa
yxF
MFd
pp
pp
2
11
2
1,1
d > 0 : choose NE : dnew= dold+a
d <= 0 : choose E : dnew= dold+a+b
2
1,2 ppnew yxFd
2
3,2 ppnew yxFd
P(xp, yp) E
Korea UniversityComputer Graphics-6-
Bresenham’s Algorithm(cont.) Initial Value of d
Update d
bayxF
cybxayxF
2
1,
2
11
2
1,1
00
0000
cbyaxyxF 2,
bad 2
2
,
,
then ,0 if
bad
y
x
d 2
, then ,0 if
ad
xd
0, cbyaxyxF
Bxdx
dyy
0, dxBydxxdyyxF
dxBcdxbdya , ,
Korea UniversityComputer Graphics-7-
PolygonsFilling Polygons
Scan-line fill algorithm Inside-Outside tests
Boundary fill algorithm
Korea UniversityComputer Graphics-8-
Scan-Line Polygon Fill Topological Difference between 2 Scan
lines y : intersection edges are opposite sides y’ : intersection edges are same side
y
y’
Korea UniversityComputer Graphics-9-
Scan-Line Polygon Fill (cont.)Edge Sorted Table
C
C’
B
D
E
A
01
yA
yD
yC
Scan-Line Number
yE xA1/mAE yB xA
1/mAB
yC’ xD1/mDC yE xD
1/mDE
yB xC1/mCB
Korea UniversityComputer Graphics-10-
Inside-Outside TestsSelf-Intersections
Odd-Even ruleNonzero winding number rule
exterior
interior
Korea UniversityComputer Graphics-11-
Boundary-Fill AlgorithmProceed to Neighboring Pixels
4-Connected8-Connected
Korea UniversityComputer Graphics-12-
AntialiasingAliasing
Undersampling: Low-frequency sampling
Nyquist sampling frequency:Nyquist sampling interval: max2 ff s
2cyclex
xs
Korea UniversityComputer Graphics-13-
Antialiasing (cont.)Supersampling (Postfiltering)
Pixel-weighting masksArea Sampling (Prefiltering)Pixel Phasing
Shift the display location of pixel areasMicropositioning the electron beam in relati
on to object geometry
Korea UniversityComputer Graphics-14-
SupersamplingSubpixels
Increase resolution
10 11 12
20
21
22
(10, 20): Maximum Intensity
(11, 21): Next Highest Intensity
(11, 20): Lowest Intensity
Korea UniversityComputer Graphics-15-
Pixel-Weighting MasksGive More Weight to Supixels Near the C
enter of a Pixel Area
1 2 1
2 4 4
1 2 1
Korea UniversityComputer Graphics-16-
Area SamplingSet Each Pixel Intensity
Proportional to the Area of Overlap of Pixel2 Adjacent vertical (or horizontal)
screen grid lines trapezoid
10 11 12
20
21
22
(10, 20): 90%
(10, 21): 15%
Korea UniversityComputer Graphics-17-
Filtering TechniquesFilter Functions (Weighting
Surface)
Box Filter Cone Filter Gaussian Filter
Mathematics for CG
Korea UniversityComputer Graphics-19-
Coordinate Reference Frames2D Cartesian Reference Frames
x
y
x
y
Korea UniversityComputer Graphics-20-
2D Polar Coordinate Reference Frame
r
r
x
y
x
yyxr
ryrx
122 tan,
sin,cos
s
rP
radianr
rr
sradian
22
360
Korea UniversityComputer Graphics-21-
3D Cartesian Reference FrameRight-Handed v.s. Left-Handed
y
xz
Right-handed Left-handed
y
x
z
Korea UniversityComputer Graphics-22-
3D Curvilinear Coordinate SystemsGeneral Curvilinear Reference
FrameOrthogonal coordinate system
Each coordinate surfaces intersects at right angles
axisX1
axisX 2
axisX 3
33 constX11 constX
22 constX
Korea UniversityComputer Graphics-23-
Cylindrical-Coordinate
: radius of vertical cylinder
: vertical plane containing z-axis
: horizontal plane parallel to xy-plane
z
constant
zz
y
x
sin
cos
Transform to Cartesian coordinator
z
x axis
y axis
z axis
),,( zP
Korea UniversityComputer Graphics-24-
Spherical-Coordinate
: radius of sphere
: vertical plane containing z-axis
: cone with the apex at the origin
constant
cos
sinsin
sincos
rz
ry
rx
Transform to Cartesian coordinator
z
x axis
y axis
z axis
),,( rP
r
Korea UniversityComputer Graphics-25-
Solid Angle3D Angle Defined on a Sphere
Steradian
r
A2r
ASteradian :
Total solid angle :
44
2
2
2
r
r
r
Asteradian
Korea UniversityComputer Graphics-26-
Points & VectorsPoint
Position in some reference frameDistance from the origin depends on
the reference frame
PFrame B
Frame Ax
y
AO
BO
Korea UniversityComputer Graphics-27-
Points & Vectors (cont.)Vector
Difference between two point positions
Properties : Magnitude & direction Same properties within a single
coordinate system Magnitude is independent from
coordinate frames
yx VV
yyxx
PP
,
, 1212
12
V 22yx VV VMagnitude :
x
y
V
V1tanDirection :
Korea UniversityComputer Graphics-28-
3D VectorMagnitude
Directional angle
222zyx VVV V
x
y
z
VVVzyx VVV
cos,cos,cos
1coscoscos 222
Korea UniversityComputer Graphics-29-
Vector Addition &Scalar MultiplicationAddition
Scalar multiplication
),,( 21212121 zzyyxx VVVVVV VV
1V
2V 2V
1V
21 VV
),,( zyx aVaVaVa V
Korea UniversityComputer Graphics-30-
Vector MultiplicationScalar Product(Inner Product)
zzyyxx VVVVVV 212121
2121 cos
VVVV Commutative :
Distributive :
1221 VVVV
3121321 )( VVVVVVV Orthogonal : 021 VV
1V
2V
cos2V
Korea UniversityComputer Graphics-31-
Vector Multiplication (cont.)Vector Product(Cross Product)
zyx
zyx
zyx
xyyxzxxzyzzy
VVV
VVV
VVVVVVVVVVVV
222
111
212121212121
2121
,,
sin
uuu
VVuVV
Noncommutative :
Nonassociative :
Distributive :
1221 VVVV
3121321 )( VVVVVVV
321321 )()( VVVVVV
21 VV 2V
1V
uRight-handed rule!