Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Fast interactive graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77499] Re: Fast interactive graphics
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Mon, 11 Jun 2007 04:17:02 -0400 (EDT)
  • References: <f4gmui$hpj$1@smc.vnet.net>

I have been experimenting to try to find a way of answering my own question. 
It seems that part of the problem was that using Manipulate introduuces some 
overheads that can be avoided by writing your own interactive graphics code.

The code below is the result of some experimentation that shows a useful 
level of interactive manipulation of a 2-dimensional manifold.

Define a cut-out region. This is a "window" within which the manifold is 
being interactively manipulated.

cutout[\[Phi]_, \[Theta]_] := (9 \[Pi])/8 < \[Phi] < (13 \[Pi])/
    8 && \[Pi]/4 < \[Theta] < (3 \[Pi])/4;

Basic spherical region with a cut-out. This is a background graphic showing 
everything except the part that is being manipulated.

g0 = ParametricPlot3D[{Sin[\[Theta]] Cos[\[Phi]],
    Sin[\[Theta]] Sin[\[Phi]], Cos[\[Theta]]}, {\[Phi], 0,
    2 \[Pi]}, {\[Theta], 0, \[Pi]},
   RegionFunction -> (Not[cutout[#4, #5]] &)];

Define a fiducial point. This is the location of the tip of a "nose"-like 
protrusion that is being manipulated around the manifold.

{\[Phi]1, \[Theta]1} = {(11 \[Pi])/8, \[Pi]/2};
Slider2D[Dynamic[{\[Phi]1, \[Theta]1}], {{0, \[Pi]}, {2 \[Pi], 0}}]

Dynamically updated display of everything.

Dynamic[
 u = (1 +
     0.5 Exp[-((\[Theta] - \[Theta]1)/0.25)^2 - ((\[Phi] - \[Phi]1)/
         0.25)^2]) {Sin[\[Theta]] Cos[\[Phi]],
    Sin[\[Theta]] Sin[\[Phi]], Cos[\[Theta]]};
 p = 1.01 u /. {\[Theta] -> \[Theta]1, \[Phi] -> \[Phi]1};
 g1 = ParametricPlot3D[u, {\[Phi], 0, 2 \[Pi]}, {\[Theta], 0, \[Pi]},
   RegionFunction -> (cutout[#4, #5] &)];
 g2 = Graphics3D[{Red, PointSize[0.05], Point[p]}];
 Show[g0, g1, g2, PlotRange -> 2 {{-1, 1}, {-1, 1}, {-1, 1}},
  AxesLabel -> {"x", "y", "z"}]
 ]

Now you can move the 2D slider around (slowly!) to adjust the position of 
the "nose" on the sphere. On my version of Mathematica (Windows XP 32-bit) 
as you move the slider you get a continuously updated fiducial point and 
"nose", but the mesh on the nose doesn't get drawn in until you release the 
mouse button. Also the border of the "nose" is not drawn in during the 
continuous updates.

This code produces results that are a LOT better than the situation was when 
I wrote my original posting, and this approach may be a worthwhile starting 
point for this type of interactive manipulation.

Steve Luttrell
West Malvern, UK

"Steve Luttrell" <steve at _removemefirst_luttrell.org.uk> wrote in message 
news:f4gmui$hpj$1 at smc.vnet.net...
> In version 6 I want to do interactive graphics where I use a controller to
> manipulate the shape of a curved 2-dimensional manifold (for instance). 
> This
> is a type of interaction with Mathematica that should be of interest to 
> lots
> of people.
>
> The main problem that I have is that the redraw time after each controller
> movement is quite long. I need continuous feedback so that I can 
> immediately
> see the effect of making various controller movements, so using
> ContinuousAction->False in Manipulate (for instance) doesn't solve this
> problem. I have tried various shortcuts such as skeletonising the graphic
> during updates so that it redraws quicker, but it is still too slow, and
> will get worse for the more complicated graphics that I really want to 
> work
> on.
>
> As a general solution it would be great if it was possible to control the
> redrawing of graphics so that only those parts that need to be redrawn are
> actually redrawn, with the user taking responsibility for any 
> consequential
> errors in the accumulated graphics rendering. Here I don't want to simply
> zoom the graphic to limit the rendered region, because I want to
> interactively see the impact of my manipulations in the context of the 
> whole
> graphic.
>
> Does anyone know a way of imposing this type of control (see above) on
> graphics rendering, or is it not actually possible in Mathematica? I think
> the answer is no, but I just want to make sure that I haven't overlooked a
> trick here.
>
> Steve Luttrell
> West Malvern, UK
>
>
> 




  • Prev by Date: Re: Simplify 0/0 to 1?
  • Next by Date: Re: Simplify 0/0 to 1?
  • Previous by thread: Fast interactive graphics
  • Next by thread: Re: Fast interactive graphics