Mathematics for Graphics
description
Transcript of Mathematics for Graphics
![Page 1: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/1.jpg)
Mathematics for Graphics
![Page 2: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/2.jpg)
2
Objectives Introduce the elements of geometry
Scalars Vectors Points
Develop mathematical operations among them in a coordinate-free manner
Define basic primitives Line segments Polygons
![Page 3: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/3.jpg)
3
3D Cartesian co-ordinates
![Page 4: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/4.jpg)
4
Basic Elements Geometry is the study of the relationships among objects in an n-dimensional space
In computer graphics, we are interested in objects that exist in three dimensions
Want a minimum set of primitives from which we can build more sophisticated objects
We will need three basic elements Scalars Vectors Points
![Page 5: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/5.jpg)
5
Scalars Need three basic elements in geometry
Scalars, Vectors, Points Scalars can be defined as members of sets which can be combined by two operations (addition and multiplication) obeying some fundamental axioms (associativity, commutivity, inverses)
Examples include the real and complex number systems under the ordinary rules with which we are familiar
Scalars alone have no geometric properties
![Page 6: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/6.jpg)
6
Vectors And Point We commonly use vectors to represent:
Points in space (i.e., location) Displacements from point to point Direction (i.e., orientation)
But we want points and directions to behave differently Ex: To translate something means to move it
without changing its orientation Translation of a point = different point Translation of a direction = same direction
![Page 7: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/7.jpg)
7
Vectors Physical definition: a vector is a quantity with two
attributes Direction Magnitude
Examples include Force Velocity Directed line segments
Most important example for graphics Can map to other types
v
![Page 8: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/8.jpg)
8
Vector A quantity characterized by a magnitude and direction Can be represented by an arrow, where magnitude is the
length of the arrow and the direction is given by slope of the line
12
v
2
1
v
Y
X
A vector in 2D
2
2
2
Y
X
Z
v
222
v
A vector in 3D
P (2, 1)
O (0, 0)
v = OP = จุดปลาย จุดต้น – = P-O
![Page 9: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/9.jpg)
9
Vector Operations Every vector has an inverse
Same magnitude but points in opposite direction Every vector can be multiplied by a scalar There is a zero vector
Zero magnitude, undefined orientation The sum of any two vectors is a vector
Use head-to-tail axiom
v -v vv
u
w
![Page 10: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/10.jpg)
10
Vectors Lack Position These vectors are identical
Same direction and magnitude
Vectors spaces insufficient for geometry Need points
![Page 11: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/11.jpg)
11
Vector Addition Addition of vectors follows the parallelogram law
in 2D and the parallelepiped law in higher dimensions:
vuvu
975
654
321
![Page 12: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/12.jpg)
12
Vector Multiplication by a Scalar Multiplication by a scalar scales the vectors
length appropriately (but does not affect direction):
1.5v
v
5.1
315.125.1
12
5.1
464
232
2
![Page 13: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/13.jpg)
13
Subtractionu
-v
u
-v
-v
Can be seen as an addition of
u + (-1v)
vuvu
24
25
41
v
Inverse vector?
![Page 14: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/14.jpg)
14
Vector Magnitude The magnitude or “norm” of a
vector of dimension 3 is given by the standard Euclidean distance metric:
How about dimension n?
222212
212
212 321
vvvzzyyxx v
11131131
222 v
5254343 22 v
2
131
v
5
3
4
43
v
2D example 3D example
3
2
1
12
12
12
1
1
1
2
2
2
1221
vvv
zzyyxx
zyx
zyx
PPPPv
P2
P1
v
![Page 15: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/15.jpg)
15
Unit Vectors Vectors of length 1 are often termed unit vectors (a.k.a.
normalised vectors). When we only wish to describe direction we use normalised
vectors – often to avoid redundancy For this and other reasons, we often need to normalise a
vector:
e.g.v
vvv
22221
1ˆn
vvv
3015.9045.3015.
111113111
111
131
111
111ˆ v
vvv
131
vv̂v
![Page 16: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/16.jpg)
16
Examples Suppose point P1(-1,-3) and P2(2,-7). Find
Vector v obtained from these two points Norm of vector v Unit vector
![Page 17: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/17.jpg)
17
Dot Product Dot product (inner product) is defined as:
Note: Therefore we can redefine magnitude in terms of
the dot-product operator:
The dot product operator is commutative and associative.
332211
3
2
1
3
2
1
vuvuvuvvv
uuu
vu
223
22
21 uuu uuu uuu
i
iivuvu
22112
1
2
1 vuvuvv
uu
vu
![Page 18: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/18.jpg)
18
The Dot Product can also be obtained from the following equation:
where is the angle between the two vectors
So, if we know the vectors u and v, then the dot product is useful for finding the angle between two vectors.
Note that if we had already normalised the vectors u and v then it would simply be:
Dot Product
cosvuvu
vuvuvuvu 1coscos
vu ˆˆcos 1
vu
![Page 19: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/19.jpg)
19
Dot Product Examples
Find the angle between vectors { 1, 1, 0} and {0, 1, 0}?
![Page 20: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/20.jpg)
20
Additional Properties For any three vectors u, v, w and scalars a, b
uv = vu u(v+w) = uv + uw (u+v)w = uw + vw If uv = 0 then u and v are orthogonal or
perpendicular, where u and v are not zero vector
![Page 21: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/21.jpg)
21
Cross Product Used for defining orientation and constructing co-ordinate
axes. Cross product defined as:
The result is a vector, perpendicular to the plane defined by u and v:
Magnitude :
1221
3113
2332
3
2
1
3
2
1
vuvuvuvuvuvu
vvv
uuu
vu
n̂sinvuvu
sin|||||||||||| vuvu
![Page 22: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/22.jpg)
22
Right Handed Coordinate System
Cross Product
![Page 23: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/23.jpg)
23
Cross product is anti-commutative: It is not associative:
Direction of resulting vector defined by operand order:
uvvu wvuwvu
R.H.S.
Cross Product
![Page 24: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/24.jpg)
24
Consider, two vectors u = , v = , the cross product u x v
321
654
Cross Product
![Page 25: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/25.jpg)
25
Vector Spaces A linear combination of vectors results in a new
vector:v = 1v1 + 2v2 + … + nvn
where is any scalar If the only set of scalars such that
1v1 + 2v2 + … + nvn = 0 is 1 = 2 = … = 3 = 0 then we say the vectors are linearly independent The dimension of a space is the greatest number of
linearly independent vectors possible in a vector set For a vector space of dimension n, any set of n linearly
independent vectors form a basis
![Page 26: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/26.jpg)
26
Coordinate Systems 3D vector space
scalar component : 1, 2, 3
basis vector : v1, v2, v3
define a coordinate system the origin : fixed reference point
column matrix
3
2
1
v
332211 vvvv
v2
v1
v3
Coordinate System
origin
![Page 27: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/27.jpg)
27
Points Location in space Operations allowed between points and vectors
Point-point subtraction yields a vector Equivalent to point-vector addition
P = v + Q
v = P - Q
![Page 28: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/28.jpg)
28
Affine Spaces Point + a vector space Operations
Vector-vector addition Scalar-vector multiplication Point-vector addition Scalar-scalar operations
For any point define 1 • P = P 0 • P = 0 (zero vector)
![Page 29: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/29.jpg)
29
Lines (in Affine Space) Consider all points of the form
P(a)=P0 + a d Set of all points that pass through P0 in the direction of the
vector d Affine addition
d P
QRP 21 Q
vR
1
0
QR
QRQPQRv
vQP
1
![Page 30: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/30.jpg)
30
Parametric Form This form is known as the parametric form of the line
More robust and general than other forms Extends to curves and surfaces
Two-dimensional forms Explicit: y = mx +h Implicit: ax + by +c =0 Parametric: x() = x0 + (1-)x1
y() = y0 + (1-)y1
![Page 31: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/31.jpg)
31
Rays and Line Segments If >= 0, then P() is the ray leaving P0 in the direction d
If we use two points to define v, thenP( ) = Q+v = Q + (R-Q) = R + (1-)Q For 0<=<=1 we get all thepoints on the line segmentjoining R and Q
![Page 32: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/32.jpg)
32
Convexity An object is convex iff for any two points in the object all points on the line segment between these points are also in the object
P
Q Q
P
convex not convex= concave
![Page 33: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/33.jpg)
33
Affine Sums Consider the “sum”P=1P1+2P2+…..+nPn
Can show by induction that this sum makes sense iff
1+2+…..n=1
in which case we have the affine sum of the points P1P2,…..Pn
If, in addition, i>=0, we have the convex hull of P1P2,…..Pn
![Page 34: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/34.jpg)
34
Convex Hull Smallest convex object containing P1P2,…..Pn
Formed by “shrink wrapping” points
![Page 35: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/35.jpg)
35
Curves and Surfaces Curves are one parameter entities of the form
P() where the function is nonlinear Surfaces are formed from two-parameter functions P(, )
Linear functions give planes and polygons
P() P(, )
![Page 36: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/36.jpg)
36
Planes A plane be determined by a point and two vectors or by three points
P(,)=R+u+v P(,)=R+(Q-R)+(P-Q)R
P
![Page 37: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/37.jpg)
37
Triangles
convex sum of P and Q
convex sum of S() and R
for 0<=,<=1, we get all points in triangle
![Page 38: Mathematics for Graphics](https://reader030.fdocuments.net/reader030/viewer/2022020320/56815e63550346895dcce277/html5/thumbnails/38.jpg)
38
Planes Extension of line
P Q
R
,T
S
10,1 QPS
10,1 RST
RQPT 11,
PRPQPT 11,
vuPT 0, 1,0,
vuPP 0
00 PPn
vun normal to the planeP0
v
u
n
P