Download - Math Primer for CG
![Page 1: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/1.jpg)
Math Primer for CG
Ref: Interactive Computer Graphics, Chap. 4, E. Angel
![Page 2: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/2.jpg)
Contents
Scalar, Vector, PointChange of BasisFrameChange of FrameAffine Sum, Convex Combination, Convex Hull, …Case Study: shooting game
![Page 3: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/3.jpg)
Introduction
Three basic data types in CG: scalars, points, and vectors scalar: not a geometric type per se; used in
measurement point: a location in space; exist regardless
of any coordinate system vector: any quantity with direction and
magnitude; does not have fixed location
Examine these concepts in a mathematically more rigorous way…
![Page 4: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/4.jpg)
Scalars: Live in Real Space
Two fundamental operations are defined between pairs: Addition,
multiplication ClosureS, S, ·S
SCommutative
··
Associative····
Distributive···
Additive & multiplicative inverse·
![Page 5: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/5.jpg)
Real Analysis
The study of real numbers…If you are interested, see Analysis WebNotes:
http://www.math.unl.edu/~webnotes/contents/chapters.htm
![Page 6: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/6.jpg)
Vectors: Live in Vector Space
Two kinds of entities: Scalar, vector
Two operations and corresponding geometric interpretations: v-v addition(head-tail) scalar-v multiplication(scaling of vector)
Properties Closureu,vV, u+vV
Commutativeu+v=v+u
Associative u+(v+w)=(u+v)+w
Distributive (u+v)=u+v )u=u+u
![Page 7: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/7.jpg)
Vector Space (cont)
Linear combinationu=1u1+2u2+…+nun
Linear independentOnly set of scalars such th
atu=1u1+2u2+…+nun
is zero 1=2=…=n=0
Basis a set of linearly indepen
dent vectors that span the space
![Page 8: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/8.jpg)
Vector Space: change of basis
represent any vector uniquely in a basis
change of basis
332211 uuuu
3
2
1
321
uuuu
3332321313
3232221212
3132121111
vvvu
vvvu
vvvu
332313
322212
312111
321321
vvvuuu
3
2
1
321332211
vvvvvvu
3
2
1
3
2
1
332313
322212
312111
3
2
1
321
3
2
1
332313
322212
312111
321
vvvvvv
![Page 9: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/9.jpg)
Example
3
2
1
3
2
1
321 eeeu
3213
212
11
1
1
1
0
1
1
0
0
1
eeev
eev
ev
100
110
011
100
110
111
100
110
111
321
1
321321
321321
vvv
vvveee
eeevvv
3
1
1
3
2
1
100
110
011
321321 vvvvvvu
New Basis
![Page 10: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/10.jpg)
Points: Live in Affine SpaceVector space lacks Location, distance, …
Concept of coordinate system (frame) Reference point: origin Frame: origin + basis
defines position in space
Add another entity to vector spaces Point
New operations Point – Point Vector Point + Vector Point
(translation)
Note that the following are not defined: point addition multiplication of
scalar & point
![Page 11: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/11.jpg)
Affine Space: change of framesRepresent point in a frame
Change of frame
0332211 PuuuP
0332211 QvvvP
03432421410
3332321313
3232221212
3132121111
QvvvP
vvvu
vvvu
vvvu
100043332313
42322212
41312111
03210321
QvvvPuuu
1110003
2
1
03213
2
1
43332313
423222112
413121111
0321
QvvvQvvv
1110003
2
1
3
2
1
43332313
423222112
413121111
1110003
2
1
3
2
1
43332313
423222112
413121111
![Page 12: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/12.jpg)
Euclidean Space
Supplement vector space with the notion of distanceNew operation Inner (dot)
product
S u,v,wVu · v=v · u(u+v) · w=u · w + v ·
wv · v>0 (v0)0 · 0=0u · v=0 u and v are ortho
gonal|v|=(v · v)½
u · v=|u||v| cos
![Page 13: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/13.jpg)
Summary: Mathematical Spaces
Real Space(Scalar)
Vector Space(Scalar, Vector)
Euclidean Space(Scalar, Vector)
[distance]
Affine Space(Scalar, Vector, Point)
[location]
![Page 14: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/14.jpg)
Affine Sum
In affine space, point addition is only defined in the following case:
QRP
QRQvQP
)1(
)(
1 where 2121 QRP
Q
R
P()Point addition is allowed only if their weights add up to one
![Page 15: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/15.jpg)
Affine Sum (cont)More generally,
Convex Combination A particular affine sum where weights are non-n
egative
1 where i
ii
iiPP 1 where i
ii
iiPP
0 and 1 where ii
ii
iiPP 0 and 1 where ii
ii
iiPP
![Page 16: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/16.jpg)
Convex Hull
![Page 17: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/17.jpg)
Now, how to apply these math
Besides change of basis/frame…
![Page 18: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/18.jpg)
Ex: Parametric Equation of a Line
Q
R
S() 10 ,)1()( RQS
Q
R
S() RRQS ,)1()(
![Page 19: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/19.jpg)
Ex: Plane, Triangle, Parallelogram
Q
R
S()P
T()
10 ,10 ,10
10 and 10
,
R
u
v
RQP
PRPQP
vuPT
PRvPQu
)1(
)()(
),(
;
(infinite) Plane
Parallelogram
Triangle
![Page 20: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/20.jpg)
Ex: Homogeneous Coordinates
A unified representation scheme in affine space for points and vectorsChange of Frame: subsume change of basis
![Page 21: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/21.jpg)
Affine Space: coordinate system
fixing the origin of the vectors of coordinate system at P0
4x1 “vector”: Unified vector & point
representation
homogeneous coordinate distinguish point &
vector 4x4 matrix algebra for
change in frames
0332211 PuuuP
13
2
1
0321
PuuuP
03
2
1
0321
Puuuu
Point: [1 2 3 1]Frame: [u1 u2 u3 P0]
Vector: [1 2 3 0]Frame: [u1 u2 u3 P0]
![Page 22: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/22.jpg)
Ex: Shooting (AABB)
Intersection can be checked using 3D Sutherland algorithm
0p
0p
![Page 23: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/23.jpg)
Cohen-Sutherland Line-Clipping Algorithm
Trivially acceptTrivially rejectclipping
![Page 24: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/24.jpg)
Ex: Shooting (OBB)
Change of frame then apply Sutherland algorithm in the local frame
0p
0p
![Page 25: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/25.jpg)
Ex: Ray-Triangle Intersection
),,(t for triple ),()(
Solve
10 ,10 ,10
,)1(),(
Triangle
0,)(
:Ray
210
0
tqtp
qqqq
tutptp
u
v
w
0p
0q
1q
2q
![Page 26: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/26.jpg)
Ex: Shooting (discrete version)
v
w
0p0q
0p
),,(t for triple ),()(
Solve
10,10,10
,)1(),(
Triangle
)1()(
:PathBullet
)( );(
210
00
0000
tqtp
qqqq
ptpttp
ttpptpp
![Page 27: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/27.jpg)
Ex: Shooting (continuous version)
0p
0p0q
0q
2q
1q
2q
1q
),,(t for triple ),,()(
Solve
10 ,10 ,10
)1()(
)1()(
)1()(
)()()()1(),(
:motion)(in Triangle
10 ,)1()(
:PathBullet
,,; :)(After
,,; :)( Before
222
111
000
210
00
21000
21000
ttqtp
qtqttq
qtqttq
qtqttq
tqtqtqq
tptpttp
qqqptt
qqqpt
![Page 28: Math Primer for CG](https://reader036.vdocuments.site/reader036/viewer/2022062315/56815ad9550346895dc8a4d4/html5/thumbnails/28.jpg)
Exercise
Convex Hull: prove convex combination yields the shape you imagine