Download presentation
Presentation is loading. Please wait.
Published byAlvin Jefferson Modified over 9 years ago
1
Some Cool Tricks
2
We can consider the screen as high school graph paper. Each sprite or object is located somewhere in the coordinate system.
3
Remember our screen is not like the school mathematical graph paper! The origin is at the top-left! That means the bottom of our object is at a higher y position than the top!
4
Moving things around is called translation. Usually we translate our object to the origin before we perform rotation and scaling.
5
Move every point in one object to another location.
6
For rotation, lets visit the Siggraph web page: https://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm, accessed August 2014. https://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/2drota.htm
7
We use Pythagoras to find the distance between two points.
8
Using (x, y) positions is common. However, you may use (r, Θ) r = distance from origin Θ = angle. Converting between the two systems is easy. Just remember the name!
9
Beware, we need a little bit more sophistication to calculate the angle… as this gives us ambiguity.
10
We can use circle to circle collision as an example. We find the centre of each circle and use Pythagoras to discover the distance between the two. The equations to the right tell us when there has been a collicsion! We can possibly do this with square distances to avoid using expensive sqrt operations. We must be careful to avoid interpenetration as the entities will indefinite collide with each other.
11
Interpenetration of objects. Interlocking of objects. Quantum Tunnelling Effects.
12
Once again in scaling we need to translate our object’s origin to the origin of the world, we then perform the scaling operation. Remember to translate back!
13
We use logic all the time in coding. We will use logic for our AI and decision making in games. We will explicitly cover some rudimentary logic.
14
And Or Not Xor Implies Tautologies—Saying the same thing more than once. Associative Laws—Order does not matter. Distributive Laws—We can say things in different ways that mean the same thing. Identity Laws
17
Sets can be used to make decisions. Sets indicate belongingness.
18
Venn Diagrams Union Intersection Difference. Sets Subsets Compliment Universal Set Identity Laws
20
What is in A, B and C? What is in A? What is in not A? Useful for games. Useful for determining strategies.
21
Yes! std::set! How awesome is that?
22
Vectors and matrices are mathematically convenient tools. They are used in games for graphical mathematics. So annoying that std::vector is named in such a way to make things a little confusing.
23
I like to call this Quantum Tunnelling. We miss the detection of a collision as the bullet passes through the wall.
24
Bounding box collision detection in 2D.
25
Tricks One’s Compliment
26
The distance between two points can be calculated using Pythagoras. This can be used for simple collision detection. Movie, https://www.youtube.com/watch?v=pVo6szY E13Y, accessed August 2014. https://www.youtube.com/watch?v=pVo6szY E13Y
27
https://www.youtube.com/watch?v=o- OvVep2uSg, accessed August 2014. https://www.youtube.com/watch?v=o- OvVep2uSg
28
Analytical Geometry is concerned with points and the relationships between points. We can find angles between two points to determine interesting relationships.
29
Useful for determining: (a) If a collision would take place. (b) If a collision has taken place.
30
Let’s look at the diagrams! http://www.intmath.com/plane-analytic- geometry/perpendicular-distance-point- line.php, accessed August 2014. http://www.intmath.com/plane-analytic- geometry/perpendicular-distance-point- line.php
31
Vectors can represent acceleration, velocity and displacement and any sort of force, which is essential to any physics orientated game. It allows for you to calculate paths, trajectories and many aspects of physics within code.
32
A vector is a point. For two dimensional mathematics: (x, y). These vectors have interesting operations. They make it easier to do mathematics.
33
We can simply calculate the resulting vector when combining multiple forces…
34
A matrix is a column by row matrix of values. The matrix has defined operations so we can perform mathematical operations efficiently on a collection of points.
38
Read the wikipage on 2D Graphics. This will help you understand more about your programming project. http://en.wikipedia.org/wiki/2D_computer_graphics http://en.wikipedia.org/wiki/2D_computer_graphics
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.