Re: Rotable Graphics and ViewPoint
- To: mathgroup at smc.vnet.net
- Subject: [mg78544] Re: Rotable Graphics and ViewPoint
- From: Januk <ggroup at sarj.ca>
- Date: Wed, 4 Jul 2007 05:28:04 -0400 (EDT)
- References: <f67mco$2vu$1@smc.vnet.net><f6d5jp$i8p$1@smc.vnet.net>
Hi Albert, Thanks for the suggestions. I had indeed previously tried the method you espouse. It does solve the issue of being able to press a given button in succession. However, I find that the rotating and interaction with the graphic is less responsive than if I make the entire Show command dynamic. Yes I am aware of the Front, Back, etc built-in keywords. They are useful if you want a perspective view. By setting the viewpoint to infinity, you get a projection view (i.e no perspective artifacts). It is simply a matter of personal preference for a given application. Thanks again, Januk On Jul 3, 6:57 am, Albert <a... at arcor.net> wrote: > Hi, > > > > > > > CADView[pl_, opts___?OptionQ] := DynamicModule[{vpv, vv, vp}, > > Panel[ > > { > > vpv = { {1.3, -2.4, 2}, Automatic }; > > Row[{ > > Button["Automatic", vpv = { {1.3, -2.4, 2}, > > Automatic }], > > Button["Top", vpv = {{0, 0, }, {0, 1, 0} }], > > Button["Bottom", vpv = { {0, 0, - }, {0, 1, 0} }], > > Button["Left", vpv = { {- , 0, 0}, {0, 0, 1} }], > > Button["Right", vpv = { { , 0, 0}, {0, 0, 1} }], > > Button["Front", vpv = { {0, - , 0}, {0, 0, 1} }], > > Button["Back", vpv = { {0, , 0}, {0, 0, 1} }] > > }], > > > Dynamic[{vp, vv} = vpv; > > Show[pl, ViewPoint -> vp, ViewVertical -> > > vv, opts, ImageSize -> 400]] > > } // Column > > ]] > > > One bug with this is that you can't press one button, rotate the > > graphic and then press that same button. I don't really understand > > why that doesn't work. The work-around is easy enough; simply press a > > different button before pressing the first one a second time. > > I think that happens because vpv does not dynamically update when either > vp or vv change, you either need to make it aware of these changes or > directly use vp and vv in the assignments. Also it would make the thing > more reactive if you restrict the Dynamics to the Option-Values (which > will not recreate the whole graphics). Have you noticed that you can use > Front, Back etc. directly as Option-Values for ViewPoint? Here is a > slightly modified version of your code: > > CADView[pl_, opts___?OptionQ] := DynamicModule[{vv, vp}, > vp = {1.3, -2.4, 2}; > vv = Automatic; > Panel[Column[{ > Row[{ > Button["Automatic", {vp, vv} = {{1.3, -2.4, 2}, Automatic}], > Button["Top", {vp, vv} = {Top, {0, 1, 0}}], > Button["Bottom", {vp, vv} = {Bottom, {0, 1, 0}}], > Button["Left", {vp, vv} = {Left, {0, 0, 1}}], > Button["Right", {vp, vv} = {Right, {0, 0, 1}}], > Button["Front", {vp, vv} = {Front, {0, 0, 1}}], > Button["Back", {vp, vv} = {Back, {0, 0, 1}}] > }], > Grid[{ > {ViewPoint, InputField[Dynamic[vp]]}, > {ViewVertical, InputField[Dynamic[vv]]} > }], > Show[pl, ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv], > opts, ImageSize -> 600] > }]] > ] > > Anyway, the following would probably be just be enough functionality for > what Helen needs: > > v=Front; > Column[{ > InputField[Dynamic[v]], > Plot3D[Sin[x y], {x, -5, 5}, {y, -5, 5}, ViewPoint -> Dynamic[v], > ImageSize -> 500] > }] > > I think that Helen needs something without extra code and that is > simpler than what is suggested. Although I agree that it would be nice > if Wolfram would implement some standard things for graphics (reading > and copying coordinates from a 2d-Graphics has come up already) in such > a way that you wouldn't need extra code to do them. On the other hand I > can imagine that there is disagreement about what would be important > enough to be a build-in and what not. And to have everything available > doesn't make the program easier to use, too... > > after all I guess we have to live with what WRI decides to do... > > albert- Hide quoted text - > > - Show quoted text -