Group Abstract Group Abstract

Message Boards Message Boards

1
|
8.8K Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How can I change the orientation of a 3D object after using Dynamic?

Posted 11 years ago

While going over the examples in the tutorial "Advanced Manipulate Functionality" I'm struggling with the apparent ramifications of improving

Manipulate[
 Plot3D[Sin[n x y], {x, 0, 3}, {y, 0, 3}, ViewPoint -> {2, v, 2}, 
  SphericalRegion -> True, Ticks -> None], {n, 1, 4}, {v, -2, 2}]

by using "Dynamic" as directed:

Manipulate[
 Plot3D[Sin[n x y], {x, 0, 3}, {y, 0, 3}, 
  ViewPoint -> Dynamic[{2, v, 2}], SphericalRegion -> True, 
  Ticks -> None], {n, 1, 4}, {v, -2, 2}]

I see that the improvement works as stated. However, with the "Dynamic" version I can no longer use the mouse to change the orientation of the 3D figure. When attempting to change the orientation with the mouse I get a zillion identical errors stating

         Set::setraw: Cannot assign to raw object 2. >>

How can I use the "Dynamic" version but still be able to change the orientation of the figure with the mouse? (I'm using Wolfram Mathematica 10.0.0.0 with Windows 7.)

POSTED BY: Jim Baldwin
3 Replies

When you change the ViewPoint, it's trying to do the following:

{2,v,2} = {2.1, 2.5, 2.3} (* where 2.1, 2.5, and 2.3 are whatever random values your rotation produced *)

which isn't going to work. You can use the second argument of Dynamic to provide a custom setter function.

Manipulate[
 Plot3D[Sin[n x y], {x, 0, 3}, {y, 0, 3}, 
  ViewPoint -> Dynamic[{2, v, 2}, (v = Clip[#[[2]], {-2, 2}]) &], 
  SphericalRegion -> True, Ticks -> None], {n, 1, 4}, {v, -2, 2}]
POSTED BY: John Fultz
Posted 11 years ago

Thank you, John!

From your explanation (what I suppose I should have understood from reading the documentation on Dynamic), I now understand why those errors occurred. My superficial understanding as to how Manipulate works is now a little less superficial but I think I've got a long way to go (as in understanding why the new issue occurs that George brings up).

Thanks again!

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard