# 7. Motion under gravity¶

Motion under gravity, with or without strafing, is ubiquitous in Half-Life. In speedrunning, such questions are sometimes raised:

Is it possible at all to clear that gap?

What is the minimum long jump speed required to clear that gap?

How much speed boost is needed to jump over that wall?

How much speed boost is needed to clear that gap?

At what angle should I toss the MP5 grenade to hit the target?

Here we will attempt to answer these questions, and provide formulae or algorithms to solve many of these common cases.

## 7.1. Preliminaries¶

We will restrict discussions to a vertical plane, where the horizontal and vertical axes are denoted as the and axes respectively. We will assume all bodies have initial position at the origin .

Recall from classical kinematics that a particle under projectile motion (motion under the sole influence of gravity) with initial velocities , , and gravitational acceleration has final positions

In most of the discussions below, the equation for will remain unchanged, but the equation for will depend on whether strafing is done.

Recall from strafing physics that given initial velocity and strafing variables, the final horizontal speed and position after seconds of strafing is

Here, depends on the type of strafing. Possible values are or .

## 7.2. Position and a velocity component¶

In speedrunning situations, the final position is often given, and the goal would be to move from the current position, to the final position, subject to some constraints in one of the velocity components. For example, determining the minimum initial horizontal velocity needed to clear a gap by jumping and strafing alone (initial vertical velocity is known), or determining the minimum boost needed to reach a certain height (the final vertical velocity is zero).

Assuming initial and final positions and , we may be given just one of the following:

Knowing just one of these quantities is sufficient to solve the entire equation of motion in both axes.

### 7.2.1. Time constraint equation¶

The time it takes to reach the final position must be the same for both and directions. In other words, the position in both directions must reach the final position simultaneously. Solving the time in the vertical equation of motion yields

If strafing is performed, the time it takes to reach the final horizontal position is found to be

Then, must be satisfied for the body to reach the final position. This is the time constraint equation that will be used in later analyses.

Note also the maximum is achieved by having zero initial horizontal velocity, while keeping the other variables constant. This yields

The purpose of this quantity will be illustrated later as well.

### 7.2.2. Given ¶

With known, we can simply compute the horizontal time , and compute

The calculated initial vertical speed is guaranteed to reach the final position in the same time. However, the trajectory may take a different shape. That is, the path might either be strictly increasing or ends with a decreasing curve. To check this, we check the sign of the final vertical velocity. If the path is strictly increasing, we have

Observe that if increases while all else kept constant, the inequality will eventually be violated, resulting in a inverted bell shaped path. In addition, if , that is when the final position is below the starting position, then the inequality will always be violated regardless of .

### 7.2.3. Given ¶

TODO TODO

### 7.2.4. Given ¶

Firstly, the final height is reachable if , which ensures the square root in the equation give a real number. Notice that if then this condition will always hold, which is intuitive.

This is where we will make use of the described earlier. There are four different cases we need to handle. Namely, two from the the sign of the square root when computing , and two from the sign of . In most cases, taking the negative square root is desirable as this minimises the time . However, the negative square root may lead to , which must be rejected. The sign of indicates the need to manually slow down the horizontal motion (by taking a longer curve or stop strafing altogether). Namely, implies reaching the final position before reaching the final position. Therefore, the horizontal motion needs to be slowed, and no subsequent computation needs to be done. If , then the horizontal speed is not sufficiently high, and therefore the initial horizontal velocity is nonzero and an additional step is needed to compute its value.

In the last case, we must solve for the initial horizontal velocity from the time constraint equation. The time constraints equation cannot be solved analytically with any ease, therefore a numerical solution should be computed using any root finding algorithm. For example, the Newton’s method appears to work in many cases. For reference, the derivative of the time constraint equation needed for Newton’s method is

An alternative to the Newton’s method, but still require a numerical solution, is to solve the quartic equation

using a standard polynomial solver. Typically, there are two complex roots that do not satisfy the time constraint equation, and a root that is negative.

### 7.2.5. Given ¶

It is common to have the final vertical velocity given as well. For example, this gives the minimum required initial velocity to reach a the given height. Or, with this gives the maximum initial velocity such that the player is barely onground when landing on some platform.

The approach to solving this problem is very similar to that when given the initial vertical velocity. The only difference is the equation for , which must be rewritten in terms of , giving