Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: tubes program not working in version 9
Replies: 2   Last Post: Dec 9, 2012 10:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mark McClure

Posts: 193
Registered: 9/12/07
Re: tubes program not working in version 9
Posted: Dec 9, 2012 10:58 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Fri, Dec 7, 2012 at 1:39 AM, Roger Bagula <roger.bagula@gmail.com> wrote:

> The tubes program was written for an earlier version
> ( works in version 5 I think) by Mark McClure
> and has worked fine for literally years.
> I haven't got a clue what has gone wrong.


I originally developed that code for version 2. Of course, since V7,
there's a Tube primitive. Thus, perhaps the easiest way to generate a
tube is as follows.

trefoil[t_] = {Sin[3 t], Sin[t] + 2 Sin[2 t], Cos[t] - 2 Cos[2 t]};
ParametricPlot3D[trefoil[t], {t, 0, 2 Pi},
PlotRangePadding -> 2, ViewPoint -> {8, 0, 0},
Boxed -> False, Axes -> False, PlotPoints -> 100,
PlotStyle -> Directive[Lighter[Blue], Specularity[White, 40]]] /.
Line[pts_] -> Tube[BSplineCurve[pts], 0.5]

Here's a working version of TubePlotFrenet, if you prefer. As Bob
points out, simplification is really necessary in V9.

trefoil[t_] = {Sin[3 t], Sin[t] + 2 Sin[2 t], Cos[t] - 2 Cos[2 t]};
TubePlotFrenet[curve_List, {var_, min_, max_}, radius_, opts___] := Module[
{tangent, unitTangent, normal, unitNormal, biNormal},
tangent = D[curve, var];
unitTangent = Simplify[tangent/Sqrt[tangent . tangent]];
normal = D[unitTangent, var];
unitNormal = Simplify[normal/Sqrt[normal . normal]];
biNormal = Simplify[Cross[unitTangent, unitNormal]];
ParametricPlot3D[Evaluate[curve + radius*Cos[s]*unitNormal +
radius*Sin[s]*biNormal],
{var, min, max}, {s, 0, 2*Pi}, opts]
];
TubePlotFrenet[trefoil[t], {t, 0, 2 Pi}, 0.5,
Axes -> None, Boxed -> False, ViewPoint -> {10, 0, 0},
PlotPoints -> {64, 16}]

An alternative approach is to take the cross product of the unit
tangent with an arbitrary vector.

trefoil[t_] = {Sin[3 t], Sin[t] + 2 Sin[2 t], Cos[t] - 2 Cos[2 t]};
TubePlot[curve_List, {var_, min_, max_}, radius_,
crossVector_List: {1, 1, 1}, opts___] := Module[
{tangent, unitTangent, normal, unitNormal, biNormal},
tangent = D[curve, var];
unitTangent = Simplify[tangent/Sqrt[tangent . tangent]];
normal = Cross[tangent, crossVector];
unitNormal = Simplify[normal/Sqrt[normal . normal]];
biNormal = Simplify[Cross[unitTangent, unitNormal]];
ParametricPlot3D[Evaluate[curve + radius*Cos[s]*unitNormal +
radius*Sin[s]*biNormal],
{var, min, max}, {s, 0, 2*Pi}, opts]];
TubePlot[trefoil[t], {t, 0, 2 Pi}, 0.5, {1, 0, 0},
Axes -> None, Boxed -> False, ViewPoint -> {10, 0, 0},
PlotPoints -> {64, 16}]

Hope that helps,
MM




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.