Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12714 > unrolled thread
| Started by | Mark McClure <mcmcclur@unca.edu> |
|---|---|
| First post | 2012-12-09 15:58 +0000 |
| Last post | 2012-12-09 15:58 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: tubes program not working in version 9 Mark McClure <mcmcclur@unca.edu> - 2012-12-09 15:58 +0000
| From | Mark McClure <mcmcclur@unca.edu> |
|---|---|
| Date | 2012-12-09 15:58 +0000 |
| Subject | Re: tubes program not working in version 9 |
| Message-ID | <ka2cek$7g1$1@smc.vnet.net> |
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
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web