1. Beginning Direct3D Game Programming:
Mathematics 5
Matrix
jintaeks@gmail.com
Division of Digital Contents, DongSeo University.
15, May 2016
2. Linear system
2
A linear function is a polynomial function of degree zero or
one, or is the zero polynomial(f(x)=0).
3. Linear function
When the function is of only one variable, it is of the form
where a and b are constants, often real numbers.
The graph of such a function of one variable is a nonvertical
line. a is frequently referred to as the slope of the line,
and b as the intercept.
For a function of any finite number of independent variables,
the general formula is
and the graph is a hyperplane of dimension k.
3
4. Linear map
In linear algebra, a linear function is a map f between
two vector spaces that preserves vector addition and scalar
multiplication:
This tells us that for a some input, if we can decompose the
input to addition, the result also be calculated separately.
In physics and other sciences, a nonlinear system, in contrast
to a linear system, is a system which does not satisfy
the above properties – meaning that the output of a
nonlinear system is not directly proportional to the input.
4
5. Linear system
A system of linear equations (or linear system) is a
collection of two or more linear equations involving the same
set of variables.
Above is a system of three equations in the three
variables x, y, z.
5
6. Plane
A plane is a flat, two-dimensional surface that extends
infinitely far.
The equation of a plane with nonzero normal vector n=(a,b,c)
through the point x0=(x0,y0,z0) is n·(x-x0)=0, where x=(x,y,z).
6
7. Plugging in gives the general equation of a plane,
ax+by+cz+d=0,
where
d=-ax0-by0-cz0.
A plane specified in this form therefore has x-, y-, and z-
intercepts at
x = -d/a
y = -d/b
z = -d/c,
and lies at a distance
D=d/(sqrt(a2+b2+c2))
from the origin.
7
10. Linear system
A solution to a linear system is an
assignment of numbers to the
variables such that all the equations
are simultaneously satisfied.
10
A linear system in three variables
determines a collection of planes.
The intersection point is the
solution.
11. Matrix
Each element of a matrix is often denoted by a variable with
two subscripts. For instance, a2,1 represents the element at the
second row and first column of a matrix A.
11
12. A matrix (plural matrices) is a rectangular array of
numbers, symbols, or expressions, arranged
in rows and columns. The dimensions of below matrix
are 2 × 3 (read "two by three"), because there are two rows
and three columns.
12
13. Size
The size of a matrix is defined by the number of rows and
columns that it contains. A matrix with m rows and n columns
is called an m × n matrix or m-by-n matrix,
while m and n are called its dimensions.
13
14. Notation
Matrices are commonly written in box
brackets or parentheses:
The (1,3) entry of the following matrix A is 5. It is
denoted a13, a1,3, A[1,3] or A1,3.
14
15. Basic operations
There are a number of basic operations that can be applied to
modify matrices.
– matrix addition
– scalar multiplication
– transposition
– matrix multiplication
– row operations.
15
16. Addition
The sum A+B of two m-by-n matrices A and Bis calculated
entrywise:
(A + B)i,j = Ai,j+ Bi,j, where 1 ≤ i ≤ m and 1 ≤ j ≤ n.
16
17. Transposition
The transpose of an m-by-n matrix A is the n-by-m
matrix AT formed by turning rows into columns and vice versa:
(AT)i,j = Aj,i
17
18. Scalar multiplication
The product cA of a number c (also called a scalar in the
parlance of abstract algebra) and a matrix A is computed by
multiplying every entry of A by c:
(cA)i,j = c · Ai,j.
This operation is called scalar multiplication.
– Its result is not named “scalar product” to avoid confusion, since
“scalar product” is sometimes used as a synonym for “inner product”.
18
19. Multiplication
Multiplication of two matrices is defined if and only if the
number of columns of the left matrix is the same as the
number of rows of the right matrix.
If A is an m-by-n matrix and B is an n-by-p matrix, then
their matrix product AB is the m-by-p matrix whose entries
are given by dot product of the corresponding row of A and
the corresponding column of B:
19
21. example
Matrix multiplication satisfies the rules (AB)C = A(BC)
(associativity), and (A+B)C = AC+BC as well as C(A+B)
=CA+CB (left and right distributivity), whenever the size of the
matrices is such that the various products are defined. The
product AB, they need not be equal, that is, generally
AB ≠ BA,
21
3=2×0+3×1+4×0
2340=2×1000+3×100+4×10
22. Identity element, Inverse element for multiplication
For some real number a
a×1 = a
In this case, 1 is called the identity element for multiplication.
a×( ) = 1
The answer to above equation is 1/a, 1/a is called the inverse
element of a for multiplication.
22
23. Identity Matrix
In linear algebra, the identity matrix, or sometimes
ambiguously called a unit matrix, of size n is
the n × n square matrix with ones on the main diagonal and
zeros elsewhere.
When A is m×n, it is a property of matrix multiplication that
23
24. Determinant
In linear algebra, the determinant is a useful value that can
be computed from the elements of a square matrix. The
determinant of a matrix A is denoted det(A) or |A|.
24
25. Linear Systems
Matrices provide a compact and convenient way to represent
systems of linear equations. For instance, the linear system is
given below.
Above linear system can be represented in matrix form like
below.
25
26. The matrix preceding the vector x, y, z of unknowns is called
the coefficient matrix, and the column vector on the right
side of the equals sign is called the constant vector. Linear
systems for which the constant vector is nonzero (like the
example above) are called non-homogeneous.
Linear systems for which every entry of the constant vector is
zero are called homogeneous.
– The geometric meaning of homogeneous is all the 3-planes meet at
the origin (0,0,0).
26
27. How to solve?
We can set the augmented matrix formed by concatenating
the coefficient matrix and constant vector.
And we may apply operations known as the Elementary Row
Operation.
We will not examine that process.
27
28. Homogeneous Matrix
Later, we will use 4x4 matrices to consistently represent
translation, scaling and rotation in 3D space.
In that case a14, a24 and a34 is always zero, so we call this 4x4
matrix as a Homogeneous Matrix.
3 2 −3 0
4 −3 6 0
1
0
0
0
−1
0
0
1
28
29. Matrix Inverses
An n × n matrix M is invertible if there exists a matrix, which
we denote by M−1, such that MM−1 =M−1M = I. The matrix
M−1 is called the inverse of M.
Not every matrix has an inverse, and those that do not are
called singular. An example of a singular matrix is any one
that has a row or column consisting of all zeros.
1 0 0
0 1 0
0 0 0
Any matrix possessing a row that is a linear combination of
the other rows of the matrix is singular.
1 0 0
0 1 0
2 2 0
29
30. How to calculate the inverse of an n×n matrix M?
There is a well known algorithm called 'Gauss-Jordan
elimination'.
We will not examine that algorithm.
30
31. Back to the 2D Rotation
Do you remember this linear system?
31
32. x' = x·cos(θ) – y·sin(θ)
y' = x·sin(θ) + x·cos(θ)
Above linear system can be represented like below.
𝑥′
𝑦′
=
𝑐𝑜𝑠(𝜃) −sin(𝜃)
sin(𝜃) cos(𝜃)
𝑥
𝑦
32
33. Key observation
In 2-dimensional space, when a position (a,b) is given, a linear
system uniquely determines a new position (a', b').
For example, for a position (2,1), We can find a linear system
which transform to a new position (1,3).
33
34. But there may be no linear system such like that, or may be
very difficult to find the system.
In that case, the process may be decomposed to more easier
steps.
To consistently represent this process, we uses matrix as a
ADT(abstract data type).
34