MathGroup Archive 2012

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

Search the Archive

Re: Slow plotting of reflected parametric "butterflies"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124495] Re: Slow plotting of reflected parametric "butterflies"
  • From: Chris Young <cy56 at comcast.net>
  • Date: Sat, 21 Jan 2012 05:20:26 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jf8ql4$3pl$1@smc.vnet.net> <jfb358$hr6$1@smc.vnet.net>

I'm thinking that it's much safer programming style to always isolate 
any functions using Set (rather than SetDelayed) inside a module; 
otherwise aren't there "exposed" global variables? If these get 
assigned some value, wouldn't the function be broken?

Below, I put the MSeg[ ] function, which plots segment outwards from 
its midpoint, into the module used by the Manipulate.

Manipulate[
 Module[
  {
   \[ScriptCapitalA] = {Ax, Ay, Az}, \[ScriptCapitalB] = {Bx, By,
     Bz}, \[ScriptCapitalC] = {Cx, Cy, Cz}, \[ScriptCapitalD] = {Dx,
     Dy, Dz},
   \[ScriptCapitalP], \[ScriptCapitalQ], n, k, t
   },

  (* points riding along the "rails" \[ScriptCapitalA]\
\[ScriptCapitalC] and \[ScriptCapitalB]\[ScriptCapitalD]: *)
  \
\[ScriptCapitalP][n_] = (1 - n) \[ScriptCapitalA] +
    n \[ScriptCapitalC];
  \[ScriptCapitalQ][n_] = (1 - n) \[ScriptCapitalB] +
    n \[ScriptCapitalD];
  \[HorizontalLine]MSeg[\[ScriptCapitalA]_, \[ScriptCapitalB]_, k_,
    t_] = (\[ScriptCapitalA] + \[ScriptCapitalB])/2 +
    k (t - 1/2) (\[ScriptCapitalB] - \[ScriptCapitalA]);

  (* reflections of the "butterfly" across all the coordinate planes *)

    Show[
   ParametricPlot3D[
    Table[
     ( {
        {\[ScriptI], 0, 0},
        {0, \[ScriptJ], 0},
        {0, 0, \[ScriptK]}
       } ). \[HorizontalLine]MSeg[\[ScriptCapitalP][
        u], \[ScriptCapitalQ][u], 2 u - 1, v],
     {\[ScriptI], {-1, 1}}, {\[ScriptJ], {-1, 1}}, {\[ScriptK], {-1,
       1}}
     ],
    {u, 0, 1}, {v, 0, 1},
    PlotPoints -> plotPts,

    Mesh -> mesh,
    MeshStyle -> Tube[tubeR],
    MeshFunctions -> {{x, y, z, u, v} \[Function] v},
    MeshShading -> {Lighter[Blue, .5], Yellow, Orange, Yellow,
      Lighter[Blue, .5]},

    BoundaryStyle -> Tube[tubeR],

    MaxRecursion -> maxRecurs
    ],

   (* the corners of the twisted sheet *)

   With[{pts = {\[ScriptCapitalA], \[ScriptCapitalB], \
\[ScriptCapitalC], \[ScriptCapitalD]}},
    Graphics3D[
     {Table[{Hue[(k - 1)/4], Sphere[pts[[k]], ptRad]}, {k, 1, 4}],
      Gray, Sphere[Plus @@ pts/4, ptRad]}]
    ],
   Lighting -> "Neutral",
   PlotRange -> 4,
   Axes -> True,
   AxesLabel -> {"x", "y", "z"}
   ]
  ],
 {{Ax, 0}, -4, 4, .125},
 {{Ay, -4}, -4, 4, .125},
 {{Az, -4}, -4, 4, .125},

 {{Bx, -4}, -4, 4, .125},
 {{By, 0}, -4, 4, .125},
 {{Bz, -4}, -4, 4, .125},

 {{Cx, 0}, -4, 4, .125},
 {{Cy, 0}, -4, 4, .125},
 {{Cz, -2}, -4, 4, .125},

 {{Dx, -4}, -4, 4, .125},
 {{Dy, -4}, -4, 4, .125},
 {{Dz, 0}, -4, 4, .125},

 {{mesh, 4}, 0, 9},
 {{tubeR, 0.03}, 0, 0.1, 0.01},
 {{plotPts, 6}, 2, 30, 1},
 {{maxRecurs, 1}, 0, 4, 1},
 {{ptRad, .1}, 0, 0.5, 0.01},
 {{tubeR, .03}, 0, 0.5, 0.01}
 ]




  • Prev by Date: Re: Slow plotting of reflected parametric "butterflies"
  • Next by Date: Re: Tips for writing correct, non trivial Mathematica Libraries
  • Previous by thread: Re: Slow plotting of reflected parametric "butterflies"
  • Next by thread: Re: Slow plotting of reflected parametric "butterflies"