Presentation is loading. Please wait.

Presentation is loading. Please wait.

Physics + Vectors References: xyz. Variable frame rates (review) Two options for handling it: – Option1: Cap frame rates When moving / rotating express.

Similar presentations


Presentation on theme: "Physics + Vectors References: xyz. Variable frame rates (review) Two options for handling it: – Option1: Cap frame rates When moving / rotating express."— Presentation transcript:

1 Physics + Vectors References: xyz

2 Variable frame rates (review) Two options for handling it: – Option1: Cap frame rates When moving / rotating express in units / updated Good: Easy to understand Bad: Slow machines can't reach the frame-rate – Option2: Let computer run as fast as possible When moving / rotating express in units / second – The multiply by the time since the last frame Good: Runs on any speed machine Bad: A little harder to understand

3 Velocity and Acceleration Suppose you are moving at 50mph for 3 hours. How far are you from your original position? – A: 150 miles 50 * 3 Express this as a graph – We're really calculating the area of this rectangle. Speed (mph) Time (hours) 50 3

4 Velocity and Acceleration, cont. What about (abruptly) changing velocity? Speed (mph) Time (hours) 50 3 Q: How far have we travelled after these 5 hours? Q (rephrased): In other words, what is the area of the pink area? A: 0.5*(50x1) + (50x3) + 0.5*(50x1) = 200 miles

5 Velocity and Acceleration, cont. we can approximate the area of this curve using (small) discreet time intervals Speed (mph) Time (hours) 50 3 A dT value for one iteration of the game loop. import pygame # … clock = pygame.time.Clock() #... (inside the game loop) dT = clock.tick() / 1000.0

6 Velocity and Acceleration, cont.

7 Velocity and Acceleration change in position due to velocity

8 Velocity and Acceleration, cont. Velocity results in a change in position Acceleration results in a change in velocity Speed (mph) Time (hours) 50 3 Position-offset (miles) Time (hours) 25 3 50 75 100 Accel (m/h 2 ) 3 50

9 Acceleration and Vectors, cont.

10 Gravity Gravity produces an accelaration on objects Assuming we're on the earth, it points downwards

11 Newton's Laws of Motion

12 Simple collisions Not physically accurate When we've looked at dot product, we'll re- explore this and do proper – elastic collisions – inelastic collisions For now: – When two objects collide, impart a force Equal magnitude, opposite direction on each body Of a fixed magnitude

13 A new vector operator

14 Boundary collisions

15 Gravity as a Force Gravity is a force – Proportional to the mass – But…when we apply the force We divide by the mass (Newton's 2 nd ) So…the acceleration is the same regardless of mass – Unless there is air resistance (drag)

16 "Planetary" Gravity

17 Examples / Labs #1: – Two bodies, exerting "planetary" gravity on the other. – Try to set up a semi-stable orbit. #2: – Create a bunch of circles, subject to gravity and bouncing off walls Bouncing off each other – Click to lay a bomb. #3: – Asteroids! – Bouncing asteroids – Realistic accelaration


Download ppt "Physics + Vectors References: xyz. Variable frame rates (review) Two options for handling it: – Option1: Cap frame rates When moving / rotating express."

Similar presentations


Ads by Google