Presentation is loading. Please wait.

Presentation is loading. Please wait.

Physics Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair.

Similar presentations


Presentation on theme: "Physics Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair."— Presentation transcript:

1 Physics Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair

2 Pong Velocity is constant Vx = 0.1 Vy = 0.1 Position at time t = Px, Py Position at time t + 1 Px(t+1) = Px(t) + Vx Py(t+1) = Py(t) + Vy

3 Pong How do I get motion that is not diagonal? What happens when I hit a wall? Vx = -Vx (which wall?) Vy = -Vy Vx = -Vx, Vy = -Vy (when you hit a corner) What happens when I hit a paddle?

4 Pong - Collisions If Py Ymax, I hit a wall If Px Xmax, I scored/hit a wall Ball center compared to X1 - Cx, Y1 Radius = r r

5 F = ma Gravity: F = G * (M1 * M2)/D^2 G = gravitational constant, D is distance On earth, assume mass of earth is LARGE so it does not move. Acceleration due to gravity is a constant = 32 ft/sec^2 or 9.8m/sec^2 V(t) = V (0) t + ½ g t^2 Vx = Vx + 0 Vy = Vy + g → choose g to make it look good. !

6 Friction Friction is a function of velocity and mass Static Friction > Kinetic Friction Static: when V = 0 Kinetic: when V > 0 V = V – friction, if V > friction, else 0

7 Collisions (again) Detect Collision Determine time of collision (why?) Determine where objects are when they touch Determine the collision normal Determine velocity vectors after collision Determine changes in rotation (advanced:))

8 Circles/Spheres If the distance between 2 objects is less than sum of radii Avoid using square root (r1+r2)^2 > ((x1 – x2)^2 + (y1 – y2)^2) If N objects → O(N^2)

9 Other objects Collisions are rare Most of the time objects are NOT colliding Create a series of filters so that computationally expensive tests are done rarely Use a grid and only test objects in cells adjacent (touched by) to you First use bounding circles/spheres, then test further


Download ppt "Physics Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair."

Similar presentations


Ads by Google