# How should a beginner figure out the context to use an expert answer provided on this forum?

J.M.'s answer to Extruding along a path related to custom cross-sections appears to answer a question I have been puzzling over for some time. I am interested in producing a tube with the stadium or stadion cross-section of oblong ductwork. I look at the code and am lost as to how to use it. Any suggestions?

• You only have to provide a path and a cross section to @J.M.'s TubePolygons[]. Please be more specific about your doubts. – Dr. belisarius Feb 19 '13 at 19:09
• Try ListPlot@cs you can see the cross section @J.M is using! So what you need to do is discretize your custom cross-section into some 2D points and declare it as cs. And you will be done. – PlatoManiac Feb 19 '13 at 19:21
• +1 simply for drawing my attention to a really cool answer I'd previously missed – Mr.Wizard Feb 19 '13 at 21:18

I'll just dissect a little @J.M.'s answer for you:

First define a path:

path = ParametricPlot3D[
BSplineFunction[{{0, 0, 0}, {1, 1, 1}, {2, -1, -1}, {3, 0, 1}, {4, 1, -1}}][u]
// Evaluate, {u, 0, 1}, MaxRecursion -> 1] Now extract the Line[] definitions from that plot:

pathL = First@Cases[path, Line[l_] :> l, Infinity]


Do the same with the cross section:

cs = ParametricPlot[BSplineFunction[{{0., 0.}, {1/4, 0.}, {1/2, 1/8}, {1/4, 1/4}, {0., 1/4}},
SplineClosed -> True][u] // Evaluate, {u, 0, 1}, MaxRecursion->1] Get those lines:

csL = First@Cases[cs, Line[l_] :> l, Infinity]


Now use @JM's function:

Graphics3D[{EdgeForm[], TubePolygons[pathL, csL]}, Boxed -> False] Edit

Another example:

path = First@Cases[ParametricPlot3D[5 {Sin[u u], Cos[u u], u}, {u, 0, 2 Pi},
MaxRecursion -> 1], Line[l_] :> l, Infinity];

cs = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};

Graphics3D[{EdgeForm[], TubePolygons[path, cs]}, Boxed -> False] ...And a last one:

path = First@ Cases[ParametricPlot3D[5 {Sin[u ], Cos[u ], 0}, {u, 0, Pi},
MaxRecursion -> 1], Line[l_] :> l, Infinity];

cs = First@ Cases[ParametricPlot[{Sin[2 u], Cos@u}, {u, 0, 2 Pi},
MaxRecursion -> 1], Line[l_] :> l, Infinity];

Graphics3D[{EdgeForm[], TubePolygons[path, cs]}, Boxed -> False] • That's great, Belisarius, got it to work. Many thanks. Any thoughts on how to make TubePolygons have the equivalent of CapForm["Round"] for Tube? – rexacoatl Feb 25 '13 at 23:53
• @rexacoatl That doesn't seem trivial at all – Dr. belisarius Feb 26 '13 at 0:00