Horizontal throw with air resistance
0.5vt must be a result of some misunderstandings of your own, but you resist to believe us.
For a falling ball (without air resistance):
Acceleration is constant (gravity)
Velocity increases linear with time
Position forms a parabola
Diagramm + code in this older post: http://www.gamedev.net/topic/672589-equations-of-motion-for-position-dependent-acceleration/
Ok, i've read the wikipedia article and wrote this code, hope it's correct.
It uses integration, analytical solution would be harder but i guess integration is what you want.
Thanks for your effort, i tried to apply the code to my project and it looks kind of better now but i am not sure why you use those values:
airDensity = 11.0f
i read about it on wikipedia and they said it is about 1.2 kg\m³?
I also read that the mass of the object has some influence in the air resistance but in your formula i don't see any mass?
What you say makes no sense.
0.5vt must be a result of some misunderstandings of your own, but you resist to believe us.
Sorry, my fault.
Also i did not read what those constants mean exactly and have no experience with drag simulation.
I just took the formula and can't help to find the proper values.
I also read that the mass of the object has some influence in the air resistance but in your formula i don't see any mass?
Good point, i've had that in but removed it for simplicity, assuming ball mass of one.
Bringing it back, we use mass to convert from drag force to drag acceleration:
float dragForceX = vx*vx * dragForceConstant * (vx > 0.0f ? -1.0f : 1.0f);
float dragForceY = vy*vy * dragForceConstant * (vy > 0.0f ? -1.0f : 1.0f);
float dragAccX = dragForceX / ballMass;
float dragAccY = dragForceX / ballMass;
Hi and thanks for your reply,
if i use a ball mass which is < 1 i get the strange effect, that the ball suddenly starts to gain acceleration like crazy?
var dragAccX = this.velocity.x*this.velocity.x * dragForceConstant * (this.velocity.x > 0 ? -1.0 : 1.0);
dragAccX /= parseFloat(document.getElementById("mass").value);
I've just tried those realistic values with various masses and the sim always looks good:
float ballRadius = 0.2f;
float ballMass = 0.1f;
float airDensity = 1.2f;
float dragCoefficient = 0.1f;
float dragForceConstant = 0.5f * airDensity * dragCoefficient * PI * ballRadius*ballRadius;
You can post your settings / more code / link to the site if you're sure it's wrong.