Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Using an locator and Rotating 3D graphics
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
KB  
View profile  
 More options Oct 6 2008, 4:15 am
Newsgroups: comp.soft-sys.math.mathematica
From: KB <KennethLeeBa...@gmail.com>
Date: Mon, 6 Oct 2008 08:15:20 +0000 (UTC)
Local: Mon, Oct 6 2008 4:15 am
Subject: Using an locator and Rotating 3D graphics
When I try to use locators as inputs to 3D graphics, I end up not
being able to rotate 3d graphics.  Clicking on the graphic moves the
nearest locator rather than the graphic.  Switching to a collection of
2D sliders works in a pinch, but does not achieve the desired effect.
Here is an example:

Manipulate[v = pt2 - pt1;
 {Graphics[Arrow[{pt1, pt2}], PlotRange -> 2],
  ParametricPlot3D[{v[[1]] Cos[u], v[[2]] Sin[u], u}, {u, 0, 4 Pi},
   PlotRange -> {{-2, 2}, {-2, 2}},
   ColorFunction -> Function[{x, y, z, u}, Hue[u]],
   PlotStyle -> Thick]}, {{pt1, {0, 1}}, Locator},   {{pt2, {1, 0}},
  Locator}]

Any ideas?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Park  
View profile  
(1 user)  More options Oct 7 2008, 7:48 am
Newsgroups: comp.soft-sys.math.mathematica
From: "David Park" <djmp...@comcast.net>
Date: Tue, 7 Oct 2008 11:48:21 +0000 (UTC)
Local: Tues, Oct 7 2008 7:48 am
Subject: Re: Using an locator and Rotating 3D graphics
Manipulate is like a set-piece dynamic display. It tries to be very versitle
but for most custom dynamic presentations it becomes a pain-in-the-neck. It
is better to learn how to construct your own dynamic presentations. Here is
more direct code for your display:

Module[
 {pt1 = {1, 0}, pt2 = {0, 1}},
 Row[{
   Graphics[
    {Dynamic@Arrow[{pt1, pt2}],
     Locator[Dynamic[pt1]],
     Locator[Dynamic[pt2]]},
    PlotRange -> 2,
    ImageSize -> 200],
   Dynamic@
    ParametricPlot3D[{Part[pt2 - pt1, 1] Cos[u],
      Part[pt2 - pt1, 2]  Sin[u], u}, {u, 0, 4 Pi},
     PlotRange -> {{-2, 2}, {-2, 2}},
     ColorFunction -> Function[{x, y, z, u}, Hue[u]],
     PlotStyle -> Thick,
     ImageSize -> 350,
     BoxRatios -> {1, 1, 1}]}]
 ]

You could use DynamicModule, but it really isn't necessary here. The
Locators are confined to the lhs plot and not imposed on the entire display.
In the code above I bypassed calculating the v variable you used.  Let's
reintroduce v. Quite often we might have a set of primary dynamic variables,
such as pt1 and pt2 here, which are manipulated by the mouse or sliders or
other dynamic elements, and a set of dependent dynamic variables that depend
on the primary variables, such as v here. We can handle this situation as in
the following code. Here we use the two argument form of Dynamic and when a
primary dynamic variable is adjusted the routine calcAll is called to
calculate all the dependent quantities (only v in this case). I've also made
some stylistic changes to the display.

Module[
 {(* Primary dynamic variables *)
  pt1 = {1, 0}, pt2 = {0, 1},
  (* Dependent dynamic variable *)
  v,
  (* Other variables *)
  calcAll},

 calcAll[p1_, p2_] := (v = p2 - p1);

(* Initialize dependent variables *)
 calcAll[pt1, pt2];

 (* Display *)
 Panel[
  Row[{
    Graphics[
     {Arrowheads[.1],
      Dynamic@Arrow[{pt1, pt2}],
      Locator[Dynamic[pt1, (pt1 = #; calcAll[pt1, pt2]) &],
       Graphics[{AbsolutePointSize[8], Point[{0, 0}]},
        ImageSize -> 10]],
      Locator[Dynamic[pt2, (pt2 = #; calcAll[pt1, pt2]) &], None]},
     PlotRange -> 2,
     ImageSize -> 200],
    Dynamic@
     ParametricPlot3D[{v[[1]] Cos[u], v[[2]]  Sin[u], u}, {u, 0,
       4 Pi}, PlotRange -> {{-2, 2}, {-2, 2}},
      ColorFunction -> Function[{x, y, z, u}, Hue[u]],
      PlotStyle -> Thick,
      Axes -> False,
      SphericalRegion -> True, RotationAction -> Clip,
      ImageSize -> 350,
      Boxed -> False,
      BoxRatios -> {1, 1, 1}]}],
  Style["Custom Dynamics", 16]]
 ]

--
David Park
djmp...@comcast.net
http://home.comcast.net/~djmpark/

"KB" <KennethLeeBa...@gmail.com> wrote in message

news:gccheo$s5t$1@smc.vnet.net...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google