Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a 2D golf game in VB.NET 2005, but I am stuck on how to implement air or wind drag that should affect the ball.

Already I have these equations for projectile:

Vo                            `<-Initial velocity of golfball when hit or fired`

Vx=VoCos(theta)               `<-Vertical component of velocity of golfball`

Vy=VoSin(theta)-gt*           `<-Horizontal component of velocity of golfball`

X=VoCos(theta)t              `<-Vertical dixtance of golfball`

Y=VoSin(theta)t-(0.5)g(t*t)  `<-Horizontal dixtance of golfball`

How do I add air drag to this equation to properly affect the velocity of the golf ball? I don't have any idea how to do it, has anyone worked with similar equations?

share|improve this question
up vote 9 down vote accepted

I'm not sure if there even exists a closed form for drag or wind, but it is quite easy to simulate in a step-wise fashion (like all the physics libraries do):

1) set your initial condition:

x, y, vx, vy , (for t = 0)

2) update position:

x += vx * dt, y += vy * dt , (where dt is the time elapsed since the last update)

3) calculate these velocity helpers:

vsquared = vx * vx + vy * vy and vlength = √(vsquared)

4) calculate drag force:

fdrag = c * vsquared , (where c is the coefficient of friction small!)

5) accumulate forces:

fx = (-fdrag * vx / vlength), fy = (-fdrag * vy / vlength) + (-g * mass) , (where mass is the mass of your golf ball)

6) update velocity:

vx += fx * dt / mass, vy += fy * dt / mass

That's basically Euler's Method for approximating those physics.


A bit more on how the simulation as requested in the comments:

  • The initial condition (t = 0) in your case is

x = 0, y = 0,

vx = v0 * cos(θ),

vy = v0 * sin(θ)

It's basically the same as in your basic trajectory formula where every occurrence of t is replaced by 0.

  • The kinetic energy

KE = 0.5 * m * (V * V) = 0.5 * m * vsquared

is valid for every t (see vsquared as in (3)

  • The potential energy

PE = m * g * y

is also always valid.

  • If you want to get the current (x,y) for a given t1 what you need to do is initialize the simulation for t = 0 and do small dt updates until t = t1

  • If you already calculated (x,y) for a t1 and you want to know their values for a t2 where t1 < t2 all you need to do is calculating those small dt update steps from t1 to t2


simulate(v0, theta, t1)
  dt = 0.1
  x = 0
  y = 0
  vx = v0 * cos(theta)
  vy = v0 * sin(theta)
  for (t = 0; t < t1; t += dt)
    x += vx * dt
    y += vy * dt
    v_squared = vx * vx + vy * vy
    v_length = sqrt(v_squared)
    f_drag = c * v_squared
    f_grav = g * mass
    f_x = (-f_drag * vx / v_length)
    f_y = (-f_drag * vy / v_length) + (-f_grav)
    v_x += f_x * dt / mass
    v_y += f_y * dt / mass
  end for
  return x, y
end simulate
share|improve this answer
Thank you so much for this, i'll try it out an get back to you. – Smith Apr 15 '11 at 7:47
from these equations you provided, i'd like to get the current X & Y for a give time (t), should i replace my Vo with V_x and Vo with v_y? Also if i need to add the initial KE with which the ball was fired, will this KE=0.5*m*(V*V) be valid? – Smith Apr 15 '11 at 8:28
@Smith I'll edit my answer to account for your questions – LumpN Apr 15 '11 at 10:00
this is exactly what i did, and x is always negative, why? – Smith Apr 15 '11 at 11:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.