Message Boards Message Boards

0
|
2410 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to get absolute options used by Graphics3D?

Posted 1 year ago

I want to know options, especially the view options used by a Graphics3D. However, AbsoluteOptions does not resolve some automatic options.

How can I find out all the values used?

Note: AbsoluteCurrentValue fails for all options.

Graphics3D[{Cube[]}, ImageSize -> Small]
AbsoluteOptions[%, {"ImageSize", "ViewCenter", "ViewPoint", "ViewVector", "ViewProjection"}]
AbsoluteCurrentValue[%%, "ImageSize"]

enter image description here

POSTED BY: Werner Geiger
6 Replies
Posted 1 year ago

Thanks Hans for that hint and the link to StackExchange. This looks pretty strange, but it works and I can understand why. Nevertheless I don't understand why standard AbsoluteOptions do not work.

POSTED BY: Werner Geiger
Posted 1 year ago

From this MSE post:

vp = Options[Graphics3D, ViewPoint][[1, 2]];
Graphics3D[Cube[], ViewPoint -> Dynamic[vp]]
Dynamic[vp]
POSTED BY: Hans Milton
Posted 1 year ago

This works for me:

g = Graphics3D[{Cube[]}, ImageSize -> Small]
Dynamic[AbsoluteOptions[g]]
POSTED BY: Damien Waden
Posted 1 year ago

Sorry, Damien, for responding so late. I have overlooked your reply.

For me, using Dynamic does not change anything (and I would not understand why it should). The option ViewVector i still shown as Automatic not with its true value.

POSTED BY: Werner Geiger
Posted 1 year ago

I might be misunderstanding what you are wanting to do.

One interpretation of what information you are trying to get (from my own personal experience of messing with the 3D plots) is that you want the ViewVector property to update in real time when you are interacting with the plot. I've tried similar solutions to the one from Hans Milton below in the past without success (at least in the cloud notebooks - may it works on the local wolfram app? - I haven't tried b/c I just wanted to stick with the cloud version)

Part of the issue is that when you are manipulating the plot in the output viewer - I believe this ViewPoint is related to some property on the FrontEnd and is not actually changing the ViewVector property of the underlying graphics3D object.

This is a solution that I came up with recently that mostly worked for me. It's not perfect but it at least lets you rotate the 3D plot. Just replace g1 with whatever you are trying to plot. The cool thing about this is that you don't have to replot g1 with the new ViewPoint property. You can just use the new Graphics object g2.

g1 = Graphics3D[{Sphere[],Cuboid[]}];
    Manipulate[With[{v = RotationTransform[\[Theta]z[[1]]*-2Pi+Pi, {0, 0, 1}][{Pi, 0,Pi}]}, 
            g2= Show[g1, ViewPoint -> {v[[1]],v[[2]],\[Theta]z[[2]]*-40+20}, 
         SphericalRegion -> True]],{{\[Theta]z,{.5,.5}},Locator}]
Dynamic[Options[g2,ViewPoint]]
Dynamic[Show[g2]]
POSTED BY: Damien Waden
Posted 1 year ago

"One interpretation of what information you are trying to get (from my own personal experience of messing with the 3D plots) is that you want the ViewVector property to update in real time when you are interacting with the plot."

Well Damien, actually my issue is much simpler than dynamic updating. I just want to know the ViewVector actually used after some static Graphics3D has been defined and displayed.

Maybe AbsoluteOptions does not work since the display can be manipulated manually and then the ViewVector indeed changes dynamically.

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

Group Abstract Group Abstract