Can I request the ViewPoint Graphics3D property?

After displaying some graphic objects with Graphics3D, you can move the image by interactively changing the ViewPoint parameter or simply dragging, resizing or rotating the image. Does the latter change ViewPoint internally? Can this be requested?

For instance.

By program:

Manipulate [ viewpoint->{x,y,y}; Graphics3D[Cuboid[],ViewPoint->viewpoint], ,{x,-25,25} ,{y,-25,25} ,{z,-25,25}] 

Under the mouse

 Graphics3D[ Cuboid[]] 

The effects of the program above can be modeled. Can I โ€œrequestโ€ an effect on a ViewPoint as a result of, for example, rotation?

+6
source share
3 answers

Try this code:

 gr = Graphics3D[Cuboid[], SphericalRegion -> True, Boxed -> False] (* this is one way to extract the values: *) vp = ViewPoint /. AbsoluteOptions[gr] vv = ViewVertical /. AbsoluteOptions[gr] (* the following is completely another way. try rotating the output of this: *) Row[ {Show[gr, ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv]], Show[gr, ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv]]} ] (* values will dynamically update here: *) Dynamic[vp] Dynamic[vv] 

Hope this helps solve your problem.

EDIT: You can also simply copy and paste graphics with the mouse already turned in ViewPoint /. Options[...] ViewPoint /. Options[...]

+8
source

Here is an extended version of the Szabolcs code. The main difference is that using DynamicModule avoids the pink background of Graphics3D , which indicates an error due to undefined vp and vv characters. This output works correctly even after saving the laptop and restarting Mathematica without re-evaluating the code!

 gr = Graphics3D[Cuboid[], SphericalRegion -> True, Boxed -> False]; DynamicModule[{vp = ViewPoint /. AbsoluteOptions[gr], vv = ViewVertical /. AbsoluteOptions[gr]}, Column[{Row[ Table[Show[gr, ViewPoint -> Dynamic@vp , ViewVertical -> Dynamic@vv ], {3}]], Dynamic@vp , Dynamic@vv }]] 

This behavior is well documented : "The values โ€‹โ€‹of local variables in the DynamicModule are automatically saved by default when the laptop containing the DynamicModule saved so that these values โ€‹โ€‹are saved during Mathematica sessions."

+4
source

This can be done manually by selecting the cell containing your graphic and providing the menu command Cell > Show Expression (ctrl-shift-E). The graphic is replaced with the corresponding cell expression, and the ViewPoint option ViewPoint displayed as plain text.

Another possibility:

 Cases[ NotebookGet[EvaluationNotebook[]], (ViewPoint -> e_) -> e, Infinity] (* Out[51]= {{1.73834, -2.29064, 1.78357}, {0.651043, -0.128738, 3.31807}, {-3.03116, -1.38541, 0.585417}} *) 

This finds all the occurrences of ViewPoint in your notebook and displays their coordinates. You probably know which one you need.

+2
source

Source: https://habr.com/ru/post/890920/


All Articles