First of all, this is a fun question that I have seen from here. We have a rectangular prism with dimension $30\times12\times12$ cubic inches. Assume that there is an ant at the blue point 1 inch above from $xy$ plane and mid point of $y$ direction, i.e. coordinate of ant is $(30,6,1)$ and there is some honey at red point 11 inch above from $xy$ plane and mid point of $y$ direction, i.e. coordinate of honey is $(0,6,11)$. Question: What is the minimum path that ant reaches to honey? I thought I could solve it using Mathematica. Here is my starting point.
Graphics3D[{Opacity@0.5, Cuboid[{0, 0, 0}, {30, 12, 12}], Red,
Sphere[{0, 6, 11}, 0.5], Blue, Sphere[{30, 6, 1}, 0.5]},
Boxed -> False]
Best I can do is this:
pInitial = {30, 6, 1};
p1 = {30, 0, z};
p2 = {x, 0, 12};
p3 = {0, y, 12};
pFinal = {0, 6, 11};
f = EuclideanDistance[pInitial, p1] + EuclideanDistance[p1, p2] +
EuclideanDistance[p2, p3] + EuclideanDistance[p3, pFinal]
$f(x,y,z)=\sqrt{\left| x\right| ^2+\left| y\right| ^2}+\sqrt{\left| 30-x\right| > ^2+\left| z-12\right| ^2}+\sqrt{\left| y-6\right| ^2+1}+\sqrt{\left| > 1-z\right| ^2+36}$
sol = NMinimize[f, {x, y, z}]
{40.7185, {x -> 12.0591, y -> 5.54055, z -> 3.75679}}
With[{p1 = p1 /. Last@sol, p2 = p2 /. Last@sol, p3 = p3 /. Last@sol},
Graphics3D[{Opacity@0.5, Cuboid[{0, 0, 0}, {30, 12, 12}], Red,
Sphere[{0, 6, 11}, 0.5], Blue, Sphere[{30, 6, 1}, 0.5], Opacity@1,
Black, Thick,
Line /@ {{pInitial, p1}, {p1, p2}, {p2, p3}, {p3, pFinal}},
Magenta, Sphere[#, 0.5] & /@ {p1, p2, p3}}, Boxed -> False]]