mathmatics for computer graphics
DESCRIPTION
r. A. Mathmatics for Computer Graphics. Contents. Spaces Vectors and Linear combination Affine Combination Coordinate-reference Frames Points and Lines Parametric Representation Linear Transformation Homogeneous Coordinates. Vector Spaces. A nonempty set V of vectors - PowerPoint PPT PresentationTRANSCRIPT
Mathmatics for Computer Graphics
A r
Mathematics for Computer Graphics
Contents
Spaces Vectors and Linear combination Affine Combination Coordinate-reference Frames Points and Lines Parametric Representation Linear Transformation Homogeneous Coordinates
Mathematics for Computer Graphics
Vector Spaces
A nonempty set V of vectors
Vectors have magnitude and direction.
Addition + Scalar Multiplication · u+v = v+u V · (u+v)+w = u+(v+w)
· u+0 = u · u+(-u) = 0 · cu V ,(c is scalar) · c(u+v) = cu+cv · (c+d)u = cu+du · c(du) = (cd)u · 1u = u
Directed Line Segments
… but, have no position !
Identical Vectors
Mathematics for Computer Graphics
Affine Spaces
e3
e1
e2 e3
e1e2
Basis vectors located at the origin
Introducing the concepts of “points”,which represents “the location”
Truncated plane (No Origin): Vector Space
P 기준의 새 좌표계 설정: Affine Space
P
Contain the necessary elements for building geometric models
Points 와 그에 종속된 Vector 들로 표현
Mathematics for Computer Graphics
Euclidean Spaces
Affine spaces have no concepts of how far apart two points are, or of what the length of a vector is
To Support a measure of distance between points,such as,..Inner Product!
)()( QPQPQP
Mathematics for Computer Graphics
Points and Vectors
Point : 좌표계의 한 점을 차지 , 위치표시 Vector : 두 position 간의 차로 정의
Magnitude 와 Direction 으로도 표기
),(),( 121212 yx VVyyxxPPV
V
P2
P1
x1 x2
y1
y222
yx VVV
x
y
V
V1tan
Mathematics for Computer Graphics
Vectors (계속 )
3 차원에서의 Vector
Vector Addition and Scalar Multiplication
222zyx VVVV
||cos,
||cos,
||cos
V
V
V
V
V
V zyx
1coscoscos 222
V
x
z
y
),,( 21212121 zzyyxx VVVVVVVV
),,( zyx VVVV
Mathematics for Computer Graphics
Scalar Product
|V2|cos
V2
V1
0,cos|||| 2121 VVVV
Dot Product, Inner Product 라고도 함
For Cartesian reference frame,
zzyyxx VVVVVVVV 21212121
Some PropertiesCommutative
Distributive1221 VVVV
3121321 )( VVVVVVV
Mathematics for Computer Graphics
Scalar Product (계속 )
V2
V1
Edge 사이의 사잇각 Polygon 의 면적
(x0,y0,z0)
(x1,y1,z1)(x2,y2)
(x0,y0)
(x2,y2,z2)
(x1,y1)
Mathematics for Computer Graphics
Vector Product
0,sin|||| 2121 VVuVV
V1
V2
V1 V2
),,( 21212121212121 xyyxzxxzyzzy VVVVVVVVVVVVVV
※ ux,uy,uz 를 각 축의 단위 vector 라 하면 ,
zyx
zyx
zyx
VVV
VVV
uuu
VV
222
11121
Properties
AntiCommutative
Not Assotiative
Distributive
)( 1221 VVVV
321321 )()( VVVVVV
)()()( 3121321 VVVVVVV
Mathematics for Computer Graphics
Vector Product (계속 )
Shading, Reflection Model 평면사이의 위치관계
Mathematics for Computer Graphics
Vector Spaces
A nonempty set V of vectors
Addition + Scalar Multiplication
· u+v = v+u V · (u+v)+w = u+(v+w)
· u+0 = u · u+(-u) = 0
· cu V ,(c is scalar)
· c(u+v) = cu+cv · (c+d)u = cu+du
· c(du) = (cd)u · 1u = u
Mathematics for Computer Graphics
Linear Combination
Consist of scalar and vectors
nn2211 v...vv
v
v
v
: real number : nonnegative
Ex) Single Vector 의 linear combination
Mathematics for Computer Graphics
Span
v1
v2
v1 +v2
Ex) Span{v1,v2}
두 Vector 의 linear combination
Span Vector set 의 모든 가능한 linear combination 을 지칭
Mathematics for Computer Graphics
Linearly Independence
A set of vectors B={v1,…,vp} in V is said to be linearly independent if the vector equation
has only the trivial solution c1=0,…,cp=0.
0...2211 ppvcvcvc
uw
v
u
w
v
Linearly dependent,w in Span{u,v}
Linearly independent,w not in Span{u,v}
(6,2)(3,1)
Linearly dependent, Collinear
(6,2)(3,2)
Linearly independent, Not collinear
Mathematics for Computer Graphics
Basis
어떤 linearly independent vector set B 에 의해 vector space H 가 span 될 때 , 이 vector set B 를 H 의 basis 라 한다 .
1
0
0
u,
0
1
0
u,
0
0
1
u 321
z
x
yu1 u2
u3
The standard basis for R3
H = Span{b1, … ,bp}
Mathematics for Computer Graphics
Orthogonal Basis
Orthogonal basis
- 각 원소 vector 들이 서로 직교 할 때
- ,1 kk uu for all k,0 kj uu for all j k
-
kk
kkkkkk vv
vycvyvvc
yvcvcvc pp ...2211
z
x
yu1 u2
u3
Orthonormal basis
※ Orthonormal basis 각 원소 vector 들이 서로 직교 하면서 동시에 단위 vector 로 이루어져 있을 때
kkpp vyvvcvcvc )...( 2211
Mathematics for Computer Graphics
Affine Space
The Extension of the Vector Space
Geometric operation 들이 의미를 갖는 공간
Points 와 그에 종속된 vector 들로 표현
Truncated plane (No Origin): Vector Space
P 기준의 새 좌표계 설정: Affine Space
P
Mathematics for Computer Graphics
Affine Combination
Linear combination of points in an affine space make no se
nse (Operations on the points are limited)
Using Parametric Representation
)( 12 PPt
)( 121 PPtP
1P
2P
)( 121 PPtPP
Line segment joining P1and P2, if 0 t 1
21)1( tPPtP
2211 PPP Affine combination of two points
1, 21
Mathematics for Computer Graphics
Affine Combination
nnPPPP ...2211
2P
3P1P
P
)( 133 PP
)( 122 PP
One Example of Affine Combination
Generalized form
1..., 21 n
33211 PPPP 1, 321
gives a point in the triangle.
)()( 1331221 PPPPPP
2
1,
4
1321
Mathematics for Computer Graphics
Euclidean Transformation
One-to-One Correspondence between the points of such space and the set of all real-number pair or triples
Transforming Only by rotation and translation
w
y
xtR
w
y
x
T 1|
|
0'
'
')0,0(0
T
y
x
t
tt
Action of the euclidean group on five points
cossin
sincosR
Mathematics for Computer Graphics
Affine Transformation
w
y
xtA
w
y
x
T 1|
|
0'
'
'
projectiveaffineeuclidean
Action of the affine group on five points
Parallel lines are preseved.
R is Replaced by a general non-singular transformation matrix A
Mathematics for Computer Graphics
General Linear Transformation
w
y
x
t
t
t
t
t
t
t
t
t
w
y
x
33
23
13
32
22
12
31
21
11
'
'
'
It preserves the collinearity of points.
For general non-singular linear transformations T,
We get general linear or projective group of transformations.
Action of the projective group on five points
Mathematics for Computer Graphics
Coordinate Reference Frames
Coordinate Reference FramesCartesian coordinate system
x,y,z 좌표축사용 , 전형적 좌표계
Non-Cartesian coordinate system– 특수한 경우의 object 표현에 사용 .
– Polar, Spherical, Cylindrical 좌표계등
Mathematics for Computer Graphics
2 D Coordinate System
Two-dimensional Cartesian Reference Frames
a) b)
y
xy
x
Mathematics for Computer Graphics
Polar Coordinates
가장 많이 쓰이는 non-Cartesian System
Elliptical coordinates, hyperbolic, parabolic plane coordinates 등 원 이외에 symmetry 를 가진 다른 2 차 곡선들로도 좌표계 표현 가능 .
sin,cos ryrx
x
yyxr 122 tan,
rs
r
Mathematics for Computer Graphics
Why Polar Coordinates?
x x
y y
dxdx
dd
균등하게 분포되지 않은 점들 연속된 점들 사이에 일정간격유지
Polar CoordinatesCartesian Coordinates
예 ) 원의 표현
222 ryx
sin
,cos
ry
rx
Mathematics for Computer Graphics
3D Cartesian Frames
Three Dimensional Point
Mathematics for Computer Graphics
3D Cartesian Frames
오른손 좌표계
- 대부분의 Graphics Package 에서 표준
왼손 좌표계
- 관찰자로부터 얼마만큼 떨어져 있는지
나타내기에 편리함
- Video Monitor 의 좌표계
Mathematics for Computer Graphics
3D NonCartesian System
Cylindrical coordinates
z
P(,,z)
x axis
y axis
z axis
P(r,, )
x axis
y axis
z axis
r
Spherical coordinates
cosx siny
zz
sincosrx sinsinry
cosrz
Mathematics for Computer Graphics
Points
가장 기본적인 Output Primitive
0 차원으로 크기와 길이 측정 불가
순서쌍 (x,y) 나 vector 형식으로 표기
Raster Scan display 의 한 Pixel 차지
2D or 3D
Mathematics for Computer Graphics
Lines
Defined as a list of points(PolyLine)
RasterizationStairstep effect(jaggies)
Mathematics for Computer Graphics
Line Drawing Algorithm
Accomplished by calculating intermediate positions along the line path between two specified endpoint positions
12 xy Bresenham’s Line Algorithm
Mathematics for Computer Graphics
Why “y=mx” is not good for Graphics Applications
Defects in Nonparametric representation Explicit function 의 경우
1. Can only represent infinite lines, not finite line segments 2. Cannot represent vertical lines(m=) 3. Can only 2D lines, not 3D
Implicit function 의 경우
Redundant representation
Ex) 원호의 표현 :
bmxy
0),( yxf
122 yx x
y
Mathematics for Computer Graphics
Parametric Line Equation
P1
P2
y = Y1 + t * ( Y2 -Y1 )
x = X1 + t * ( X2 - X1 )
z = Z1 + t * ( Z2 - Z1 )
0.0 t 1.0
p = P1 + t * ( P2 - P1 )p
Mathematics for Computer Graphics
Parametric Line Equation
P1
P2
x = ( 1 - t ) * X1 + t * X2
0.0 t 1.0
Can Also be thought of as a blending function...
y = ( 1 - t ) * Y1 + t * Y2
z = ( 1 - t ) * Z1 + t * Z2
Mathematics for Computer Graphics
Linear Blending
q = Q1 + t * ( Q2 - Q1 )
You can linearly blend any two quantities with :
q = ( 1 - t ) * Q1 + t * Q2
Or, if you’d prefer :
Color, Shape, Location, Angle, Scale factors,….
Mathematics for Computer Graphics
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
Mathematics for Computer Graphics
Matrix Multiplication
Definition
PropertiesNot CommutativeAssotiativeDistributiveScalar multiplication
× = (i,j)
j-th column
i-th row
ml
nnm
l
n
kkjikij bac
1
ABC
BAAB
)()( BCACAB
BCABCBA )(
)()()( ABkkBABkA
Mathematics for Computer Graphics
Translation
y
x
T
TT
y
xP
y
xP ,
'
'',
x
y
x
y
(b)
(a)
P
P’
110
01
'
'y
x
T
T
y
x
y
x
y
x
Ty'y
,Tx'x
Mathematics for Computer Graphics
Scaling x’ = x · Sx , y’ = y · Sy
y
x
S
S
y
x
y
x
0
0
'
'
x’ x
P2
(xf, yf) : fixed pointx
y (xf,yf)P1
P3
x’ = xf + (x-xf) sx , y’ = yf + ( y- yf) sy
P)y,x(T)s,s(S)y,x(T'P ffyxff
1100
10
01
100
00
00
100
10
01
1
y
x
T
T
S
S
T
T
'y
'x
y
x
y
x
y
x
Mathematics for Computer Graphics
Rotation
P’ = R P
x = r cos , y = r sin
x’ = r cos ( + ) = r cos cos - r sin sin y’ = r sin ( + ) = r cos sin + r sin cos
x’= x cos - y sin , y’ = x sin + y cos
cossin
sincosR
죄표중심을 회전점으로각 만큼 회전
(x,y)
r
(x’,y’)
r
Mathematics for Computer Graphics
Homogeneous Coordinates
PTP '
In basic Transformations,
PSP 'PRP '
( Addition )
( Multiplication )
( Multiplication )Only Translation istreated differently
We hope to combine the multiplicative and translational terms for two-dimensional geometric transformations into a single matrix
representation for enabling the composite transformations such as,
PTSRTP )('
Mathematics for Computer Graphics
Extend the matrix
1100
10
01
1
'
'
y
x
t
t
y
x
y
x
1100
0cossin
0sincos
1
'
'
y
x
y
x
1100
00
00
1
'
'
y
x
s
s
y
x
y
x
We can solve this problem by extending 2 by2 matrix into 3 by 3 matrix
P2
(xf, yf) : fixed pointx
y (xf,yf) P1
P3
1100
10
01
100
00
00
100
10
01
1
y
x
T
T
S
S
T
T
'y
'x
y
x
y
x
y
x
Translation Rotation Scaling
Ex)
Mathematics for Computer Graphics
Homogeneous Space
y
x
z =3
z =2
z =1
P(3x1,3y1,3)
P(2x1,2y1,2)P(x1,y1,1)
P(hx1,hy1,h)= P(X,Y, h)
3D Representarion of homogeneous space
Any two dimensional point can be represented by one of the points along the ray in 3D space
Mathematics for Computer Graphics
Point at Infinity
The points with h=0 are called points at infinity,and this will not appear very often.
Ex) [ X Y h ] = [ 4 3 1]
h x* y* X Y
1 4 3 4 3
1/2 8 6 4 3
1/3 12 9 4 3
… … … … …
1/100 400 300 4 3
Mathematics for Computer Graphics
Point at Infinity(Cont’d)
0
1
yx
yx
Ex) The intersection point of two Parallel lines
00
01
11
11
1
yx
011
011
110
100
100
101
011
011
1001
1
yx
The resulting homogeneous coordinates [1 -1 0] represent the ‘pointof intersection’ for the two parallel lines, i.e. a point at infinity.
Mathematics for Computer Graphics
Point at Infinity(Cont’d)
Two Lines are intersect each otherif they are not parallel
Non-Homogeneous treatment !!
A
B
Mathematics for Computer Graphics
Determinant of Matrix For n 2, the Determinant of nn matrix A is,
and for a 2 by 2 matrix,
Ex)
※ if A is a triangular matrix, det A is the product of the entries on the main diagonal of A
n
jjkjk
kj AaA1
det)1(det
211222112221
1211 aaaaaa
aa
20
42det0
00
12det5
02
14det1det A
2)04(0)00(5)20(1
020
142
051
A
Mathematics for Computer Graphics
Properties of Determinants
Row OperationsLet A,B be a square matrix1) A 의 한 행의 실수배가 다른 row 에 더해져 B 를 만들었다면 , detB = detA2) A 의 두 행이 교환되어 B 를 생성했다면 , detB = -detA3) A 의 한 행이 k 배된 것이 B 라면 , detB = kdetA
Ex)
Column Operations
AAT detdet ))(det(det)det( BAAB
071
982
241
A
15))5(31(
500
230
241
detdet
A
071
500
241
230
500
241
500
230
241
Mathematics for Computer Graphics
Solving Linear Equations
Linear Equation
where, ajk and bj are known
Using Matrix Equation
11212111 ... bxaxaxa nn
22222121 ... bxaxaxa nn
nnnnnn bxaxaxa ...2211
...
BAX 1BAX
※Coefficient Matrix A 의 역행렬이 존재할 때만 성립
Mathematics for Computer Graphics
Inverse Matrix
If ad-bc = 0, then A is not invertible.
IAAIAA 11
• Definition
• 2 2 matrix 의 경우
• Properties
TT )A()A(AB)AB(A)A( 1111111
ac
bd
bcadA
11
dc
baA
Mathematics for Computer Graphics
Inverse Matrix
[ I A-1] 형태의 row reduction 이 존재하지 않으면 , A is not invertible.
• Algorithm for Finding A-1
834
301
210
A
1AI~IA : Row reduction
Ex)
140
001
010
430
210
301
100
001
010
834
210
301
100
010
001
834
301
210
~~IA
21223
142
23729
100
010
001
21223
001
010
100
210
301
143
001
010
200
210
301
//
//
~
//
~~
21223
142
237291
//
//
A
Mathematics for Computer Graphics
Gaussian Elimination
System 에서 한 행의 실수배를 다른 행에서 빼어 연립방정식의 차수를 줄여나가다 , 한 변수의 해가 구해지면 , 역으로 대입해 나머지 변수값을 구한다 .
• Elementary Row Operation 1. Multiply any row of the augmented matrix by a nonzero constant 2. Add a multiple of one row to a multiple of any other row 3. Interchange the order of any two rows
222
1132
1223
321
321
321
xxx
xxx
xxx
1874
2177
1223
32
32
321
xx
xx
xxx
4221
2177
1223
3
32
321
x
xx
xxx
312 123 x,x,x
Mathematics for Computer Graphics
Using Row Operation
2
11
12
122
321
213
3
2
1
x
x
x
2
11
12
122
321
213
|
|
|
b|A
13
12
23
13
2
11
12
122
321
213
R)(R
R)(R
23 4718
21
12
740
770
213
RR
42
21
12
2100
770
213
42
21
168
2100
0210
02163
42
21
189
2100
0210
0063
213
2
1
3
2
1
3
100
010
001
321
x,x,x,x,
222
1132
1223
321
321
321
xxx
xxx
xxx
Mathematics for Computer Graphics
Consistency of Linear System
1. Unknown variable 의 수에 비해 equation 의 수가 적을 때 No Unique solution (Infinite set of solution)
2. Unknown variable 의 수에 비해 equation 의 수가 많을 때 1) Consistent한 경우
: 구한 해가 남은 방정식에 대해서도 성립 (redundant)
2) Inconsistent 한 경우
(infinity)
(no solution)
1132
1223
321
321
xxx
xxx
6223 yx,yx
7223 yx,yx
Mathematics for Computer Graphics
Singular Matrix
• nn system 이 unique solution 을 갖지 않을 때 , 그 system의 coefficient matrix 를 singular 하다고 한다 .
• 일반적으로 coefficient matrix 를 triangulization 했을 때 ,diagonal 에 0 이 있으면 singular 하다 .
~
211141
7142
5321
1000
3780
5321
( No solution,Inconsistent )
( Infinity,redundant )
0000
3780
5321
Mathematics for Computer Graphics
Cramer’s Rule
For invertible nn matrix A and b, let Ai(b) be the matrix obtained from A by replacing column i by the vector b,
x of Ax=b is,
niA
bAx i
i ,...,2,1,det
)(det
],...,,...,[)( 1 ni ababA
column i
Ex)845
623
21
21
xx
xx
85
63)(,
48
26)(,
45
2321 bAbAA
detA=2 272
3024
det
)(det,20
2
1624
det
)(det 22
11
A
bAx
A
bAx
Mathematics for Computer Graphics
Iterative Method
,...
11
131321211 a
xaxaxabx nn ......,
...
12
121211122 a
xaxaxabx nn
- Gaussian Elimination 의 roundoff error 를 해결하기 위함- 처음에는 임의의 기대값을 해로 준 다음 error 가 최소가 될 때까지 다음 식에 반복 대입
427
1292
88
321
321
321
xxx
xxx
xxx
213
312
321
111022203331
286014305710
125012501
x.x..x
x.x..x
x.x.x
First Second Third Fourth Fifth Sixth Seventh Eighthx1
x 2
x 3
0 1.000 1.095 0.995 0.993 1.002 1.001 1.000 0 0.571 1.095 1.026 0.990 0.998 1.001 1.000 0 1.333 1.048 0.969 1.000 1.004 1.001 1.000