simple mathematics for graphics. volumes from silhouettes start with collection of “calibrated”...
TRANSCRIPT
![Page 1: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/1.jpg)
Simple Mathematics Simple Mathematics for graphicsfor graphics
Simple Mathematics Simple Mathematics for graphicsfor graphics
![Page 2: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/2.jpg)
Volumes from Silhouettes
• Start with collection of “calibrated” images
![Page 3: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/3.jpg)
Volumes from Silhouettes
Cup on turntable example
![Page 4: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/4.jpg)
3D Curves from Edges• “Feature-based” stereo matching
![Page 5: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/5.jpg)
3D Curves from Edges• Extract extremal and internal
edges
![Page 6: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/6.jpg)
3D Curves from Edges• Match curves along epipolar lines
viewing rayviewing rayepipolar planeepipolar plane
epipolar lineepipolar line
![Page 7: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/7.jpg)
What is Computer Graphics?
• Using a computer to generate an image from a representation.
Model Imagecomputer
![Page 8: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/8.jpg)
Representations• How do we represent an object?
– Points • p = [x y z]
– Mathematical Functions• X2 + Y2=R2
– Polygons (most commonly used)• Points• Connectivity
![Page 9: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/9.jpg)
Representing Points and Vectors
• A 3D point p = [ x y z ]– Represents a location with respect to
some coordinate system
• A 3D vector v = [ x y z]– Represents a displacement from a
position
![Page 10: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/10.jpg)
Linear Algebra• Why study Linear Algebra?
– Deals with the representation and operations commonly used in Computer Graphics
![Page 11: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/11.jpg)
Vector Spaces• Consists of a set of elements,
called vectors and two operations that are defined on them, addition and multiplication
![Page 12: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/12.jpg)
Vector Addition• Given V = [X Y Z] and W = [A B C]
– V+W = [X+A Y+B Z+C]
• Properties of Vector addition– Commutative: V+W=W+V– Associative (U+V)+W = U+(V+W)– Additive Identity: V+0 = V– Additive Inverse: V+W = 0, W=-V
![Page 13: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/13.jpg)
Parallelogram Rule• To visualize what a vector addition
is doing, here is a 2D example:
V
W
V+W
![Page 14: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/14.jpg)
Vector Multiplication• Given V = [X Y Z] and a Scalar s and t
– sV = [sX sY sZ]
• Properties of Vector multiplication• Associative: (st)V = s(tV)• Multiplicative Identity: 1V = V• Scalar Distribution: (s+t)V = sV+tV• Vector Distribution: s(V+W) = sV+sW
![Page 15: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/15.jpg)
Dot Product and Distances
• Given u = [x y z] and v = [a b c]– v•u = ax+by+cz
• The Euclidean distance of u from the origin is sqrt( x2+y2+z2) and is denoted by ||u||– Notice that ||u|| = sqrt(u•u)
• The Euclidean distance between u and v is sqrt( (x-a) 2+(y-b) 2+(z-c) 2) ) and is denoted by || u-v ||
![Page 16: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/16.jpg)
Properties of the Dot Product
• Given a vector u, v, w and scalar s– The result of a dot product is a
SCALAR value– Commutative: v•w = w•v– Non-degenerate: v•v=0 only when
v=0– Bilinear: v•(u+sw)=v•u+s(v•w)
![Page 17: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/17.jpg)
Angles and Projection• Alternative view of the dot product• v•w=||v|| ||w|| cos() where is the
angle between v and w• If v is a unit vector (||v|| = 1) then if
we perpendicularly project w onto v can call this newly projected vector u then ||u|| = v•w
w
vu
![Page 18: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/18.jpg)
Matrices• A compact way of representing operations on
points and vectors• 3x3 Matrix A looks like
• a(i,j) refers to the element of matrix A
333231
232221
131211
aaa
aaa
aaa
![Page 19: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/19.jpg)
Matrix Multiplication• If A is an nk matrix and B is a kp then
AB is a np matrix with entries c(i,j)where– c(i,j)=a(i,s)b(s,j)
• Alternatively, if we took the rows of A and columns of B as individual vectors then
• c(i,j)=Ai•Bj where the subscript refers to the row and column, respectively
![Page 20: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/20.jpg)
Matrix Multiplication Properties
• Associative: (AB)C = A(BC)• Distributive: A(B+C) = AB+AC• Multiplicative Identity: I= diag(1)
(square matrix• NOT commutative: ABBA
![Page 21: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/21.jpg)
Determinant of a Matrix
• Defined on a square matrix (nxn)
• Where A1i determinant of (n-1)x(n-1) submatrix A gotten by deleting the first row and the ith column
n
i ii AAA
1 11)1(det
![Page 22: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/22.jpg)
Recursive Definition!!• The basis case• det of a 2x2 matrix is defined to
be ad-bc where
db
ca
![Page 23: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/23.jpg)
Uses of the Determinant?
• Linear Independence of columns in a matrix
• Cross Product– Given 2 vectors v=[v1 v2 v3], w=[w1
w2 w3], the cross product is defined to be the determinant of
1221
3113
2332
321
321
wvwv
wvwv
wvwv
www
vvv
kji
![Page 24: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/24.jpg)
Cross Product Properties
• The Cross Product of v and w is denoted by vw
• Is a VECTOR, perpendicular to the plane defined by v and w
• ||vw||=||v|| ||w|| |sin| is the angle between v and w
• vw=-(wv)v
wvw
![Page 25: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/25.jpg)
Matrix Transpose and Inverse
• The Transpose of a matrix A, denoted by AT is defined as aij=aji (exchanging the rows and columns)
• If A and B are nxn matrices and AB=BA=I then B is the inverse of A, denoted by A-1
• (AB)-1=B-1A-1 same applies for transposeT
MM T 11
![Page 26: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/26.jpg)
Methods for finding the Inverse
• Explicit Methods– Gaussian-Jordan Elimination
• Create the Augmented matrix [A|I] and reduce the left side to the identity using elementary row operations and the right hand side will be the inverse. ie. [I|A-1]
– Cramer’s Rule• Solve for A’ where a’
ij=det(submatrix(Aij))
• A-1=(1/det(A))(A’)T
![Page 27: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/27.jpg)
Implicit Methods• Instead of explicitly calculating A-1, there
are techniques that solve equations of the form Ax=b (system of linear equations).
• Clearly x=A-1b but we do not need to explicitly calculate A-1 to calculate x.– LU Decomposition– QR Factorization– Singular Value Decomposition (SVD)– Conjugate Gradient if sparse…
![Page 28: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/28.jpg)
Transformations• Why use transformations?
Create object in convenient coordinates
Reuse basic shape multiple times Hierarchical modeling System independent Virtual cameras
![Page 29: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/29.jpg)
Translation
z
y
x
z
y
x
t
t
t
= +
z
y
x
tttT zyx ),,(
z
y
x
z
y
x
t
t
t
= +
'
'
'
z
y
x
![Page 30: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/30.jpg)
Properties of Translation
v=v)0,0,0(T
=v),,(),,( zyxzyx tttTsssT
=
=v),,(1zyx tttT
v),,(),,( zyxzyx tttTsssT v),,(),,( zyxzyx sssTtttT
v),,( zzyyxx tststsT
v),,( zyx tttT
![Page 31: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/31.jpg)
Rotations (2D)
sin
cos
ry
rx
cos)sin(sin)cos('
sin)sin(cos)cos('
rry
rrx
)sin('
)cos('
ry
rx
cossinsincos)sin(
sinsincoscos)cos(
cossin'
sincos'
yxy
yxx
yx,
',' yx
x
y
![Page 32: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/32.jpg)
Rotations 2D• So in matrix notation
y
x
y
x
cossin
sincos'
'
![Page 33: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/33.jpg)
Rotations (3D)
100
0cossin
0sincos
)(
cos0sin
010
sin0cos
)(
cossin0
sincos0
001
)(
z
y
x
R
R
R
![Page 34: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/34.jpg)
Properties of RotationsIRa )0(
)()()()( aaaa RRRR
)()()( aaa RRR
)()()(1 Taaa RRR
)()()()( abba RRRR order matters!
![Page 35: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/35.jpg)
Combining Translation & Rotation
)1,1(T
)45( R
)45( R
)1,1(T
![Page 36: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/36.jpg)
Combining Translation & Rotation
Tvv'
RTR
TR
R
vv
vv
vv
''
)(''
'''
vv R'
TR
T
vv
vv
''
'''
![Page 37: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/37.jpg)
Scaling
zs
ys
xs
z
y
x
z
y
x
'
'
'
z
y
x
zyx
s
s
s
sssS
00
00
00
),,(
Uniform scaling iff zyx sss
![Page 38: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/38.jpg)
Homogeneous Coordinates
z
y
x
w
Z
Y
X
can be represented as
wherew
Zz
w
Yy
w
Xx ,,
![Page 39: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/39.jpg)
Translation Revisited
11000
100
010
001
),,(z
y
x
t
t
t
z
y
x
tttTz
y
x
zyx
![Page 40: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/40.jpg)
Rotation & Scaling Revisited
11000
000
000
000
),,(z
y
x
s
s
s
z
y
x
sssSz
y
x
zyx
11000
0cossin0
0sincos0
0001
)(z
y
x
z
y
x
Rx
![Page 41: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/41.jpg)
Combining Transformations
vv
vvvv
vvv
vv
M
TRSTRT
RSR
S
'''
''''''
'''
'
where TRSM
![Page 42: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/42.jpg)
Transforming Tangents
t
qp
qp
qpt
qpt
M
M
MM
)(
'''
![Page 43: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/43.jpg)
Transforming Normals
nnn
nn
nn
tntn
tn
tn
tn
TT
T
TT
TT
T
T
T
MM
M
M
M
M
11'
'
'
'
0'
0''
0
![Page 44: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/44.jpg)
Rotations about an arbitrary axis
Rotate by around a unit axis r
r
![Page 45: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/45.jpg)
• We can view the rotation around an arbitrary axis as a set of simpler steps
• We know how to rotate and translate around the world coordinate system
• Can we use this knowledge to perform the rotation?
![Page 46: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/46.jpg)
Rotation about an arbitrary axis
• Translate the space so that the origin of the unit vector is on the world origin
• Rotate such that the extremity of the vector now lies in the xz plane (x-axis rotation)
• Rotate such that the point lies in the z-axis (y-axis rotation)
• Perform the rotation around the z-axis• Undo the previous transformations
![Page 47: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/47.jpg)
Rotation about an arbitrary axis
• Step 1Rotate x-axis
x
y
z
(a,b,c)
x
![Page 48: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/48.jpg)
Closer Look at Y-Z Plane
• Need to rotate degrees around the x-axis
y
z
![Page 49: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/49.jpg)
Equations for
||)1,0,0(||||),,0(||
)1,0,0(),,0()cos(
||),,0(||||)1,0,0(||
||),,0()1,0,0(||)sin(
cb
cb
cb
cb
![Page 50: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/50.jpg)
Rotation about the Y-axis
• Using the same analysis as before, we need to rotate degrees around the Y-axis
y
z
x
![Page 51: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/51.jpg)
Rotation about the Z-axis
• Now, it is aligned with the Z-axis, thus we can simply rotate degrees around the Z-axis.
• Then undo all the transformations we just did
![Page 52: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/52.jpg)
Equation summary
c
b
a
TRRRRRT
c
b
a
rot xyzyxaxis )()()()()(
'
'
'
)( 111
![Page 53: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/53.jpg)
Deformations
Transformations that do not preserve shape Non-uniform scaling Shearing Tapering Twisting Bending
![Page 54: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/54.jpg)
Shearing
11000
01
01
01
1
'
'
'
z
y
x
ss
ss
ss
z
y
x
zyzx
yzyx
xzxy
0
0
0
1
zyzx
yzyx
xz
xy
ss
ss
s
s
x
y
x
y
![Page 55: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/55.jpg)
Tapering
11000
0)(00
00)(0
0001
1
'
'
'
z
y
x
xf
xf
z
y
x
Image courtesy of Watt, 3D Computer Graphics
![Page 56: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/56.jpg)
Twisting
11000
0))(cos(0))(sin(
0010
0))(sin(0))(cos(
1
'
'
'
z
y
x
yy
yy
z
y
x
Image courtesy of Watt, 3D Computer Graphics
![Page 57: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/57.jpg)
Bending
11000
0)()(0
0)()(0
0001
1
'
'
'
z
y
x
ykyh
ygyf
z
y
x
Image courtesy of Watt, 3D Computer Graphics
![Page 58: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/58.jpg)
What have we seen so far?
• Basic representations (point, vector)• Basic operations on points and vectors
(dot product, cross products, etc.)• Transformation – manipulative
operators on the basic representation (translate, rotate, deformations) – 4x4 matrices to “encode” all these.
![Page 59: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/59.jpg)
Why do we need this?• In order to generate a picture from
a model, we need to be able to not only specify a model (representation) but also manipulate the model in order to create more interesting images.
![Page 60: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/60.jpg)
Overview• The next set of slides will deal with
the other half of the process (at least in a simplistic fashion)
• From a model, how do we generate an image
Model Imagecomputer
![Page 61: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/61.jpg)
Accumulation of Transformations
baseT
)()()(
)()(
RRTRMM
RTRMM
TM
basearmhand
basebasearm
basebase
base
arm hand
Example: Robot arm
![Page 62: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/62.jpg)
Orthonormal Coordinates
Iff u and v are orthonormal:
Tyx
yx
Mvv
uu
M
100
0
01
100100
10
01
100
0
011 vr
ur
yx
yx
y
x
yx
yx
vv
uu
r
r
vv
uu
TM
![Page 63: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/63.jpg)
Coordinate Systems Object coordinates World coordinates Camera coordinates Normalized device coordinates Window coordinates
![Page 64: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/64.jpg)
Object CoordinatesConvenient place to model the
object
O
![Page 65: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/65.jpg)
World CoordinatesCommon coordinates for the scene
O
O
W
![Page 66: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/66.jpg)
Camera CoordinatesCoordinate system with the camera
in a convenient pose
u
v
n
1000
nr
vr
ur
zyx
zyx
zyx
nnn
vvv
uuu
M
![Page 67: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/67.jpg)
Normalized Device Coordinates
Device independent coordinatesVisible coordinate usually range
from:
11
11
11
z
y
x
![Page 68: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/68.jpg)
Window CoordinatesAdjusting the NDC to fit the window
0
0
2)1(
2)1(
yheight
yy
xwidth
xx
ndw
ndw
),( 00 yx is the lower left of the window
width
height
![Page 69: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/69.jpg)
Perspective ProjectionTaking the camera coordinates to
NDC
z
x
near
![Page 70: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/70.jpg)
Perspective Projection
z
x
near'p
p
z
xnearx
z
x
near
x
'
'
![Page 71: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/71.jpg)
Rasterization
Array of pixels
0
0 1 2 3 4
1
2
3
![Page 72: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/72.jpg)
Rasterizing LinesGiven two endpoints, find the pixels that make up the line.
),(),,( 1100 yxyx
![Page 73: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/73.jpg)
Rasterizing LinesRequirements
1. No gaps
2. Minimize error (distance to line)
![Page 74: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/74.jpg)
Rasterizing Lines
Line(int x0, int y0, int x1, int y1) float dx = x1 – x0; float dy = y1 – y0; float m = dy/dx; float x = x0, y= y0;
for(x = x0; x <= x1; x++) setPixel(x,round(y)); y = y+m;
Assume –1 < m < 1, x0 < x1
![Page 75: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/75.jpg)
Rasterizing LinesProblems with previous algorithm
1. round takes time2. uses floating point arithmetic
![Page 76: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/76.jpg)
Midpoint Algorithm
NE
E
P=(x,y)
MQ
If Q <= M, choose E. If Q > M, choose NE
![Page 77: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/77.jpg)
Implicit Form of a Line
dxBcdxbdya
dxBydxxdy
Bxdx
dyycbyax
0
0
Implicit form Explicit form
Positive below the lineNegative above the lineZero on the line
![Page 78: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/78.jpg)
Decision Function
cybxayxFd
cybxayxFd
)()1(),1(
),(
2
1
2
1
Choose NE if d > 0Choose E if d <= 0
![Page 79: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/79.jpg)
Incrementing d
cybxayxFdnew )()2(),2(2
1
2
1
If choosing E:
But:
cybxayxFdold )()1(),1(2
1
2
1
So:
Eaddd oldnewinc
![Page 80: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/80.jpg)
Incrementing d
cybxayxFdnew )()2(),2(2
3
2
3
If choosing NE:
But:
cybxayxFdold )()1(),1(2
1
2
1
So:
NEbaddd oldnewinc
![Page 81: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/81.jpg)
Initializing d
2
1
2
1
2
1
2
1
00
0000 )()1(),1(
ba
bacybxa
cybxayxFd
Multiply everything by 2 to remove fractions (doesn’t change the sign)
![Page 82: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/82.jpg)
Midpoint AlgorithmLine(int x0, int y0, int x1, int y1) int dx = x1 – x0, dy = y1 – y0; int d = 2*dy-dx; int delE = 2*dy, delNE = 2*(dy-dx); int x = x0, y = y0; setPixel(x,y);
while(x < x1) if(d<=0) d += delE; x = x+1; else d += delNE; x = x+1; y = y+1; setPixel(x,y);
Assume 0 < m < 1, x0 < x1
See: Bresenham Algorithm
![Page 83: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/83.jpg)
Limitations?• The midpoint line algorithm
assumes that the slope (m) is between 0 and 1
• This implies that this algorithm only applies to lines in region 1
• Extending to other regions left as an a programming assignment
1
23
4
5
67
8
![Page 84: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/84.jpg)
Anti-aliasing LinesLines appear jaggy
Sampling is inadequate
![Page 85: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/85.jpg)
Anti-aliasing LinesTrade intensity resolution for spatial resolution
![Page 86: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/86.jpg)
Anti-aliasing LinesLine(int x0, int y0, int x1, int y1) float dx = x1 – x0; float dy = y1 – y0; float m = dy/dx; float x = x0, y= y0;
for(x = x0; x <= x1; x++) int yi = floor(y); float f = y – yi; setPixel(x,yi, 1-f); setPixel(x,yi+1, f); y = y+m;
Assume 0 < m < 1, x0 < x1
![Page 87: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/87.jpg)
Putting it all together!!• Take your representation (points) and
transform it from Object Space to World Space• Take your World Space point and transform it
to Camera Space• Perform the remapping and projection onto the
image plane in Normalized Device Coordinates• Perform this set of transformations on each
point of the polygonal object• “Connect the dots” through line rasterization
![Page 88: Simple Mathematics for graphics. Volumes from Silhouettes Start with collection of “calibrated” images](https://reader035.vdocument.in/reader035/viewer/2022062423/56649e375503460f94b26ec0/html5/thumbnails/88.jpg)
IntuitivelyObjectSpace
WorldSpace
CameraSpace
Rasterization