Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am exploring the use of Dynamic variables for the ViewPoint and ViewVertical options in a Graphics3D object. I have the following code:

vp = {0, -5, 0}
vv = {0, 0, 1}
(* Cell break here to make changes in vp and vv a bit easier *)
img = Graphics3D[{Yellow, Cuboid[{0, 0, 0}, {1, 3, 1}], Blue, 
  Cuboid[{2, 1, 1}, {4, 2, 3}]}, SphericalRegion -> True, 
  Lighting -> "Neutral", ViewPoint -> Dynamic[vp],
  ViewVertical -> Dynamic[vv]]
(* Another cell break, but hopefully making cut and paste easier by adding comments *)
{ViewVertical, ViewPoint} /. AbsoluteOptions[img]

There are two things that bother me:

  1. The AbsoluteOptions line throws an error ViewPoint::nlist3 is not a list of numbers. I presume this is because the Head of vp is Dynamic. This error isn't thrown for ViewVertical, however, which I would expect should complain as well. Am I missing something, or can the ViewVertical error be safely ignored? (I don't like quieting errors for fear of covering up something later on down the line.)
  2. Because of the dynamic head, operations on vv and vp require a bit of manipulation. For example, in the next bit of code, the first line doesn't work and the second line does, but obviously the dynamic evaluation has been lost:


Norm[ViewVertical /. AbsoluteOptions[img]]
Norm[(ViewVertical /. AbsoluteOptions[img]) /. {Dynamic -> List}]

Again, I worry about my hack to change Dynamic into a List isn't the most elegant (or safe) way to gain access to these values. Furthermore, I envision wanted to maintain the Dynamic nature of the data manipulation. Any suggestions would be welcome.

P.S. I have looked here for some guidance, and while helpful in framing the picture, I'm still a bit confused with the use of Dynamic in this case.

share|improve this question
Why do You need to use AbsoluteOptions if those values are in vv and vp and Norm@vp is enough? If You just want to extract those values it seems to be a duplicate – Kuba Jun 26 '13 at 18:09
@Kuba Heh, it looks like you caught me just copying and pasting examples without giving much thought to what I'm doing. – bobthechemist Jun 26 '13 at 18:13
up vote 2 down vote accepted

Ignoring Kuba's Gordian Knot solution (let's just pretend he never said anything), I think the idiomatic function here would be Setting, which "collapses" Dynamic expressions:

{ViewVertical, ViewPoint} /. AbsoluteOptions[Setting[img]]

This can in turn be dynamic:

Dynamic[{ViewVertical, ViewPoint} /. AbsoluteOptions[Setting[img]]]

Neither of these trigger the ViewPoint error, which is pretty quirky. Just doing AbsoluteOptions[img] gives that error.


Sidenote, also check out DynamicSetting, which has some nifty debugging/development uses (see the color swatch example here).

share|improve this answer
I'm glad You ignored me because this answer is educational :). – Kuba Jun 26 '13 at 18:25
Thanks. I was unfamiliar with Setting and the dynamic version. – bobthechemist Jun 26 '13 at 18:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.