Skip to content

04. Fastest descent with a depth limit

Descending deeper builds speed, but what happens if the track cannot go below a prescribed depth? A segment along the floor appears, changing the shape of the fastest path.

ItemDefinition
StatesHorizontal position xx, depth yy, speed vv
ControlAngle θ\theta from downward vertical
ObjectiveMinimize tft_f
PhasesOne phase, 40 nodes, free final time
New conceptsState bounds as path constraints; a boundary arc

As in Example 03, a ball slides without friction under gravity. Here the endpoint is fixed at (1,0.2)(1,0.2) m, and a floor limits depth to 0.3 m. Without the floor, the fastest path descends below the destination, then climbs back up. We ask how the floor changes that solution. Gravity is 9.81 m/s².

Depth is positive downward. Angle 00 points down, 90∘90^\circ is horizontal, and angles above 90∘90^\circ climb upward:

x˙=vsin⁡θ,y˙=vcos⁡θ,v˙=gcos⁡θ.\dot{x}=v\sin\theta,\qquad\dot{y}=v\cos\theta,\qquad\dot{v}=g\cos\theta.

On the uphill segment, cos⁡θ<0\cos\theta<0 and the ball slows down. Energy conservation still gives v=2gyv=\sqrt{2gy}.

x(0)=y(0)=v(0)=0,x(tf)=1,y(tf)=0.2.x(0)=y(0)=v(0)=0,\qquad x(t_f)=1,\quad y(t_f)=0.2.

Terminal speed is not prescribed, but energy determines it as 2⋅9.81⋅0.2≈1.98\sqrt{2\cdot9.81\cdot0.2}\approx1.98 m/s.

0≤y≤0.3,v≥0,0≤θ≤π,0.01≤tf≤5.0\le y\le0.3,\qquad v\ge0,\qquad0\le\theta\le\pi,\qquad0.01\le t_f\le5.

The depth upper bound is the floor. Bounds apply at every node and therefore act as path constraints. The other bounds keep optimization within the intended physical range.

J=tf.J=t_f.
SymbolParameterValue
gggravity9.81 m/s²
lldistance1 m
yfy_ffinal_depth0.2 m
ymax⁡y_{\max}max_depth0.3 m

For time 0 to 0.7 s, let s=t/0.7s=t/0.7 and set

x=ls,y=yfs+0.2sin⁡(πs),v=2gy.x=ls,\qquad y=y_fs+0.2\sin(\pi s),\qquad v=\sqrt{2gy}.

The depth bulges downward and returns to the target. Angle increases linearly from 0 to 2 rad (about 115°).

The optimized track with depth increasing downward. The gray region is forbidden. The blue interpolant passes through 40 nodes; black dashed shows the unconstrained fastest track.
The optimized track with depth increasing downward. The gray region is forbidden. The blue interpolant passes through 40 nodes; black dashed shows the unconstrained fastest track.
Depth, speed, and angle in degrees. The red dotted line is the 0.3 m depth limit.
Depth, speed, and angle in degrees. The red dotted line is the 0.3 m depth limit.
Ball motion alongside depth, speed, and angle histories. The vertical cursor marks the current time.
  • Arrival time: 0.6242 s, slightly longer than the floorless value 0.6206 s.
  • Without the floor, maximum depth would be 0.358 m; with it, depth is limited to 0.300 m.
  • The path descends, follows the floor horizontally, then climbs. On the floor, angle is 90° and speed is constant.
  • Final angle: 125°; final speed: 1.981 m/s.

The floor blocks the deepest, fastest part of the unconstrained curve. The next best choice is to spend time at the greatest allowed depth, where speed reaches 2gymax⁡≈2.43\sqrt{2gy_{\max}}\approx2.43 m/s. A segment that remains on an active constraint, y=ymax⁡y=y_{\max}, is a boundary arc. Its control is fixed by the constraint: θ=90∘\theta=90^\circ keeps depth constant. Cycloid segments join this arc tangentially on entry and exit.

The floor excludes only a short part of the unconstrained path. Speed along the floor is still high, so the arrival-time increase is less than 1%.

Unlike Example 03, depth is fixed at the endpoint. The ball must climb from the floor to 0.2 m, so it arrives on an uphill segment rather than horizontally.

The rate of change of angle changes abruptly at the ends of the boundary arc. One polynomial rounds these corners. Since bounds hold only at nodes, interpolation can exceed the floor slightly, by around 10−510^{-5} m. More nodes make the corners clearer.

  • Set max_depth to 0.4. The floor lies below the unconstrained maximum depth (about 0.358 m), becomes inactive, and duration approaches 0.6206 s.
  • Set it to 0.25. The boundary arc becomes longer and duration rises to about 0.636 s.
  • Use solve(nodes=20) and compare the angle near the boundary-arc transitions with the 40-node result.
Terminal window
uv run python examples/04_constrained_descent.py

View the Python source on GitHub.