Re: tubes program not working in version 9
- To: mathgroup at smc.vnet.net
- Subject: [mg129029] Re: tubes program not working in version 9
- From: Mark McClure <mcmcclur at unca.edu>
- Date: Sun, 9 Dec 2012 10:59:55 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20121207063953.888006934@smc.vnet.net>
On Fri, Dec 7, 2012 at 1:39 AM, Roger Bagula <roger.bagula at 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
- References:
- tubes program not working in version 9
- From: Roger Bagula <roger.bagula@gmail.com>
- tubes program not working in version 9