1 / 9

Physics

Physics. Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair. 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.

kemp
Télécharger la présentation

Physics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 < Ymin OR Py > Ymax, I hit a wall • If Px < Xmin OR Px > Xmax, I scored/hit a wall Radius = r Ball center compared to X1 - Cx, Y1 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

More Related