Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Interactive settings for ParamPlot3D. Mesh not quite working.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121499] Re: Interactive settings for ParamPlot3D. Mesh not quite working.
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Sun, 18 Sep 2011 04:08:12 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201109160950.FAA12506@smc.vnet.net>

Instead of changing the Mesh specifications, you could change the MeshFunctions
to indicate which mesh lines you want, e.g.

saddleParamPlot3[opacity_, xBnds_, yBnds_, zBnds_, drawXMesh_,
  drawYMesh_, drawZMesh_] :=
 Module[{
   meshf = Pick[{#1 &, #2 &, #3 &}, {drawXMesh, drawYMesh, drawZMesh}, True],
   meshSpecs = {Range[-xBnds, xBnds], Range[-yBnds, yBnds], Range[-zBnds, zBnds]}},
 
   ParametricPlot3D[
    Flatten[{{u}, {v}, {u v}}], {u, -xBnds, xBnds}, {v, -xBnds, xBnds},
    PlotRange -> {{-xBnds, xBnds}, {-yBnds, yBnds}, {-zBnds, zBnds}},
    BoxRatios -> {xBnds, yBnds, zBnds},
    SphericalRegion -> True,
    FaceGrids -> {{{1, 0, 0}, {Range[-xBnds, xBnds],
        Range[-zBnds, zBnds]}}, {{0, 1, 0}, {Range[-yBnds, yBnds],
        Range[-zBnds, zBnds]}}, {{0, 0, 1}, {Range[-xBnds, xBnds],
        Range[-yBnds, yBnds]}}},
    MeshFunctions -> meshf,
    Mesh -> meshSpecs, BoundaryStyle -> Gray,
    AxesLabel -> {"x", "y", "z"}, PlotStyle -> Opacity[opacity],
    ColorFunctionScaling -> False,
    ColorFunction -> (Hue[0.35 (#3 + 4)/8] &)] /.
   Line[pts_, opts___] :> {Gray, Tube[pts, 0.03, opts]}]

Heike

On 16 Sep 2011, at 11:50, Christopher O. Young wrote:

> I'm trying to make a template for interactive graphing with the settings I
> like, and controls to change the bounding box, etc. Everything is working
> except that I'm not able to set the mesh correctly. Checking or unchecking
> one of the boxes causes _all_ the mesh to be toggled off, not just one of
> the mesh specifications. I think I'm constructing the list of specifications
> according to the Help documentation. I put in and empty list for the mesh
> function I don't want any mesh for.
>
> Do I need to make this a Dynamic module? I don't see why, since I'm passing
> in the value via the drawXMesh, drawYMesh, and drawZMesh arguments to
> saddleParamPlot3.
>
> Thanks for any help.
>
> Chris Young
> cy56 at comcast.net
>
>
> saddleParamPlot3[
>  opacity_,
>  xBnds_, yBnds_, zBnds_,
>  drawXMesh_, drawYMesh_, drawZMesh_
>  ] :=
> Module[
>  {
>   meshSpecs =
>    {
>     If[drawXMesh, Range[-xBnds, xBnds], {}],
>     If[drawYMesh, Range[-yBnds, yBnds], {}],
>     If[drawZMesh, Range[-zBnds, zBnds], {}]
>     }
>
>   },(* Specifications for the mesh; i.e., in which directions. *)
>
>  Print["Mesh specs are: ", meshSpecs];
>
>  ParametricPlot3D[
>    Flatten[ {
>      {u},
>      {v},
>      {u v}
>     } ],
>
>    {u, -xBnds, xBnds},
>    {v, -xBnds, xBnds},
>
>    PlotRange -> {{-xBnds, xBnds}, {-yBnds, yBnds}, {-zBnds, zBnds}},
>    BoxRatios -> {xBnds, yBnds, zBnds},
>    SphericalRegion -> True,
>
>    FaceGrids ->
>     {
>      {
>       {1, 0, 0}, {Range[-xBnds, xBnds], Range[-zBnds, zBnds]}
>       },
>      {
>       {0, 1, 0}, {Range[-yBnds, yBnds], Range[-zBnds, zBnds]}
>       },
>      {
>       {0, 0, 1}, {Range[-xBnds, xBnds], Range[-yBnds, yBnds]}
>       }
>      },
>
>    MeshFunctions -> {#1 &, #2 &, #3 &},
>    Mesh ->  meshSpecs,
>
>    BoundaryStyle -> Gray,
>    AxesLabel -> {"x", "y", "z"},
>    PlotStyle -> Opacity[opacity],
>    ColorFunctionScaling -> False,
>    ColorFunction -> (Hue[0.35 (#3 + 4)/8 ] &)
>    ] /. Line[pts_, opts___] :> {Gray, Tube[pts, 0.03, opts]}
>  ]
>
>
> Manipulate[
> saddleParamPlot3[opac, xBnds, yBnds, zBnds, drawXMesh, drawYMesh,
>  drawZMesh],
>
> {{opac, 0.5, "Opacity"}, 0, 1} ,
> {{xBnds, 4, "x bounds"}, 0, 4, 1} ,
> {{yBnds, 4, "y bounds"}, 0, 4, 1} ,
> {{zBnds, 4, "z bounds"}, 0, 4, 1} ,
> {{drawXMesh, True, "x mesh"}, {True, False}},
> {{drawYMesh, True, "y mesh"}, {True, False}},
> {{drawZMesh, True, "z mesh"}, {True, False}}
> ]
>
>





  • Prev by Date: Re: Likelihood analysis with Mathematica: which Method for NIntegrate
  • Next by Date: boundary conditions
  • Previous by thread: Re: Interactive settings for ParamPlot3D. Mesh not quite working.
  • Next by thread: Multisets package