Due: Thursday 3/5 10:00am

Submission name: w07_drag

Calculate Drag

Drag is a force that “pushes” opposite to velocity. In order to calculate the drag force we need to figure out the direction it will apply and the magnitude of the force. The (simplified) Formula for Drag is:

\[{\overrightarrow F} = -\dfrac{1}{2} ||v||^2 C_d {\hat v}\]

What is this?

  • \(v\) Is the magnitude of the velocity vector. Luckily, we can get the magnitude using velocity.mag(), which returns a float value.
  • \(C_d\) is the coefficient of drag, this is different depending on the material (air, water, honey…).
  • \({\hat v}\) is the normalized velocity vector. This has the same direction as the velocity vector, but the magnitude is 1. Once again, we have a nice method for this. vector.normalize() will normalize a vector (it will modify vector, so don’t do this directly on velocity).

Add Drag

Start with the work from yesterday (but make a new sketch and submission). Add drag to your simulation as follows:

  • Add PVector getDragForce(float coef) to the Orb class. It should calculate and return a PVector representing drag as described above.
  • draw()
    • When an Orb reaches a height of 200 or more, calculate and apply a drag force.
    • Draw a rectangle from (0, 200) that takes up the lower half of the screen to help see when the drag force should be applied.

Reference Image:

a08-drag