Minecraft Physics: Steve in Drag

An object falling under constant acceleration g travels a distance h in an amount of time t given by

h = v_ot+\frac{1}{2}gt^2

where v_o is the object's starting velocity.  For an object dropped from rest, v_o=0.  Plugging that in and solving for g, we find

g=\frac{2h}{t^2}   (1)

Using this equation, we can approximate the acceleration due to gravity in Minecraft by timing how long it takes something to fall some distance.  This model assumes constant acceleration, which means it ignores things like drag forces from air resistance.  It turns out, Minecraft actually does have air resistance, but we will get there a bit later.

Youtuber nopefully used the above approximation to determine the gravitational acceleration of sand blocks (further analyzed here).  Since then, though, the addition of command blocks and scoreboards provide a simple way to time things in game, so that's the approach I'll take.

Experiment

The dropper platform

Figure 1: The dropper platform.

Timer stop and reset

Figure 2: Timer stop and reset. The clock circuit is in the background.

The experiment is simple: jump off of stuff, time it with command blocks, and plug the result in the above equation (1) to figure out the gravitational acceleration of a player.  For timing, I used Sethbling's stopwatch design.  The timer-starting command block (figure 1) is activated by a lever which also triggers a trapdoor, causing you to fall onto a pressure plate below, stopping the timer (figure 2).

I repeated this experiment five times at three different heights.  The data is in the table below (remember, a Minecraft block is 1 meter on each side):

Table 1: Results
Height (m) Average Fall Time (s) Acceleration (m/s2)
10 0.94 22.63
20 1.34 22.28
40 1.88 22.63

So using model (1), Minecraft's gravitational acceleration is around 23 m/s2.  But as I mentioned above, we're neglecting air resistance.  There isn't an easy way to experimentally measure the air resistance, but luckily a video game provides us with something that nature does not: the source code.  So let's cheat a little bit and take a look under the hood.

Cheating

In the EntityLivingBase class, there's a method named moveEntityWithHeading that is called 20 times per second (each "tick"), updating the entity's velocity.  If there isn't a block under the living entity (in other words, it's falling), the downward velocity is increased by 0.08 and decreased by 2% each tick.  This means there's a constant acceleration component that is 0.08 blocks/tick2 = 32 m/s2 and a drag force that is directly proportional to the velocity.  32 m/s2 is a lot different than our measured 23 m/s2, so clearly the drag force is not something that can be ignored.  Also, 32m/s2 is over 3 times greater than the gravity on Earth!  (An inventory of cobble is seriously heavy.)

On Earth, the gravitational acceleration is about 9.8m/s2 near the surface, and is the same for all objects regardless of how much they weigh.  This isn't the case in Minecraft, as you can see in the more detailed table on Minecraft wiki.  The "drag" contribution is also different for different entities (which is slightly more realistic since air resistance depends on the size and shape of the object).

 

Fluid Dynamics

The existence of a non-negligible drag force complicates the task of experimentally determining Minecraft's gravitational acceleration.  But it also means that we have a more fun differential equation to play with!  We can start out by writing down the equations of motion for the object falling.  From the source code, we know that the drag force is proportional to the velocity, so we can use a linear drag model for the forces:

ma=mg - kv

where m is the object's mass, a is the total acceleration, g is the acceleration due to gravity, k is some sort of drag coefficient and v is the object's velocity.  Remembering from physics class that acceleration is the first derivative of velocity with respect to time (denoted \dot{v}), we can substitute a=\dot{v}.  Doing that and diving both sides by m gives us an equation for the total acceleration:

\dot{v}=g-\frac{k}{m}v

The value of \frac{k}{m} is what's in the "Drag" column in the Minecraft wiki tableSolving for the velocity as a function of time, we find

v(t) = \frac{mg}{k}(1 - e^{-\frac{k}{m}t})   (2)

We can take some values of g and \frac{k}{m} from the table and graph the velocity (equation 2) of each of the different entities as they fall:

The velocity increases for a bit, but the rate at which it increases (the acceleration) slows with time until the entity travels at a constant velocity.  This is called terminal velocity, and it's reached when the gravitational force and the force due to air resistance balance out.  You can see that a falling player can catch up to most other entities, except for fired arrows.*

You can see the raw data in a Google spreadsheet here.  I encourage you to try out this set up and Minecraft physics experiments.  Please share your findings!

 

*So if, for example, you're engaging in a PvP fight on Overcast Network and someone tries to jump out of the world to deny you a kill, look over the edge and shoot!  Your arrow has a chance of catching up to them.

Minecraft Calculus: River Crossing Escape

This is a classic introductory calculus problem, with a Minecraft theme.  This particular variation is inspired by example 4 in section 4.5 of Stewart's calculus.

I'll set the scene:  You're weaponless.  You have half a heart and you're being chased by a skeleton archer.  There's a river between you and your cabin.  You need to get to your cabin as quickly as possible!

In more "mathy" terms, you want to get from A to B.  There are three main ways you can do this:

  1. A to B directly, diagonally across the river
  2. A to C and then C to B
  3. At slight angle from A to D and then D to B

We know that swimming is slower than running, so option 1 isn't the best.  Option 2 involves the smallest time in the water, but also the longest distance traveled.

Option 3 is somewhere in between - you spend a bit more time in the water, but the total distance is decreased.  The travel time in this case depends on where exactly point D is.  To find the optimal path, we must find the position of D which minimizes the travel time.  This sounds like calculus!

Let x be the distance between points C and D.  In math terms, |CD|=x.

We first need an expression for the total time traveled in terms of x.  The basic equation for time traveled at constant speed is

t=\frac{distance}{speed}.

The first part of the trip is in the water where we travel from A to D.  We can use Pythagorean's theorem to get this distance as |AD|=\sqrt{x^2+w^2}.  Assuming that we can travel at a speed of v_w in the water, the time for this part is

t_w=\frac{\sqrt{x^2+w^2}}{v_w}.

The land part of the trip involves traveling what's left over of l after having already traveled x, so |DB|=l-x.  Traveling at v_l on land, the time for this part of the trip is

t_l=\frac{l-x}{v_l}.

The total trip time, T(x), is just the sum of these two.

T(x)=\frac{\sqrt{x^2+w^2}}{v_w}+\frac{l-x}{v_l}     (1)

To optimize this function with respect to x, we need to find where it is stationary and then verify that this point is a minimum.  This means we want to find a place where the function isn't changing with small changes in x.  In other words, we want to find a spot where the derivative is zero.

Taking the derivative gives:

T'(x)=\frac{x}{v_w\sqrt{x^2+w^2}}-\frac{1}{v_l}

Setting this equal to zero, we can solve for x:

x=\frac{v_ww}{\sqrt{v_l^2-v_w^2}}     (2)

Let's plug in some numbers!  In Minecraft, you can swim at about 2.2 m/s and sprint at 5.6 m/s.  Let's take the river width w to be 7 blocks (1 block = 1 meter).  Plugging in, we find that x=2.9.  At this point, though, we can't tell if this is a maximum or a minimum.  One way to find out is to examine the curvature of the function at this point by using the 2nd derivative:

T''(x)=\frac{1}{v_w\sqrt{x^2+w^2}}(1-\frac{x^2}{x^2+w^2})

Plugging in x=2.9, we see that T''(2.9)=0.04 which, being positive, means that x=2.9 is a minimum point for T(x).  Visually:

crossing

 

So if you want to get to your cabin as quickly as possible, the fastest route is to swim across the river to a point D that is 2.9 meters from point C and then run the rest of the way.

This is actually a general problem.  Try replacing the speeds I used with speeds for soul sand, crouching and walking, a boat, etc. and see what happens!  Particularly, what happens to (2) if you can travel more quickly in the water than on land?

 

Scratch Work

Finding T'(x):  First, rewrite the square root as a power,  T(x)=\frac{(x^2+w^2)^{\frac{1}{2}}}{v_w}+\frac{l-x}{v_l}

Differentiating, using the chain rule on the first term,  T'(x)=\frac{\frac{1}{2}(x^2+w^2)^{-\frac{1}{2}}(2x)}{v_w}-\frac{1}{v_l}=\frac{x}{v_w\sqrt{x^2+w^2}}-\frac{1}{v_l}

Finding T''(x):  Starting with T'(x)=\frac{(x^2+w^2)^{-\frac{1}{2}}x}{v_w}+\frac{1}{v_l}, we differentiate with respect to x.  Note that the derivative of \frac{1}{v_l} with respect to x is 0, so we only have to deal with the first term.  Using the product rule and chain rule:

T''(x)=\frac{-\frac{1}{2}(x^2+w^2)^{-\frac{3}{2}}(2x^2)}{v_w}+\frac{(x^2+w^2)^{-\frac{1}{2}}}{v_w}

Cleaning up with some algebra:

T''(x)=\frac{-x^2}{v_w(x^2+w^2)^{\frac{3}{2}}}+\frac{1}{v_w\sqrt{x^2+w^2}} =\frac{1}{v_w\sqrt{x^2+w^2}}(1-\frac{x^2}{x^2+w^2})

 

From the notes: Two masses on a string going through a hole

Two masses on a string going through a hole.  Yeah, that's the stuff we learn about in physics class.  Anyway, this is the first in a (possibly) series of posts where I work out some problem from my lecture notes or homework.  The reason for doing this is because 1) there's a (small) chance it will be useful or interesting to someone else, and 2) the drawn out process of typing this up and thinking about how to explain it helps me study.

Figure 1, two masses on a string going through a hole.

 

Consider two masses connected by a string (figure 1).  The ideal string passes through a hole in a plate which is parallel to the x-y plane.  One mass, m is sitting on the plate and is free to rotate about the hole with no friction.  The second mass, M, is hanging below the plate and moves only in the vertical z direction under the influence of gravity.   The total length of the string is l and we define r ands to be the distances between the hole and m and M, respectively, so that l=r+s.

We can use Lagrangian mechanics to explore the system.  In Cartesian coordinates, the total kinetic energy is the sum of the kinetic energy of each mass:

T=\frac{1}{2}m(\dot{x_{m}}^2+\dot{y_{m}}^2+\dot{z_{m}}^2)+\frac{1}{2}M(\dot{x_{M}}^2+\dot{y_{M}}^2+\dot{z_{M}}^2)      (1)

where we've used the dot notation for time derivatives.

Considering that m is only rotating about the z axis and M is moving only vertically, it makes sense to consider switching to a more reasonable coordinate system.  We can transform to cylindrical coordinates with:

x_{m}=r\cos\theta

y_{m}=r\sin\theta

z_{m}=0

x_{M}=y_{M}=0

z_{M}=-s=-(l-r)

Taking derivatives of these with respect to time and inserting them into (1), we can rewrite the kinetic energy in cylindrical coordinates as

T=\frac{1}{2}m(\dot{r}^2+(r\dot{\theta})^2)+\frac{1}{2}M\dot{r}^2

where r and \theta are now the generalized coordinates of the system.  The potential energy depends only on the height of M since m is confined to sit on the plate, so

V=-Mg(l-r)

With T and V we can write the Lagrangian L=T-V:

L=\frac{1}{2}m(\dot{r}^2+(r\dot{\theta})^2)+\frac{1}{2}M\dot{r}^2+Mg(l-r)

We see that \theta does not appear in the Lagrangian, which means that the generalized momentum corresponding to \theta is a conserved quantity:

p_{\theta}=\frac{\partial L}{\partial \dot{\theta}}=mr^2\dot{\theta}=rmv_m=a     (2)

a can be identified as the angular momentum of mass m.

We can also look at the total energy E=T+V:

E=\frac{1}{2}m(\dot{r}^2+(r\dot{\theta})^2)+\frac{1}{2}M\dot{r}^2-Mg(l-r)     (3)

From (2) we see that \dot{\theta}=\frac{a}{mr^2}.  Substituting this in (3) gives

E=\frac{1}{2}m\dot{r}^2+\frac{a^2}{2mr^2}+\frac{1}{2}M\dot{r}^2-Mg(l-r)

We can separate the constants on the left hand side and use the remaining terms to define an effective potential V'(r):

\frac{E+Mgl}{m+M}=\frac{1}{2}\dot{r}^2+\frac{1}{2}\frac{a^2}{m(m+M)r^2}+\frac{Mgr}{m+M}

V'(r)=\frac{1}{2}\frac{a^2}{m(m+M)r^2}+\frac{Mgr}{m+M}

Imagine m is rotating about the hole.  This means there will be some centripetal (or centrifugal, depending on your reference system) acceleration which will pull the hanging mass M up.  We want to find r such that the force is an extremum.  In other words:

\frac{\partial V'}{\partial r}=0

Setting the derivative equal to zero gives

\frac{-a^2}{m(m+M)r^3}+\frac{Mg}{m+M}=0

And solving for r:

r=\sqrt[3]{\frac{a^2}{mMg}}

which gives the radius of "orbit" of mass m about the hole for a given angular momentum a such that M remains suspended in the air.