Professional Documents
Culture Documents
CHAPTER 3
Coordinate Systems
Homogeneous coordinate
v = [α1 α2 α3 0 ]T
p = [β1 β2 β3 1 ]T
u1 = γ11v1+γ12v2+γ13v3
u2 = γ21v1+γ22v2+γ23v3
u3 = γ31v1+γ32v2+γ33v3
a=MT b
Affine Transformations
Translation
T=
Scaling
Shearing
x’ = x + y cot θ, y’ = y, z’ = z
Inverses
Translation: T-1(dx, dy, dz) = T(-dx, -dy, -dz)
Rotation: R -1(θ) = R(-θ)= RT(θ)
Scaling: S-1(sx, sy, sz) = S(1/sx, 1/sy, 1/sz)
Quaternions:
q = s + xi+ yj+ zk
q =(s, x, y, z)
q =(s, v)
i2=j2=k2= ijk = −1
ij = k, jk = I, ki = j, ji = -k, kj = -I, ik = -j
q + q’= (s, v)+(s’, v’)= (s + xi+ yj+ zk)+(s’+ x’i+ y’j+ z’k)= =(s + s’, v + v’)
qq’=(ss’-vv’,v x v’+ sv’+s’v)
q-1=(s,-v)/||q||2
quaternions to matrices
q =(s, x, y, z)
matrices to quaternions
q=(s,x,y,z)
Vertex List
Edge List
CHAPTER 4 VIEWING
Orthogonal Viewing
glOrtho(left,right,bottom,top,near,far)
OpenGL Perspective
glFrustum(left,right,bottom,top,near,far)
gluPerpective(fovy, aspect, near, far)// aspect=w/h
Move center to origin: (chuyển tâm hình hộp về gốc tọa độ)
T(-(left+right)/2, -(bottom+top)/2,-(-near-far)/2))
Scale to have sides of length 2(scale hình hộp về khối vuông cạnh = 2 từ (-1,-1,-1) đến(1,1,1) )
Near plane: z = -near → z’’ = -1
Far plane z = -far → z’’ = +1
S(2/(left-right),2/(top-bottom),2/(-near- (-far)))
P = MorthST
Oblique Normalization
P = Morth H(θ,φ)
P = Morth STH(θ,φ)
glLightfv(.):light intensities
Shading
Flat shading (vertices in a same polygon have a same color)
Smooth shading (Interpolate vertex shades across each polygon):
Gouraud shading
Phong shading
Gouraud Shading
Find average normal at each vertex (vertex normals)
Apply modified Phong model at each vertex
Interpolate vertex shades across each polygon
Phong Shading
Find vertex normals
Interpolate vertex normals across edges
Interpolate edge normals across polygon
Apply modified Phong model at each fragment