Spider and Fly Problem

Author

Eric W. Weisstein
April 25, 2024

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/SpiderandFlyProblem.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/SpiderandFlyProblem.html.

©2024 Wolfram Research, Inc. except for portions noted otherwise

Diagram

With[{
corners=Join[
Table[{{0,12j},{30,12(j+1)}},{j,0,3}],
{{{-12,12},{0,24}},{{30,36},{42,48}}}],spider={32,42},fly={-2,18}},
Graphics[{
FaceForm[None],EdgeForm[Black],Rectangle@@@corners,Text["end wall",#]&/@{{-6,22},{36,46}},
Text["side wall",#]&/@{{15,6},{20,27}},
Text["ceiling",{15,42}],Text["floor",{15,21}],
{Red,Line[{spider,fly}],Dashed,Line[{fly,Diagonal[{spider,fly}],spider}]},
{AbsolutePointSize[10],Blue,Point[fly],Brown,Point[spider]},
Text["fly",fly-{2.5,0}],Text["spider",spider+{4.5,0}],
{FontSlant->Plain,Text@@@{{32,{15,16}},{24,{34,30}},{30,{15,50}},{12,{36,50}},{12,{44,43}},{40,{15,32}}}}
},BaseStyle->Directive[14,Italic,FontFamily->"Times"]]
]

Figure

Spider[s_]:=Module[{pts={{0,{30,6,11}},{5/4,{30,21/4,12}},{10,{23,0,12}},{30,{7,0,0}},{155/4,{0,21/4,0}},{40,{0,6,1}}}},
#[s]&/@(Interpolation[#,InterpolationOrder->1]&/@(Transpose[{pts[[All,1]],#}]&/@Transpose[pts[[All,-1]]]))
]

SpiderPlot[tmax_]:=Module[{segments,s,t,paths,spider},
segments=If[tmax==0,{},ParametricPlot3D[Spider[t],{t,0,tmax}][[1]]];
Graphics3D[{
PointSize[.03],
Thickness[.01],segments,
{Blue,Point[{0,6,1}]},
{Brown,Point[Spider[tmax]]}
},
PlotRange->{{0,30},{0,12},{0,12}}]
]

SpiderPlot[39]

Manipulate[SpiderPlot[t],{t,0,40}]

Export["/Users/eww/Sites/mathworld.wolfram.com/htdocs/images/gifs/SpiderAndFlyPath.gif",Table[SpiderPlot[t],{t,0,40,1}]]