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?
1 Answer
$\begingroup$
$\endgroup$
2
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]
-
$\begingroup$ 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? $\endgroup$ Feb 25, 2013 at 23:53
-
$\begingroup$ @rexacoatl That doesn't seem trivial at all $\endgroup$ Feb 26, 2013 at 0:00
TubePolygons[]
. Please be more specific about your doubts. $\endgroup$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 ascs
. And you will be done. $\endgroup$