Author Topic: messing with newtons laws of physics  (Read 6182 times)

0 Members and 1 Guest are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
messing with newtons laws of physics
« on: January 04, 2014 »
hi folks,

after watching some myth busters tonight i got a bit of a physics itch. my knowledge uptoo this point was always non existent and i just fudged stuff too look ok. but i have always wanted too figure out how too simulate the real world in code.

i stumbled on this fantastic tutorial http://www.physicsclassroom.com/Class/newtlaws/

which led me too this little test

its just a simple test atm, no friction mass or resistance is factored in just yet.. im just droping a ball from a height of 500 metres using earths little gravity of 9.82m/s/s i calculated that the ball would accelerate up too 99.09 metres per second just at the point it hits the earth which is 99.09mps *3.6 = 356.7kph.

my code converts a 640x480 resolution too 1250x1000 meter area and the physics update at 60fps. also the acceleration gravity squares each second.

but im having a few troubles. my forcasted results arent quite lining up with my simulated ones :( im not entirely sure as too why they are very very close just not exactly spot on. so my question would be. is a few kph out after a 500 meter fall ok? or can you guys see anything iffy in what i have done here?

lots of different heights can be simulated up too 1000 meters by simply changing the InitialBallY variable. cheers folks!

i have lots planned for this like trying too include mass air resistance etc but thought i better check out this little issue first.
« Last Edit: January 04, 2014 by ninogenio »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: messing with newtons laws of physics
« Reply #1 on: January 04, 2014 »
had a mess around again and its getting really close now  :)

Instead of squaring little g every second and adding it too velocity, i am just adding (little g\fps)\fps each frame and that seems much more acurate.
i then had the little issue of the ball traveling past the earth before the cpu had time too register a collision had happened which gives slightly faster velocity's than were forcast. so i coded a little algo too try and rewind the velocity too the balls y=0 point its still not quite 100%,
In 90% of cases tested i was coming in at half a kilometer per hour out and the other 10% even less.

i am going too keep trying for accuracy.. and once i think i have it as close as can be then i will move on too adding weight size etc and hopefully make the ball bounce in a realistic fashion.
« Last Edit: January 04, 2014 by ninogenio »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: messing with newtons laws of physics
« Reply #2 on: January 04, 2014 »
i should quickly add that for anyone who just wants too give the exe a quick try. you will have too run in windowed mode and keep an eye on the console window as the simulator works.

fun quiz:.. if two mass less objects free fall in earths lower gravity with zero wind resistance, one from 1000 meters the other from 500 meters will the object falling from 500 meters hit the ground in half the time of the one from 1000??  :)
Challenge Trophies Won:

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Re: messing with newtons laws of physics
« Reply #3 on: January 04, 2014 »
nope..

Gravity without wind resistance.. then they have a constant accelearation, that has to be factored in.

so if you consider 6m with 1m/s/s .. then 1-2-3   3 seconds    12m will be 1-2-3-4-and a bit    ~4.3 seconds

(yep the numbers arent correct.. but the point is visible)

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: messing with newtons laws of physics
« Reply #4 on: January 04, 2014 »
very good  ;)

i was looking at my little free fall sim and noticing some of this stuff,.. yes your correct the higher object will continue too accelerate till it reaches a much higher speed than the lower one ever could.. thus only taking a small amount of extra time too hit the ground.

my sim is telling me it would take approx ~10 seconds for the 500 meter object ~14.2 seconds for the 1000 meter one.
Challenge Trophies Won:

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Re: messing with newtons laws of physics
« Reply #5 on: January 05, 2014 »
:) nice... what are the respective velocities at impact? (The speed is 0 at impact (considering non-elastic (and very hard :) /again not true, as without mass, there is no point in hardness or elasticity as the poor object has no momemntum :) / ) materials. ) and the direction is also non exsistent.)
Ok, i really should be more scientific in this. So what are the respective speeds 0.00001 seconds before impact? :)
/actually without mass, they would not react to gravity at all.... ahhh fck it :) /

I just like the idea of such a toy :)

Also a question for when/if you implement  wind resistane... If you shoot a bullet straight down.. How will its speed behave?
« Last Edit: January 05, 2014 by nikin »

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: messing with newtons laws of physics
« Reply #6 on: January 05, 2014 »
Quote
again not true, as without mass, there is no point in hardness or elasticity as the poor object has no momemntum

sorry nikin i made a woopsy im just using a default of 1kg mass for the ball.. i really should not have said no mass  :P the object is also assumed too be 0 elasticity aka extreme hardness atm its at a very basic level.

the full stats are as follows.

500 meter object
will be traveling at 99.02 meters per second
or 356.4kph at the moment just before impact
and take ~10 seconds

1000 meter object
Will be traveling at 140.1 meters per second
or 504.4kph at the moment just before impact
and take ~14 seconds

i have gotten a much better understanding of all the different forces and how the act on objects tonight. i still have a lot of learning too go but i am certainly in a much better position than i was yesterday :)

Quote
Also a question for when/if you implement  wind resistane... If you shoot a bullet straight down.. How will its speed behave?

if it was in a vacuum that would be a lot more simple too answer  ;D wind resistance is coming tomorrow so although i have some ideas i will need too try a few calcs out also is it a standard pistol? what sort of power are dealing with?
Challenge Trophies Won:

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Re: messing with newtons laws of physics
« Reply #7 on: January 05, 2014 »
Thanks :)

lets consider .45 ACP (185gr) as our example.
speed leaving the barrel is 373 m/s ..
Energy is 835 J
Diameter is 11.5 mm
Weight  15g

see http://en.wikipedia.org/wiki/External_ballistics for some models on the physics of bullets in air. :)


Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: messing with newtons laws of physics
« Reply #8 on: January 05, 2014 »
excellent link there nikin! k++

wind resistance is going too be extremely hard too emulate and all the properties that need attaching too each object for there behavior too mimic the real world..

for today i have decided too test galileo's theory that if a ball was placed on the edge of a bath tub and no force of friction were too be applyed against its motion it would roll down the ramp, along the bottom, and up the other side too exactly the same height as it started. this behavior would continue forever as in the case of newtons first law an object without the presence of an unbalanced force will keep doing what its doing  :)
« Last Edit: January 05, 2014 by ninogenio »
Challenge Trophies Won: