Constant Velocity Baseball
The great thing about physics is that we can start off with the simplest model possible and then just continue to make it slightly more complicated. So, what is the easiest way to show the motion of a pitched baseball? Let's just assume it travels from the pitching mound to the plate with a constant velocity of 85 mph (38 m/s). Oh, let's say the distance from mound to plate is 60 feet (18.3 meters).
Here's how this will work. We can break this motion into very small intervals of time—let's go with 0.01 seconds. At the beginning of this time interval, the ball will have some position, let's call it r1. If the velocity is v, then using the definition of average, I can find the position at the end of this interval. I will call this second position r2. Yes, these are vector quantities. That's not very important now, but it will be for later steps. Here is how I would calculate this second position.
This calculation is simple enough that you could do it on paper. But if the baseball takes even 1 second to travel to the plate, a time interval of 0.01 seconds would mean 100 calculations. No one has time for that. Instead, I'm going to make a computer do it. Computers don't complain (very much).
Here is the code for this constant velocity baseball. Yes, there might be some complicated stuff in there (just so I can draw the baseball)—but it really shouldn't be too bad. Oh! You can even edit the code and rerun it. You know...for fun. Click the "play" button to run it and the "pencil" to go back to edit mode.
Really, the most important part of this code is line 30.
Baseball With a Gravitational Force
The constant velocity baseball was boring and too easy. But notice that even with the oversimplification of constant velocity, it was still fairly useful. I could use it to calculate the time it takes the ball to get to the plate and even get a visual representation of the motion. But as usual, we can make this better by adding to the code.In this case, let's add the gravitational force to the ball. This force depends on the mass of the ball and the gravitational field (g) with a value of about 9.8 Newtons per kilogram. Now that there is a force on the ball, it won't travel at a constant velocity. Instead, this force will change the ball's momentum (where momentum is the product of mass and velocity). This momentum is updated during each time interval in a manner very similar to the way the position is updated.
In order to make this work, I only need to add three lines to the previous model. Yes, only three lines—I could technically do it with just two lines. The first line adds an initial vector direction to the baseball so that you can "throw it" at different angles. Here are the other two lines.
This just calculates the vector force (remember that g is a vector) and then uses this to update the momentum. Here is the rest of the code.
I have two quick comments. First, remember that this is a top view. Just to be clear. Second, we had to cheat to model this motion. OK, we could have done this without cheating—we just cheated for fun. Where is the cheat? It's back in that position update line (in this new code it's in line 34). The problem is that we updated the momentum (and thus the velocity) but we used the final velocity instead of the average velocity to find the new position. That's wrong. But with a small time interval, it's just a little bit wrong. Trust me, everything will work out fine.
Baseball With Air Resistance
If we want a more realistic baseball, we need another force—the air resistance force. As the ball moves through the air, there is a force pushing in the opposite direction of the ball's velocity. This is the air resistance. Although it's really a very complicated interaction between the ball and all the air molecules, we can still get a fairly nice model with the following equation.
Don't freak out. I'm going to go over each term in this expression.
- ρ is the density of the air (about 1.23 kilograms per cubic meter).
- A is the cross sectional area of the ball. This would be the area of a circle with the radius of the ball.
- C is a drag coefficient. This parameter depends on the shape of the object. For a baseball, I'm going to use a value of about 0.4—but this is difficult to pin down.
- Finally, of course v is the velocity, but what about the v with the "hat" over it? That is called v-hat. True. It's a unit vector in the direction of the velocity vector. This means that it has a magnitude of 1 such that it doesn't change the total air force. It's there to make this whole expression a vector.
Let's add this to the code.
The final position of the ball isn't that much different than in the case without air drag. The ball only moves a short distance, so the air drag doesn't have too much time to change the ball's momentum. But still—it's there. Here's some homework for you. Try changing the drag coefficient and see how much that alters the final position of the ball.
Baseball With the Magnus ForceThis is it. This is what you were waiting for. Just like the air resistance force, the Magnus effect is an interaction between the ball and the air. The difference is that this force is due to a spinning ball. As the ball both moves and spins, the friction between the surface of the ball and the air sort of pulls the air off to the side. This change in momentum of the air produces a force on the ball in the other direction. This diagram might help.
The direction of this Magnus force is perpendicular to both the velocity vector and the angular velocity vector (which is in the direction of the axis of rotation). The magnitude of the force depends on the velocity, the angular velocity, the area of the ball, the density of air and a Magnus coefficient (CM). As an equation, it looks like this:
Yes, that F-hat vector at the end doesn't really tell you much except for the direction of the force. I can calculate this direction using the cross product (which I really shouldn't get into too much):Before I put that force into the code, I need to first find that Magnus coefficient (CM). According to this paper—"The effect of spin on the flight of a baseball" (A Nathan)—there are several ways to calculate the coefficient. From that paper, the coefficient depends on the speed, angular velocity, and type of surface. There is an experimental table to look up the value, but it seems it should be between 0.2 and 0.3. Just for fun, I'm going with 0.3. I also increased the air resistance coefficient and put the angular velocity at 2000 rpm. Here's what I get.
Looking at the output, this model gives a horizontal deviation of almost a meter (about 3 feet). Yes, this is a crazy case. But what makes the ball look so crazy? I suspect that it's a combination of the camera angle and the curving ball. If I was better at coding, I could get the virtual camera to be in the same position as the real camera at that baseball game. But because you are looking from behind the pitcher, the deviation of the ball looks even more extreme.
But in the end, I'm not a baseball expert. I just know how to model stuff with code. And now you know how too.
- How Loon's balloons find their way to deliver the internet
- Did this international drug dealer create bitcoin? Maybe !
- Cold War–era bunker mania forever altered Albania
- The “manosphere” and the challenge of quantifying hate
- Fear, misinformation, and measles spread in Brooklyn
- 💻 Upgrade your work game with our Gear team’s favorite laptops , keyboards , typing alternatives , and noise-canceling headphones
- 📩 Want more? Sign up for our daily newsletter and never miss our latest and greatest stories