Graphics
Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Contents
Coordinate-Reference Frames
Vector Addition and Scalar Multiplication Scalar Product / Vector Product
Basis Vectors and the Metric Tensor
2D Cartesian Reference Frames / Polar Coordinates 3D Cartesian Reference Frames / Curvilinear Coordinates
Points and Vectors
CGVR
Orthonormal Basis Metric Tensor
Matrices
Scalar Multiplication and Matrix Addition Matrix Multiplication / Transpose Determinant of a Matrix / Matrix Inverse
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Coordinate Reference Frames
CGVR
Coordinate Reference Frames
Cartesian coordinate system
x, y, z 좌표축사용 , 전형적 좌표계
Non-Cartesian coordinate system
특수한 경우의 object 표현에 사용 . Polar, Spherical, Cylindrical 좌표계 등
cgvr.korea.ac.kr
Graphics Lab @ Korea University
2D Cartesian Reference System ď Ž
CGVR
2D Cartesian Reference Frames
y
x y x
Coordinate origin at the lower-left screen corner
cgvr.korea.ac.kr
Coordinate origin in the upper-left screen corner
Graphics Lab @ Korea University
Polar Coordinates
CGVR
가장 많이 쓰이는 Non-Cartesian System r θ
x = r cosθ , r = x2 + y2 ,
y = r sin θ y θ = tan −1 x
s = rθ
Elliptical Coordinates, Hyperbolic or Parabolic Plane Coordinates 등 원 이외에 Symmetry 를 가진 다른 2 차 곡선들로도 좌표계 표현 가능
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Why Polar Coordinates?
CGVR
Circle
2D Cartesian : 비균등 분포
Polar Coordinate y
x2 + y2 = r 2
x = r cos θ,
y
y = r sin θ
dθ dθ x
x
dx dx 균등하게 분포되지 않은 점들
Cartesian Coordinates cgvr.korea.ac.kr
연속된 점들 사이에 일정간격유지
Polar Coordinates Graphics Lab @ Korea University
3D Cartesian Reference Frames
CGVR
Three Dimensional Point
cgvr.korea.ac.kr
Graphics Lab @ Korea University
3D Cartesian Reference Frames
오른손 좌표계
대부분의 Graphics Package 에서 표준
왼손 좌표계
cgvr.korea.ac.kr
CGVR
관찰자로부터 얼마만큼 떨 어져 있는지 나타내기에 편 리함 Video Monitor 의 좌표계
Graphics Lab @ Korea University
3D Curvilinear Coordinate Systems
CGVR
General Curvilinear Reference Frame
Orthogonal coordinate system
Each coordinate surfaces intersects at right angles
x2 axis
x1 = const1
x3 axis
x3 = const3
x2 = const2
x1 axis
A general Curvilinear coordinate reference frame cgvr.korea.ac.kr
Graphics Lab @ Korea University
3D Non-Cartesian System
Cylindrical Coordinates z z axis
Spherical Coordinates z axis
P(ρ,θ,z)
θ ρ x axis
y axis
x = ρ cos θ y = ρ sin θ z =z cgvr.korea.ac.kr
CGVR
φ θ x axis
P(r,θ, ρ) r y axis
x = r cos θ sin φ y = r sin θ sin φ z = r cos φ Graphics Lab @ Korea University
Points and Vectors
CGVR
Point: 좌표계의 한 점을 차지 , 위치표시
Vector: 두 position 간의 차로 정의 V = P2 − P1 = ( x2 − x1 , y2 − y1 ) = (Vx , V y )
Magnitude 와 Direction 으로도 표기 P2
y2 y1
V
Vy α = tan Vx
P1
−1
x1 cgvr.korea.ac.kr
V = Vx2 +V y2
x2 Graphics Lab @ Korea University
Vectors
CGVR
3 차원에서의 Vector
z
V = Vx2 +V y2 +Vz2 Vy V V cos α = x , cos β = , cos γ = z |V | |V | |V |
cos 2 α + cos 2 β + cos 2 γ = 1
γ β α
V y
x
Vector Addition and Scalar Multiplication V1 + V2 = (V1x + V2 x , V1 y + V2 y , V1z + V2 z )
αV = (αVx ,αV y ,αVz ) cgvr.korea.ac.kr
Graphics Lab @ Korea University
Scalar Product
Definition V2 θ |V2|cosθ
CGVR
V1 ⋅V2 =| V1 || V2 | cos θ , 0 ≤ θ ≤ π V1
Dot Product, Inner Product 라고도 함
For Cartesian Reference Frame V1 ⋅ V2 = V1xV2 x + V1 yV2 y + V1zV2 z
Properties
Commutative V1 ⋅ V2 = V2 ⋅ V1
Distributive
cgvr.korea.ac.kr
V1 ⋅ (V2 + V3 ) = V1 ⋅ V2 + V1 ⋅ V3 Graphics Lab @ Korea University
Vector Product
Definition V1 × V2 u
CGVR
V2 θ
V1
V1 × V2 = u | V1 || V2 | sin θ , 0 ≤ θ ≤ π Cross Product, Outer Product 라고도 함
For Cartesian Reference Frame V1 × V2 = (V1 yV2 z − V1zV2 y ,V1zV2 x − V1xV2 z ,V1xV2 y − V1 yV2 x )
Properties
AntiCommutative V1 × V2 = −(V2 × V1 ) Not Associative V1 × (V2 × V3 ) ≠ (V1 × V2 ) × V3 V1 × (V2 + V3 ) = (V1 × V2 ) + (V1 × V3 ) Distributive
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Examples
CGVR
Scalar Product
Vector Product
(x2,y2) V2
θ (x0,y0)
V1
(x1,y1)
Angle between Two Edges
cgvr.korea.ac.kr
Normal Vector of the Plane
Graphics Lab @ Korea University
Basis Vectors
CGVR
Basis (or a Set of Base Vectors) Specify the coordinate axes in any reference frame Linearly independent set of vectors Any other vector in that space can be written as linear combination of them
u2
Vector Space
Contains scalars and vectors Dimension: the number of base vectors
cgvr.korea.ac.kr
u1 u3 Curvilinear coordinateaxis vectors Graphics Lab @ Korea University
Orthonormal Basis
CGVR
Normal Basis + Orthogonal Basis
u k ⋅ u k = 1,
for all k
u j ⋅ u k = 0, for all j ≠ k
Example
Orthonormal basis for 2D Cartesian reference frame
Orthonormal basis for 3D Cartesian reference frame
u x = (1, 0) u y = ( 0, 1)
u x = (1, 0, 0 ) u y = ( 0, 1, 0 ) u z = ( 0, 0, 1)
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Metric Tensor
Tensor
CGVR
Quantity having a number of components, depending on the tensor rank and the dimension of the space Vector – tensor of rank 1, scalar – tensor of rank 0
Metric Tensor for any General Coordinate System
Rank 2 Elements: g jk = u j ⋅ u k Symmetric: g jk = g kj
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Properties of Metric Tensors
CGVR
The Elements of a Metric Tensor can be used to Determine
Distance between two points in that space Transformation equations for conversion to another space Components of various differential vector operators (such as gradient, divergence, and curl) within that space
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Examples of Metric Tensors
CGVR
Cartesian Coordinate System u x = (1, 0) u y = ( 0, 1)
1, if j = k g jk = 0, otherwise Polar Coordinates
u r = u x cos θ + u y sin θ ,
uθ = −u x r sin θ + u y r cos θ 1 0 g= 2 0 r cgvr.korea.ac.kr
Graphics Lab @ Korea University
Matrices
CGVR
Definition
A rectangular array of quantities
a11 a A = 21 : am1
a12 ... a1n a22 ... a2 n : : am 2 ... amn
Scalar Multiplication and Matrix Addition
a11 A = a21
cgvr.korea.ac.kr
a12 b11 b12 , B = a22 b21 b22
a11 + b11 A + B = a21 + b21 ka11 kA = ka21
a12 + b12 a22 + b22
ka12 ka22 Graphics Lab @ Korea University
Matrix Multiplication
Definition
j-th column
C = AB n
cij = ∑ aik bkj
i-th row
×
l
k =1
CGVR
Properties
m
m
=
(i,j)
l n
n
AB ≠ BA Associative ( AB )C = A( BC ) Distributive A( B + C ) = AB + BC Scalar Multiplication ( kA) B = A( kB ) = k ( AB )
Not Commutative
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Matrix Transpose
Definition
Interchanging rows and columns
1 4 1 2 3 2 5, = 4 5 6 3 6 T
CGVR
[a
b c]
T
a = b c
Transpose of Matrix Product
( AB ) T cgvr.korea.ac.kr
= BT A T
Graphics Lab @ Korea University
Determinant of Matrix
CGVR
Definition
For a square matrix, combining the matrix elements to product a single number
2 × 2 matrix
a11 a12 = a11a22 − a12 a21 a21 a22 Determinant of n×n Matrix A (n ≥2) n
det A = ∑ (−1) j + k a jk det A jk j =1
cgvr.korea.ac.kr
Graphics Lab @ Korea University
Inverse Matrix
Definition
−1
−1
AA = I
A A= I
Non-singular matrix
CGVR
If and only if the determinant of the matrix is non-zero
2 × 2 matrix a b A= c d
1 d − b A = ad − bc − c a −1
Properties
( A − 1 )− 1 = A cgvr.korea.ac.kr
( AB )−1 = B −1 A−1
( AT )−1 = ( A−1 )T Graphics Lab @ Korea University