SlideShare a Scribd company logo
1 of 49
SER332
Introduction to Graphics and
Game Development
Lecture 13:
Linear Algebra
Javier Gonzalez-Sanchez
javiergs@asu.edu
PERALTA 230U
Office Hours: By appointment
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 1
Goal
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 2
Goal
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 3
Goal
3D Maze
( IJKS 1982)
Points, Vector, Angles
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 5
Points and Vectors
Points specify locations in
space (or in the plane)
Vectors have a
magnitude and direction
x
)4,2(y
)2,4(
q
v
1v
2v
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 6
Vectors
2
2
1
R
v
v
v Îú
û
ù
ê
ë
é
=
2
2
2
1 vvv +=
Vector
Magnitude or
Length
v
÷÷
ø
ö
çç
è
æ
= -
1
21
tan
v
v
qOrientation
(angle)
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 7
Vectors
ú
û
ù
ê
ë
é
=
0
0
vZero Vector
Unit Vector or
Normalized Vector
1=v
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 8
Addition and Subtraction
v
u
u+v
u
v
u-v
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 9
Multiplication with a Scalar
v
av
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 10
Test yourself
§ Point + Vector = ?
§ Vector + Vector = ?
§ Point – Point = ?
§ Point + Point = ?
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 11
Point or Vector
Point + Vector = Point Vector + Vector = Vector
Point - Point = Vector
v
u
u-v
v
u
v-u Point + Point = Not Defined
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 12
Angles
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 13
Uses
// mouse motion callback function
void motion(int x, int y) {
if (mouse_button == GLUT_LEFT_BUTTON) {
y_angle += (float(x - mouse_x) / width) *360.0;
x_angle += (float(y - mouse_y) / height)*360.0;
}
if (mouse_button == GLUT_RIGHT_BUTTON) {
scale += (y - mouse_y) / 100.0;
if (scale < 0.1) scale = 0.1;
if (scale > 7) scale = 7; }
mouse_x = x;
mouse_y = y;
glutPostRedisplay();
}
Dot product
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 15
Dot Product
• The dot product or inner product measures to what
degree two vectors are aligned
• Notation:
• Computation:
wvwvwv T
×==>< ,
[ ] 332211
3
2
1
321, wvwvwv
w
w
w
vvvwv ×+×+×=
ú
ú
ú
û
ù
ê
ê
ê
ë
é
=><
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 16
Dot Product
q
v=[5,5]
u=[7,3]
v * u = (5*7) + (5*3) = 50
v * w = (5*5) + (5*0) = 25
u * w = (7*5) + (3*0) = 35
u * u = (7*7) + (3*3) = 58
t * w = (0*5) + (5*0) = 0
w=[5,0]
t=[0,5]
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 17
Dot Product
• Two vectors v and w are perpendicular or normal iff
0, =>< wv
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 18
Dot Product
• Geometric Interpretation:
w
v
a
l
wv
wv
w
l
COS
×
==
,
)(a
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 19
Dot Product
q
v=[5,5]
u=[7,3]
v * u = (5*7) + (5*3) = 50
v * w = (5*5) + (5*0) = 25
u * w = (7*5) + (3*0) = 35
u * u = (7*7) + (3*3) = 58
t * w = (0*5) + (5*0) = 0
w=[5,0]
t=[0,5]
|t | = 5.00
|v| = 7.07
|u| = 7.61
|w| = 5.00
q = cos-1 (25/7.07*5) = 45º
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 20
Dot Product Calculation
Length = Magnitude
vvvvv T
== ,
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 21
Dot Product Laws
• Commutative law:
• Distributive law:
><=>< vwwv ,,
><+><=>+< uvwvuwv ,,,
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 22
Uses
Cross product
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 24
Cross Product
• Notation: u = v x w
• The cross product is a vector!
• Magnitude of u: proportional to
the sine of the angle between v
and w
• u is perpendicular to v and w
• The direction of u follows the
right hand rule
w
v
a
u
asin|||||||||||||u|| wvwv =´=
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 25
Cross Product Computation
Computation:
ú
ú
ú
û
ù
ê
ê
ê
ë
é
-
-
-
==
÷
÷
÷
ø
ö
ç
ç
ç
è
æ
´
÷
÷
÷
ø
ö
ç
ç
ç
è
æ
=´=
2121
1313
3232
321
321
3
2
1
3
2
1
vwwv
vwwv
vwwv
www
vvv
kji
w
w
w
v
v
v
wvu
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 26
Cross Product Laws
• Distributive law:
• Commutative law:
• Associative law:
vwwv ´-=´
uvwvuwv ´+´=+´ )(
uwvuwv ´´¹´´ )()(
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 27
Cross Product and Triangle Area
The cross product is related to the area of a triangle
2
PRPQ
area
´
=
Q
R
P
asin|||||||||||||u|| wvwv =´=(parallelogram) area =
(triangle)
v
w
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 28
Test Yourself
Given a Triangle with
P[0,0,0], Q[0,5,0] and R[5,5,0]
What is the area?
Q R
P
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 29
Test Yourself
Given a Triangle with
P[0,0,0], Q[0,5,0] and R[5,5,0]
What is the area?
Q R
P
area (triangle) = [0,5,0] x [5,5,0] = |[0, 0, -25]|/2 = 25/2 = 12.5
area (parallelogram) = 25
area (parallelogram) = (5)(7.07) sin (45) = (5)(7.07...)(0.70...) = 25
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 30
Distance point to line
n
0p
p
//Compute the distance from AB to C
double LineToPointDistance2D
(double[] pA, double[] pB, double[] pointC) {
double dist = CrossProduct(pA, pB, pointC) / distance(pA, pB);
return Math.Abs(dist);
}
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 31
Usage: normal calculation (lighting)
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 32
Usage: collision detection
Matrices
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 34
Matrix
• A matrix is a set of elements, organized into rows
and columns
ú
û
ù
ê
ë
é
dc
ba
rows
columns
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 35
Matrix Addition
• Addition
• Example
• Substraction
ú
û
ù
ê
ë
é
++
++
=ú
û
ù
ê
ë
é
+ú
û
ù
ê
ë
é
hdgc
fbea
hg
fe
dc
ba
ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
+ú
û
ù
ê
ë
é
64
78
51
26
13
52
ú
û
ù
ê
ë
é
--
--
=ú
û
ù
ê
ë
é
-ú
û
ù
ê
ë
é
hdgc
fbea
hg
fe
dc
ba
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 36
Matrix Multiplication
• Multiplication
ú
û
ù
ê
ë
é
++
++
=ú
û
ù
ê
ë
é
ú
û
ù
ê
ë
é
dhcfdgce
bhafbgae
hg
fe
dc
ba Multiply each row by
each column
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 37
Matrix Multiplication
pmmnpn BAC ´´´ =
Multiplication:
ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
ú
û
ù
ê
ë
é
1119
2917
51
26
.
13
52
Examples:
ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
ú
û
ù
ê
ë
é
1017
3218
13
52
.
51
26
A and B must have
compatible dimensions
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 38
Transpose
• Notation:
• Definition:
• Examples: )()( ji
T
ij AA =
ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
52
16
51
26
T
ú
û
ù
ê
ë
é
=
ú
ú
ú
û
ù
ê
ê
ê
ë
é
852
316
83
51
26
T
T
A
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 39
Rules
TTT
ABAB =)(
TTT
BABA +=+ )(
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 40
Symmetric Matrices
• A is symmetric iff AAT
=
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 41
Determinants
• Determinant (Note A must be square)
• Example
13152
13
52
det -=-=ú
û
ù
ê
ë
é
3231
2221
13
3331
2321
12
3332
2322
11
333231
232221
131211
det
aa
aa
a
aa
aa
a
aa
aa
a
aaa
aaa
aaa
+-=
ú
ú
ú
û
ù
ê
ê
ê
ë
é
12212211
2221
1211
2221
1211
det aaaa
aa
aa
aa
aa
-==ú
û
ù
ê
ë
é
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 42
Inverse Matrices
• Notation
• I is the Identity (1s on the diagonal, 0s elsewhere)
• Inverse Computation:
IAAAA == -- 11
ú
û
ù
ê
ë
é
-
-
-
=ú
û
ù
ê
ë
é
-
1121
1222
12212211
1
2221
1211 1
aa
aa
aaaaaa
aa
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 43
Test Yourself
• Example
ú
û
ù
ê
ë
é
-
-
=ú
û
ù
ê
ë
é
-
61
25
28
1
51
26
1
ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
=ú
û
ù
ê
ë
é
ú
û
ù
ê
ë
é
-
-
=ú
û
ù
ê
ë
é
ú
û
ù
ê
ë
é
-
10
01
280
028
28
1
51
26
.
61
25
28
1
51
26
.
51
26
1
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 44
Usage: transformations
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 45
Usage: transformations
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 46
Usage: transformations
Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 47
Homework
Review Linear Algebra
SER332 Advanced Graphics
Javier Gonzalez-Sanchez
javiergs@asu.edu
Spring 2017
Disclaimer. These slides can only be used as study material for the class SER332 at ASU. They cannot be distributed or used for another purpose.

More Related Content

What's hot

Cruzadinha - Expressões numéricas
Cruzadinha - Expressões numéricas Cruzadinha - Expressões numéricas
Cruzadinha - Expressões numéricas Mary Alvarenga
 
Straight line graphs
Straight line graphsStraight line graphs
Straight line graphsSajidPervez2
 
Nvo formulario
Nvo formularioNvo formulario
Nvo formulariototo3957
 
Tugascalculus 150716105101-lva1-app6891
Tugascalculus 150716105101-lva1-app6891Tugascalculus 150716105101-lva1-app6891
Tugascalculus 150716105101-lva1-app6891Fajar Corp
 
Equations and inequalities w sheet
Equations and inequalities w sheetEquations and inequalities w sheet
Equations and inequalities w sheetmarniekrentz
 
Luas daerah bidang datar (kalkulus integral)
Luas daerah bidang datar (kalkulus integral) Luas daerah bidang datar (kalkulus integral)
Luas daerah bidang datar (kalkulus integral) Nurkhalifah Anwar
 
Section 4.5 graphing linear equations
Section 4.5 graphing linear equationsSection 4.5 graphing linear equations
Section 4.5 graphing linear equationsAlgebra / Mathematics
 
Լուծենք քառակուսային հավասարումները բանավոր
Լուծենք քառակուսային հավասարումները բանավորԼուծենք քառակուսային հավասարումները բանավոր
Լուծենք քառակուսային հավասարումները բանավորHermine Antonyan
 
Algebra 5 Point 6
Algebra 5 Point 6Algebra 5 Point 6
Algebra 5 Point 6herbison
 
Teoria y problemas de conteo de segmentos cs01 ccesa007
Teoria y problemas de conteo de segmentos  cs01  ccesa007Teoria y problemas de conteo de segmentos  cs01  ccesa007
Teoria y problemas de conteo de segmentos cs01 ccesa007Demetrio Ccesa Rayme
 
Teoría y problemas de conteo de segmentos CS11 ccesa007
Teoría y problemas de conteo de segmentos  CS11  ccesa007Teoría y problemas de conteo de segmentos  CS11  ccesa007
Teoría y problemas de conteo de segmentos CS11 ccesa007Demetrio Ccesa Rayme
 
Factorization of polynomials and quadratic equation
Factorization of polynomials and quadratic equation Factorization of polynomials and quadratic equation
Factorization of polynomials and quadratic equation Edrin Jay Morta
 
Introduction to straight line graphs lesson
 Introduction to straight line graphs lesson Introduction to straight line graphs lesson
Introduction to straight line graphs lessonSajidPervez2
 
Hw to factor
Hw to factorHw to factor
Hw to factor41142391
 
Números enteros
Números enterosNúmeros enteros
Números enterosDaysi N
 
Straight line-equation.
Straight line-equation.Straight line-equation.
Straight line-equation.SajidPervez2
 

What's hot (20)

Core 3 Modulus 1
Core 3 Modulus 1Core 3 Modulus 1
Core 3 Modulus 1
 
Cruzadinha - Expressões numéricas
Cruzadinha - Expressões numéricas Cruzadinha - Expressões numéricas
Cruzadinha - Expressões numéricas
 
Straight line graphs
Straight line graphsStraight line graphs
Straight line graphs
 
Nvo formulario
Nvo formularioNvo formulario
Nvo formulario
 
Tugascalculus 150716105101-lva1-app6891
Tugascalculus 150716105101-lva1-app6891Tugascalculus 150716105101-lva1-app6891
Tugascalculus 150716105101-lva1-app6891
 
Equations and inequalities w sheet
Equations and inequalities w sheetEquations and inequalities w sheet
Equations and inequalities w sheet
 
Productos notables
Productos notablesProductos notables
Productos notables
 
Luas daerah bidang datar (kalkulus integral)
Luas daerah bidang datar (kalkulus integral) Luas daerah bidang datar (kalkulus integral)
Luas daerah bidang datar (kalkulus integral)
 
Section 4.5 graphing linear equations
Section 4.5 graphing linear equationsSection 4.5 graphing linear equations
Section 4.5 graphing linear equations
 
Լուծենք քառակուսային հավասարումները բանավոր
Լուծենք քառակուսային հավասարումները բանավորԼուծենք քառակուսային հավասարումները բանավոր
Լուծենք քառակուսային հավասարումները բանավոր
 
Squaring (Shortcut)
Squaring (Shortcut)Squaring (Shortcut)
Squaring (Shortcut)
 
Algebra 5 Point 6
Algebra 5 Point 6Algebra 5 Point 6
Algebra 5 Point 6
 
Teoria y problemas de conteo de segmentos cs01 ccesa007
Teoria y problemas de conteo de segmentos  cs01  ccesa007Teoria y problemas de conteo de segmentos  cs01  ccesa007
Teoria y problemas de conteo de segmentos cs01 ccesa007
 
Teoría y problemas de conteo de segmentos CS11 ccesa007
Teoría y problemas de conteo de segmentos  CS11  ccesa007Teoría y problemas de conteo de segmentos  CS11  ccesa007
Teoría y problemas de conteo de segmentos CS11 ccesa007
 
201801 CSE240 Lecture 26
201801 CSE240 Lecture 26201801 CSE240 Lecture 26
201801 CSE240 Lecture 26
 
Factorization of polynomials and quadratic equation
Factorization of polynomials and quadratic equation Factorization of polynomials and quadratic equation
Factorization of polynomials and quadratic equation
 
Introduction to straight line graphs lesson
 Introduction to straight line graphs lesson Introduction to straight line graphs lesson
Introduction to straight line graphs lesson
 
Hw to factor
Hw to factorHw to factor
Hw to factor
 
Números enteros
Números enterosNúmeros enteros
Números enteros
 
Straight line-equation.
Straight line-equation.Straight line-equation.
Straight line-equation.
 

Similar to 201707 SER332 Lecture 13

Similar to 201707 SER332 Lecture 13 (6)

201707 SER332 Lecture 15
201707 SER332 Lecture 15  201707 SER332 Lecture 15
201707 SER332 Lecture 15
 
201804 SER332 Lecture 01
201804 SER332 Lecture 01201804 SER332 Lecture 01
201804 SER332 Lecture 01
 
201707 SER332 Lecture 26
201707 SER332 Lecture 26  201707 SER332 Lecture 26
201707 SER332 Lecture 26
 
201707 SER332 Lecture18
201707 SER332 Lecture18201707 SER332 Lecture18
201707 SER332 Lecture18
 
201707 SER332 Lecture 14
201707 SER332 Lecture 14   201707 SER332 Lecture 14
201707 SER332 Lecture 14
 
201801 CSE240 Lecture 16
201801 CSE240 Lecture 16201801 CSE240 Lecture 16
201801 CSE240 Lecture 16
 

More from Javier Gonzalez-Sanchez (20)

201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
 
201801 SER332 Lecture 04
201801 SER332 Lecture 04201801 SER332 Lecture 04
201801 SER332 Lecture 04
 
201801 SER332 Lecture 02
201801 SER332 Lecture 02201801 SER332 Lecture 02
201801 SER332 Lecture 02
 
201801 CSE240 Lecture 25
201801 CSE240 Lecture 25201801 CSE240 Lecture 25
201801 CSE240 Lecture 25
 
201801 CSE240 Lecture 24
201801 CSE240 Lecture 24201801 CSE240 Lecture 24
201801 CSE240 Lecture 24
 
201801 CSE240 Lecture 23
201801 CSE240 Lecture 23201801 CSE240 Lecture 23
201801 CSE240 Lecture 23
 
201801 CSE240 Lecture 22
201801 CSE240 Lecture 22201801 CSE240 Lecture 22
201801 CSE240 Lecture 22
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
 
201801 CSE240 Lecture 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
 
201801 CSE240 Lecture 18
201801 CSE240 Lecture 18201801 CSE240 Lecture 18
201801 CSE240 Lecture 18
 
201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
 
201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
201801 CSE240 Lecture 13
201801 CSE240 Lecture 13201801 CSE240 Lecture 13
201801 CSE240 Lecture 13
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
 
201801 CSE240 Lecture 10
201801 CSE240 Lecture 10201801 CSE240 Lecture 10
201801 CSE240 Lecture 10
 
201801 CSE240 Lecture 09
201801 CSE240 Lecture 09201801 CSE240 Lecture 09
201801 CSE240 Lecture 09
 
201801 CSE240 Lecture 08
201801 CSE240 Lecture 08201801 CSE240 Lecture 08
201801 CSE240 Lecture 08
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

201707 SER332 Lecture 13

  • 1. SER332 Introduction to Graphics and Game Development Lecture 13: Linear Algebra Javier Gonzalez-Sanchez javiergs@asu.edu PERALTA 230U Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 1 Goal
  • 3. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 2 Goal
  • 4. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 3 Goal 3D Maze ( IJKS 1982)
  • 6. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 5 Points and Vectors Points specify locations in space (or in the plane) Vectors have a magnitude and direction x )4,2(y )2,4( q v 1v 2v
  • 7. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 6 Vectors 2 2 1 R v v v Îú û ù ê ë é = 2 2 2 1 vvv += Vector Magnitude or Length v ÷÷ ø ö çç è æ = - 1 21 tan v v qOrientation (angle)
  • 8. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 7 Vectors ú û ù ê ë é = 0 0 vZero Vector Unit Vector or Normalized Vector 1=v
  • 9. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 8 Addition and Subtraction v u u+v u v u-v
  • 10. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 9 Multiplication with a Scalar v av
  • 11. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 10 Test yourself § Point + Vector = ? § Vector + Vector = ? § Point – Point = ? § Point + Point = ?
  • 12. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 11 Point or Vector Point + Vector = Point Vector + Vector = Vector Point - Point = Vector v u u-v v u v-u Point + Point = Not Defined
  • 13. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 12 Angles
  • 14. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 13 Uses // mouse motion callback function void motion(int x, int y) { if (mouse_button == GLUT_LEFT_BUTTON) { y_angle += (float(x - mouse_x) / width) *360.0; x_angle += (float(y - mouse_y) / height)*360.0; } if (mouse_button == GLUT_RIGHT_BUTTON) { scale += (y - mouse_y) / 100.0; if (scale < 0.1) scale = 0.1; if (scale > 7) scale = 7; } mouse_x = x; mouse_y = y; glutPostRedisplay(); }
  • 16. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 15 Dot Product • The dot product or inner product measures to what degree two vectors are aligned • Notation: • Computation: wvwvwv T ×==>< , [ ] 332211 3 2 1 321, wvwvwv w w w vvvwv ×+×+×= ú ú ú û ù ê ê ê ë é =><
  • 17. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 16 Dot Product q v=[5,5] u=[7,3] v * u = (5*7) + (5*3) = 50 v * w = (5*5) + (5*0) = 25 u * w = (7*5) + (3*0) = 35 u * u = (7*7) + (3*3) = 58 t * w = (0*5) + (5*0) = 0 w=[5,0] t=[0,5]
  • 18. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 17 Dot Product • Two vectors v and w are perpendicular or normal iff 0, =>< wv
  • 19. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 18 Dot Product • Geometric Interpretation: w v a l wv wv w l COS × == , )(a
  • 20. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 19 Dot Product q v=[5,5] u=[7,3] v * u = (5*7) + (5*3) = 50 v * w = (5*5) + (5*0) = 25 u * w = (7*5) + (3*0) = 35 u * u = (7*7) + (3*3) = 58 t * w = (0*5) + (5*0) = 0 w=[5,0] t=[0,5] |t | = 5.00 |v| = 7.07 |u| = 7.61 |w| = 5.00 q = cos-1 (25/7.07*5) = 45º
  • 21. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 20 Dot Product Calculation Length = Magnitude vvvvv T == ,
  • 22. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 21 Dot Product Laws • Commutative law: • Distributive law: ><=>< vwwv ,, ><+><=>+< uvwvuwv ,,,
  • 23. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 22 Uses
  • 25. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 24 Cross Product • Notation: u = v x w • The cross product is a vector! • Magnitude of u: proportional to the sine of the angle between v and w • u is perpendicular to v and w • The direction of u follows the right hand rule w v a u asin|||||||||||||u|| wvwv =´=
  • 26. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 25 Cross Product Computation Computation: ú ú ú û ù ê ê ê ë é - - - == ÷ ÷ ÷ ø ö ç ç ç è æ ´ ÷ ÷ ÷ ø ö ç ç ç è æ =´= 2121 1313 3232 321 321 3 2 1 3 2 1 vwwv vwwv vwwv www vvv kji w w w v v v wvu
  • 27. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 26 Cross Product Laws • Distributive law: • Commutative law: • Associative law: vwwv ´-=´ uvwvuwv ´+´=+´ )( uwvuwv ´´¹´´ )()(
  • 28. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 27 Cross Product and Triangle Area The cross product is related to the area of a triangle 2 PRPQ area ´ = Q R P asin|||||||||||||u|| wvwv =´=(parallelogram) area = (triangle) v w
  • 29. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 28 Test Yourself Given a Triangle with P[0,0,0], Q[0,5,0] and R[5,5,0] What is the area? Q R P
  • 30. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 29 Test Yourself Given a Triangle with P[0,0,0], Q[0,5,0] and R[5,5,0] What is the area? Q R P area (triangle) = [0,5,0] x [5,5,0] = |[0, 0, -25]|/2 = 25/2 = 12.5 area (parallelogram) = 25 area (parallelogram) = (5)(7.07) sin (45) = (5)(7.07...)(0.70...) = 25
  • 31. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 30 Distance point to line n 0p p //Compute the distance from AB to C double LineToPointDistance2D (double[] pA, double[] pB, double[] pointC) { double dist = CrossProduct(pA, pB, pointC) / distance(pA, pB); return Math.Abs(dist); }
  • 32. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 31 Usage: normal calculation (lighting)
  • 33. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 32 Usage: collision detection
  • 35. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 34 Matrix • A matrix is a set of elements, organized into rows and columns ú û ù ê ë é dc ba rows columns
  • 36. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 35 Matrix Addition • Addition • Example • Substraction ú û ù ê ë é ++ ++ =ú û ù ê ë é +ú û ù ê ë é hdgc fbea hg fe dc ba ú û ù ê ë é =ú û ù ê ë é +ú û ù ê ë é 64 78 51 26 13 52 ú û ù ê ë é -- -- =ú û ù ê ë é -ú û ù ê ë é hdgc fbea hg fe dc ba
  • 37. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 36 Matrix Multiplication • Multiplication ú û ù ê ë é ++ ++ =ú û ù ê ë é ú û ù ê ë é dhcfdgce bhafbgae hg fe dc ba Multiply each row by each column
  • 38. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 37 Matrix Multiplication pmmnpn BAC ´´´ = Multiplication: ú û ù ê ë é =ú û ù ê ë é ú û ù ê ë é 1119 2917 51 26 . 13 52 Examples: ú û ù ê ë é =ú û ù ê ë é ú û ù ê ë é 1017 3218 13 52 . 51 26 A and B must have compatible dimensions
  • 39. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 38 Transpose • Notation: • Definition: • Examples: )()( ji T ij AA = ú û ù ê ë é =ú û ù ê ë é 52 16 51 26 T ú û ù ê ë é = ú ú ú û ù ê ê ê ë é 852 316 83 51 26 T T A
  • 40. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 39 Rules TTT ABAB =)( TTT BABA +=+ )(
  • 41. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 40 Symmetric Matrices • A is symmetric iff AAT =
  • 42. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 41 Determinants • Determinant (Note A must be square) • Example 13152 13 52 det -=-=ú û ù ê ë é 3231 2221 13 3331 2321 12 3332 2322 11 333231 232221 131211 det aa aa a aa aa a aa aa a aaa aaa aaa +-= ú ú ú û ù ê ê ê ë é 12212211 2221 1211 2221 1211 det aaaa aa aa aa aa -==ú û ù ê ë é
  • 43. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 42 Inverse Matrices • Notation • I is the Identity (1s on the diagonal, 0s elsewhere) • Inverse Computation: IAAAA == -- 11 ú û ù ê ë é - - - =ú û ù ê ë é - 1121 1222 12212211 1 2221 1211 1 aa aa aaaaaa aa
  • 44. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 43 Test Yourself • Example ú û ù ê ë é - - =ú û ù ê ë é - 61 25 28 1 51 26 1 ú û ù ê ë é =ú û ù ê ë é =ú û ù ê ë é ú û ù ê ë é - - =ú û ù ê ë é ú û ù ê ë é - 10 01 280 028 28 1 51 26 . 61 25 28 1 51 26 . 51 26 1
  • 45. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 44 Usage: transformations
  • 46. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 45 Usage: transformations
  • 47. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 46 Usage: transformations
  • 48. Javier Gonzalez-Sanchez | SER332 | Spring 2017 | 47 Homework Review Linear Algebra
  • 49. SER332 Advanced Graphics Javier Gonzalez-Sanchez javiergs@asu.edu Spring 2017 Disclaimer. These slides can only be used as study material for the class SER332 at ASU. They cannot be distributed or used for another purpose.