Download presentation

Presentation is loading. Please wait.

Published bySara Cooke Modified over 3 years ago

2
Code examples Mechanics: random balls Biology/evolution: flocking Game of tag

3
Intro to bodies interactions The attraction between two bodies is given by F= g*m 1 *m 2 /r 2 Where F is force, g is the gravitational constant [aka fudge factor], ms are masses for bodies one and two and r is the distance between them.

4
r the distance between two bodies Using the Pythagorean theorem we can find the distance between two points x hypotenuse = r y a 2 + b 2 = c 2 Hence, x 2 + y 2 = r 2 Point 1 Point 2

5
Trigonometry review cos = x sin = y tan = y/x atan y/x = y x

6
mmm vectors…. We need to separate the x and y directions of the force. is the angle So F, the force arrow has an x and y part. F x = (cos ) * F F y = (sin ) * F Mass 1 at center Mass 2 out there y x F

7
Put it all together Lets ignore m 2 [its very very very small], then F= g*m 1 *m 2 /r 2, becomes F = g*m/r 2 But, r 2 = x 2 + y 2, so F = g*m/(x 2 + y 2 ) But, F x = (cos )*F, so F x = (cos )*g*m/(x 2 + y 2 ) Similarly, F y = (sin )*g*m/(x 2 + y 2 )

8
How does the computer know what's what? x is x and y is y But the computer does not know what is. atan y/x = y x

9
Using atan y/x = Remember, F x = (cos )*g*m/(x 2 + y 2 ) And,F y = (sin )*g*m/(x 2 + y 2 ) So, F x = (cos [atan y/x])*g*m/(x 2 + y 2 ) And, F y = (sin [atan y/x])*g*m/(x 2 + y 2 )

10
What does force do? If you hit a tether ball then you are the force and the ball then has a velocity as it flies through the air. Hence we need velocity terms for our bodies: V V x = V x + F x V y = V y + F y The velocity gets added to it self just like with a tether ball: the new velocity adds its old velocity to the new force of hitting it again.

11
Next step translate into code

Similar presentations

OK

VECTORS v Fp Scalar quantities – that can be completely described by a number with the appropriate units. ( They have magnitude only. ) Such as length,

VECTORS v Fp Scalar quantities – that can be completely described by a number with the appropriate units. ( They have magnitude only. ) Such as length,

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on natural and artificial satellites pictures Ppt on condition based maintenance software Ppt on regular expression builder Ppt on how to use powerpoint 2013 Ppt on channels of distribution chart Ppt on forward contract Ppt on indian musical instruments Ppt on cold chain storage of food Ppt on save tigers in india download film Ppt on save heritage of india