Graphics Graphics Lab @ Korea University Mathematics for Computer Graphics Graphics Laboratory...
-
Upload
marlene-booth -
Category
Documents
-
view
249 -
download
0
Transcript of Graphics Graphics Lab @ Korea University Mathematics for Computer Graphics Graphics Laboratory...
Graphics
Graphics Lab @ Korea University
http://kucg.korea.ac.kr
Mathematics for Computer Graphics
Graphics LaboratoryGraphics Laboratory
Korea UniversityKorea University
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Contents
Coordinate Systems
Points and Vectors
Matrices
Parametric vs. Nonparametric Representations
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Coordinate Systems
Rectangular x, y, z axes
Typical coordinate system
Right/left-hand system
Polar
Cylindrical
Spherical
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
2D Rectangular Coordinate System
Coordinate origin at the lower-left screen corner
y
x
y
x
Coordinate origin at the upper-left screen corner
<Window Coordinate System><Window Coordinate System><Screen Coordinate System><Screen Coordinate System>
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
3D Rectangular Coordinate System
Right-hand system Standard in most graphics packages
Left-hand system Easy to know the distance from the
viewer Video monitor coordinate system
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Polar Coordinate System
sin,cos ryrx
xyyxr /tan, 122
rs
rr ss
xx
yy
p(r,p(r,))
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Why Polar Coordinates in Circles?
xx
yy
dddd
Irregularly Distributed Adjacent PointsIrregularly Distributed Adjacent PointsConstant Distance Constant Distance
among the Adjacent Pointsamong the Adjacent Points
Polar Coordinate SystemRectangular Coordinate System
222 ryx
sin
,cos
ry
rx
In rectangular system Irregular distribution of continuous points
xx
yy
dxdxdxdx
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Cylindrical / Spherical System
cosrx sinry
zz
cossinrx sinsinry
cosrz
zz
yy
xx
rr zz
p(r,p(r,,z),z)
22 yxr )/(tan 1 xy
yy
xx
zz
rr
p(r,p(r,, , ))
222 zyxr )/(tan 1 xy)/(cos 1 rz
Spherical Coordinate SystemCylindrical Coordinate System
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Point: location, position
Vector: direction from one point to another
Represented by using magnitude and unit direction
),(),( 121212 yx VVyyxxPPV
VV
PP22
PP11
xx11 xx22
yy11
yy22
22yx VVV
x
y
V
V1tan
Points and Vectors
xx
yy
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Vectors
3D Vector
Vector addition and scalar multiplication
222zyx VVVV
||cos,
||cos,
||cos
V
V
V
V
V
V zyx
1coscoscos 222
VV
xx
zz
yy
),,( 21212121 zzyyxx VVVVVVVV
),,( zyx VVVV
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Scalar Product
Definition
Properties Commutative
Distributive
0,cos|||| 2121 VVVV
Dot Product / Inner Product
zzyyxx VVVVVV 212121
1221 VVVV
3121321 )( VVVVVVV
|V|V22|cos|cos
VV22
VV11
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Vector Product
Definition
Properties Anti-commutative Not associative Distributive
0,sin|||| 2121 VVVV u
),,( 212121212121 xyyxzxxzyzzy VVVVVVVVVVVV
Cross Product / Outer Product
)( 1221 VVVV
321321 )()( VVVVVV )()()( 3121321 VVVVVVV
VV11
VV22
VV11 V V22
uu
Careful for its direction!!!Careful for its direction!!!
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Plane Normal Calculation
Frequently used in Back face detection Shading function
Vector productVector product between Two edges of the target polygon
VV11
VV22
N = VN = V11 ×× V V22
PP00
PP11PP22
PP33
PP44
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Back Face Detection
Not drawing the back faces to be culled Can make the drawing speed faster
Scalar productScalar product between Eye direction DDeyeeye and face normal vector NNii
If DDeyeeyeNNii > 0 FFii is back face
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Back Face Example
EyeEye Eye Direction DEye Direction Deyeeye(1,0)(1,0)
NN11
(-0.9, -0.1)(-0.9, -0.1)
NN22
(-0.8, 0.2)(-0.8, 0.2)
NN33
(-0.2, 0.8)(-0.2, 0.8)
NN44
(0.3, 0.7)(0.3, 0.7)
NN55
(0.8, 0.2)(0.8, 0.2)
FF11
FF22
FF33FF44
FF55
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Back Face Calculation
F1
DeyeN1 = (1,0)(-0.9, -0.1) = -0.9 F1 is a front face F2
DeyeN2 = (1,0)(-0.8, 0.2) = -0.8 F2 is a front face F3
DeyeN3 = (1,0)(-0.2, 0.8) = -0.2 F3 is a front face F4
DeyeN4 = (1,0)(0.3, 0.7) = 0.3 F4 is a back face F5
DeyeN5 = (1,0)(0.8, 0.2) = 0.8 F5 is a back face
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Back Face Culled Result
EyeEye Eye Direction DEye Direction Deyeeye(1,0)(1,0)
NN11
(-0.9, -0.1)(-0.9, -0.1)
NN22
(-0.8, 0.2)(-0.8, 0.2)
NN33
(-0.2, 0.8)(-0.2, 0.8)
NN44
(0.3, 0.7)(0.3, 0.7)
NN55
(0.8, 0.2)(0.8, 0.2)
FF11
FF22
FF33FF44
FF55
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Shading Function
The amount of illumination depends on coscos If the incoming light IIinin is perpendicular to the surface
IIsurfsurf is maximum, so the surface is fully illuminated
= 0, coscos = 1
NN
LL
cosinsurf kII LNkI in
IIsurfsurf: intensity of the surface: intensity of the surfaceIIinin: intensity of the incident light: intensity of the incident lightkk: surface reflection coefficient: surface reflection coefficientLL: direction from the surface to a light source: direction from the surface to a light source
<Simple Shading Function><Simple Shading Function>
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Matrices
Definition A rectangular array of quantities
Scalar multiplication and matrix addition
mnmm
n
n
aaa
aaa
aaa
A
...
:::
...
...
21
22221
11211
2221
1211
2221
1211 ,bb
bbB
aa
aaA
22222121
12121111
baba
babaBA
2221
1211
kaka
kakakA
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Matrix Multiplication
Definition
Properties Not commutative Associative Distributive Scalar multiplication
× = (i,j)
j-th column
i-th row
m l
nnm
l
n
kkjikij bac
1
ABC
BAAB )()( BCACAB BCABCBA )(
)()()( ABkkBABkA
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Matrix Transpose
Definition Interchanging rows and columns
Transpose of matrix product
c
b
a
cba T
T
,
63
52
41
654
321
TTT ABAB
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Determinant of Matrix
Definition For a square matrix
Combining the matrix elements to product a single number
2 2 matrix
Determinant of nn matrix A (n 2)
n
jjkjk
kj a1
det)1(det AA
211222112221
1211 aaaaaa
aa
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Inverse Matrix
Definition
Non-singular matrix If and only if the determinant of the matrix is non-zero
2 2 matrix
Properties
IAAIAA 11
TT )A()A(AB)AB(A)A( 1111111
ac
bd
bcadA
11
dc
baA
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Parametric vs. Nonparametric Representations
Circle example in computer graphics radius 2, centered at the origin
Parametric expression: x = 2cos, y = 2sin Nonparametric expression
Implicit: , explicit: 422 yx 24 xy
xx
yy
xx
yy
00 11 22-2-2 -1-1
Parametric ExpressionParametric ExpressionInterval of Interval of : : /4/4
Nonparametric ExpressionNonparametric ExpressionInterval of x: 1Interval of x: 1
Which one is balanced?Which one is balanced?
22-2-2
http://kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Parametric Representation
Easy to draw the shape of an object smoothly Just increase one parameter ex)
The other parameters are automatically calculated by Especially for symmetric objects
Circle, sphere, ellipsoid, etc.
Preferred in computer graphics Nonparametric representation is used mainly in
numerical analysis