Presentation is loading. Please wait.

Presentation is loading. Please wait.

CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)

Similar presentations


Presentation on theme: "CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)"— Presentation transcript:

1 CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)

2 OVERVIEW For 2D games, we use a lot of trigonometry For 3D games, we use a lot of linear algebra and 2D concepts For advanced concepts, we use a lot of calculus and 3D concepts Math is used to: Translate geometry Rotate geometry Scale geometry Calculate light Determine the position of enemies (such as their “AI”) Run physics engines (collisions)

3 TRIG YOU PROBABLY ALREADY KNOW… x (adjacent) y (opposite) h (hypotenuse) θ

4 TRIG YOU PROBABLY KNOW

5 THINGS YOU PROBABLY REMEMBER (REVIEW OF SIN AND COS)

6

7 ROTATING POINTS IN 2D Note: you may need to add an offset if the origin isn’t (0,0)

8 OTHER TRIG YOU SHOULD KNOW

9 INVERSE TRIG

10 QUESTION How would I describe the 2D difference in location of a player and an enemy? You Nazi-Bear-Zombie

11 QUESTION How would I describe the 2D difference in location of a player and an enemy? (x 1, y 1 ) (x 2, y 2 )

12 QUESTION How would I describe the 2D difference in location of a player and an enemy? (x 1, y 1 ) (x 2, y 2 ) Note: a very useful 2D function is atan2 (y, x) which gives you the angle!

13 3D STUFF YOU PROBABLY ALREADY KNOW… A 3D point contains x, y and z A vertex is essentially a 3D point An edge connects two vertices Triangles are comprised of 3 vertices Scalar values are just single numbers (e.g. 1, 2, 3) We need to be able to: Translate (move) vertices Rotate vertices Scale vertices

14

15 OPERATIONS ON VECTORS +=

16

17 MAGNITUDE AND NORMALIZATION OF VECTORS

18 THE DOT PRODUCT

19 DOT PRODUCT EXAMPLE

20 DOT PRODUCT EXAMPLE 2

21 DOT PRODUCT EXAMPLE 3

22 PROJECTION Can also be used to calculate the projection of one vector onto another Length is:

23 CROSS PRODUCT (AKA THE “VECTOR” PRODUCT)

24 MATRICES

25

26 A FEW SPECIAL MATRICES (USED FOR ROTATION)

27 MATRIX MULTIPLICATION

28

29

30

31

32 TRANSLATION Note: the 4 th component must be a 1 for a point, but a 0 if it’s a direction!

33 SCALING

34 LINES

35 DISTANCE OF A POINT TO A LINE

36 PLANES

37 DISTANCE OF POINT TO PLANE

38 INTERSECTION OF A LINE AND PLANE (LAST SLIDE – HURRAY!)


Download ppt "CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)"

Similar presentations


Ads by Google