The magnitude of the drag force is F=-b*V[sup]2[/sup] and the direction of the force is the same as velocity.

So we can calculate the force component in x direction as Fx=-b*V[sup]2[/sup]*Vx/|V|; (i.e. calculate inner product between F and univ vector in the direction of velocity vector.)

You can download EJS source code and load it into ejs

Or Click [b]load ejs as signed applet[/b] button to load ejs into your browser and find out how it was calculated in the program!