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:
- The
AbsoluteOptions
line throws an error ViewPoint::nlist3 is not a list of numbers. I presume this is because theHead
of vp isDynamic
. This error isn't thrown for ViewVertical, however, which I would expect should complain as well. Am I missing something, or can theViewVertical
error be safely ignored? (I don't like quieting errors for fear of covering up something later on down the line.) - 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.
AbsoluteOptions
if those values are invv
andvp
and Norm@vp is enough? If You just want to extract those values it seems to be a duplicate $\endgroup$ – Kuba♦ Jun 26 '13 at 18:09