MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Tube Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17706] Re: Tube Plot
  • From: hidekazu at aqua.biwako.ne.jp (Hidekazu Takahashi)
  • Date: Sun, 23 May 1999 02:25:25 -0400
  • Organization: Biwako Internet News server
  • References: <7i5b3d$fm0@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Joseph & Donna,

This is one aproach for Tube Plot.
Please paste and evaluate the following.

Off[ParametricPlot3D::"ppcom"]
al[{a_, b_, c_}] :=N[-If[a == 0 && b == 0, If[c > 0, Pi/2, -(Pi/2)],
ArcTan[c/Sqrt[a^2 + b^2]]]]
be[{a_, b_, c_}] :=N[Module[{d},If[a==0,Which[b>0, Pi/2, b == 0,
0, b < 0, (3Pi)/2],d = ArcTan[b/a];Which[a < 0, d + Pi,
a > 0 && b >= 0, d,a > 0 && b < 0, d + 2Pi]]]]
poi[{a_, b_, c_}, {x1_, y1_, z1_}, r_, t_] :=Module[{aa, bb, ry, rz},
aa = al[{a, b, c}]; bb = be[{a, b,c}];ry = {{Cos[aa], 0, Sin[aa]},{0, 1, 0},
{-Sin[aa], 0, Cos[aa]}};rz = {{Cos[bb], -Sin[bb], 0},{Sin[bb], Cos[bb], 0},
{0, 0, 1}};N[r rz.ry.{0,Sin[t],Cos[t]} + {x1, y1, z1}]]
rope[c_, h_, r_, opts___] :=Module[{vec, s}, vec = D[c, First[h]];
ParametricPlot3D[poi[vec, c, r, s], {s, 0, 2*Pi}, h, Boxed -> False,
Axes -> False, opts]]

rope[{Cos[2 t] (1+.5Cos[3 t]),(1+.5 Cos[3 t]) Sin[2 t],-Sin[3 t]},
{t,0,2Pi},.2,PlotPoints->{10,60}]
rope[{t, Sin[t],0},{t,0,2Pi},.5]
rope[{t, Sin[t],0},{t,0,2Pi},.5 Abs[Sin[t]]]

Hidekazu Takahashi
<Mail> hidekazu at pop.biwako.ne.jp
<URL> http://www.biwako.ne.jp/~hidekazu/


Joseph & Donna Post <jpost at panix.com> wrote in message
news:7i5b3d$fm0 at smc.vnet.net...
>     I've been looking for a routine that does "tube plots" in
> Mathematica, i.e., 3D plots showing cylindrical tubes, possibly of
> variable radius, constructed around parametrically described space
> curves.   One routine that I looked at in Mathsource, as well as others
> that I've seen, are based on the construction of a three-D coordinate
> system at every point in the curve, with the three unit vectors being
> the normalized versions of: (a) tangent vector to the curve, (b) a
> second vector based on the derivative of the tangent vector (which is
> perpendicular to the tangent vector and follows the "twist" of the
> curve), and (c) a third vector equal to the cross product of the first
> two.  Once this coordinate system is defined for each point on the
> curve, points on the tube surface are defined as (Sin[theta] * tube
> radius * second coordinate vector) + (Cos[theta] * tube radius * third
> coordinate vector).  The tube surface is draw by ParametricPlot3D, with
> the two parameters being theta (which varies from 0 to 2Pi), and the
> single parameter defining the curve.  Well and good.
>
>     The problem comes when trying to draw a tube around a straight
> line.  Although plotting a cylinder might seem like too trivial a
> problem to use a Tube Plot routine for, tube plotting is in fact a very
> easy way to plot surfaces that can be described by a tube of variable
> radius tube around a straight line.  I solved this problem by writing a
> separate routine for tubes around straight lines, and then using that
> routine or the original one depending upon whether the derivative of the
> tangent vector with respect to the space curve parameter was or was not
> identically zero.  That works fine, mostly.
>
>     This still leaves a problem, however, where the derivative of the
> tangent vector with respect to the space curve parameter is zero not
> identically, but at a point.  An example is the space curve {t, Sin[t],
> 0}, a simple sine wave.  The tube plotting routine squeezes the tube to
> a point at the inflection points of the curve (i.e., where it crosses
> the x axis), because the derivative of the tangent vector (and therefore
> the second coordinate vector) become zero vectors at that point.  There
> are also a number of error messages generated that result from
> divide-by-zero's during the normalization process.
>
>     Any suggestions for how to deal with this problem?
>
>     Thanks.
>
>                                                             -- Joseph
> Post
>
>


  • Prev by Date: Re: axes with arrows
  • Next by Date: Re: MASH: Mathematica Scripting Hack
  • Previous by thread: Re: Tube Plot
  • Next by thread: special characters in EPS graphics