- #1
daniel_dzc
- 2
- 0
So there it is me trying to program some simple physics for flying ball. I have done some research and generally I was always understanding physics very well. But what is happening in my application is not understandable for me, even tho I have checked everything twice and I think everything should have worked good.
So my physics is very simple, only gravity and air resistance, no spinning of ball etc.
My ball has few attributes, which are:
-position(in meters, I also assume that one 1px==1m),
-mass(in kg),
-radius(in meters),
-speed, which is basically a vector with direction and value (in m/s).
In physics engine I assume g=9.81 [m/s^2] and air density of q=1.2041 [kg/m^3].
Now that's how I calculate where to move the ball:
(1)I move the ball according to its actual speed vector.
(2)I calculate forces on the ball:
(4)I update the speed of the ball V1=V+a*t (time was 1 sec, but i still multiply it by time in case I want to change time intervals). I do that by simply adding 2 vectors (V and a) together.
My problem is: I tested it on a ball with:
-some start position with doesn't matter here
-mass of 0.2 [kg],
-radius of 0.01 [m],
-start speed of 200 [m/s] 45% upwards
Now the ball fly and it looks good. But when I change just the mass to let's say 0.6kg the ball actually fly further, like much further... Despite the fact that air density and gravity seems to be bigger.
Am I calculating something wrong? Or is that how it supposed to be?
Thanks for your help.
So my physics is very simple, only gravity and air resistance, no spinning of ball etc.
My ball has few attributes, which are:
-position(in meters, I also assume that one 1px==1m),
-mass(in kg),
-radius(in meters),
-speed, which is basically a vector with direction and value (in m/s).
In physics engine I assume g=9.81 [m/s^2] and air density of q=1.2041 [kg/m^3].
Now that's how I calculate where to move the ball:
(1)I move the ball according to its actual speed vector.
(2)I calculate forces on the ball:
- gravity: Q= g*m [thats a vector always directed downwards]
- air resistance: F= (0.47*q*A*v^2)/2 where:
- F is air resistance [N]
- 0.47 is drag coefficient for the ball (found on wiki)
- q is density of air
- A is the cross-sectional area of the ball
- v is speed of the ball
- the air resistance is always directed opposite to actual speed
- total force (Ft) on the ball by adding both vectors for Q and F
(4)I update the speed of the ball V1=V+a*t (time was 1 sec, but i still multiply it by time in case I want to change time intervals). I do that by simply adding 2 vectors (V and a) together.
My problem is: I tested it on a ball with:
-some start position with doesn't matter here
-mass of 0.2 [kg],
-radius of 0.01 [m],
-start speed of 200 [m/s] 45% upwards
Now the ball fly and it looks good. But when I change just the mass to let's say 0.6kg the ball actually fly further, like much further... Despite the fact that air density and gravity seems to be bigger.
Am I calculating something wrong? Or is that how it supposed to be?
Thanks for your help.