Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
1  
You only have to provide a path and a cross section to @J.M.'s TubePolygons[]. Please be more specific about your doubts. –  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
add comment

1 Answer 1

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]

Mathematica graphics

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]

Mathematica graphics

Get those lines:

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

Now use @JM's function:

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

Mathematica graphics

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]

Mathematica graphics

...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]

Mathematica graphics

share|improve this answer
    
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 –  belisarius Feb 26 '13 at 0:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.