Chap 1 Math Physic
Chap 1 Math Physic
1
Outline
• Math – Linear Algebra for Game
• Vector
• Matrix
• Physics
• Collision Detection
• Movement
2
VECTOR
• Representation:
• In code:
• No concept of position
3
ADDITION
4
SUBTRACTION
5
SUBTRACTION
• Example: imagine you are designing a UI arrow system for a
game
6
LENGTH, UNIT VECTOR,
NORMALIZATION
• Length (magnitude)
• Unit Vector:
7
SCALAR MULTIPLICATION
8
DOT PRODUCT
9
DOT PRODUCT
10
SAMPLE PROBLEM: VECTOR
REFLECTION
11
SAMPLE PROBLEM: VECTOR
REFLECTION
12
CROSS PRODUCT
13
CROSS PRODUCT
14
SAMPLE PROBLEM: ROTATING
A 2D CHARACTER
15
LINEAR INTERPOLATION
16
COORDINATE SYSTEMS
17
MATRIX
18
ADDITION
19
SCALAR MULTILICATION
20
MULTILICATION
21
INVERSE
• I: identity matrix
22
TRANSPOSE
23
TRANSFORMING 3D VECTORS
BY MATRICES
24
PHYSICS
• Plane
• Ray, and Line Segment
• Collision Geometry
• Physics-based Movement
• Physics Middleware
25
PLANE
26
RAYS AND LINE SEGMENTS
27
COLLISION GEOMETRY
• What is it???
• Why do we use it?
28
BOUNDING SPHERE
29
AXIS-ALIGNED BOUNDING
BOX
30
CAPSULE
31
CONVEX POLYGONS
32
LIST OF COLLISION
GEOMETRIES
• ???
33
COLLISION DETECTION
• Sphere versus Sphere Intersection
• AABB versus AABB Intersection
• Line Segment versus Plane Intersection
• Line Segment versus Triangle Intersection
• Sphere versus Plane Intersection
• Swept Sphere Intersection
• Collision Response
• Optimizing Collisions
34
SPHERE VERSUS SPHERE
INTERSECTION
35
AABB VERSUS AABB
INTERSECTION
36
LINE SEGMENT VERSUS PLANE
INTERSECTION
37
LINE SEGMENT VERSUS
TRIANGLE INTERSECTION
38
SPHERE VERSUS PLANE
INTERSECTION
39
Swept Sphere Intersection
• Bullet through paper problem
40
41
COLLISION RESPONSE
• Read chapter 7 [1]
42
OPTIMIZING COLLISIONS
• Read chapter 7 [1]
43
PHYSICS-BASED MOVEMENT
• Overview
• Problem???
44
ISSUES WITH VARIABLE TIME
STEPS
45
EULER AND SEMI-IMPLICIT
EULER INTEGRATION
46
VELOCITY VERLET
INTEGRATION
47
PHYSICS MIDDLEWARE
• 3D: PhysX
• 2D: Box2D
48
MORE READING
• Lengyel, Eric. Mathematics for 3D Game Programming and
Computer Graphics (Third Edition) . Boston: Course
Technology, 2012
• Ericson, Christer. Real-time Collision Detection . San
Francisco: Morgan Kaufmann, 2005
• Fielder, Glenn. Gaffer on Games – Game Physics.
http://gafferongames.com/game-physics/
49