Extract current viewing parameters from a 3D view?

You can dynamically extract ViewPoint and others like this (also useful for synchronization of different plots etc.):

vp = Options[Graphics3D, ViewPoint][[1, 2]];

Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp]]

Mathematica graphics

This value is now constantly updated:

Dynamic[vp]

{1.3, -2.4, 2.}

This seem also to work fine with other functions that use the ViewPoint option. Below, ViewPoint and ViewVertical are in sync for both objects:

{vp, vv} = Options[Graphics3D, {ViewPoint, ViewVertical}][[All, 2]];

Grid[{{Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp], 
    ViewVertical -> Dynamic[vv]], 
   ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 
     2 Pi}, {v, -Pi, Pi}, ViewPoint -> Dynamic[vp], 
    ViewVertical -> Dynamic[vv]]}}]

Mathematica graphics


Perhaps the most easiest way is to use Options

  1. Graphics3D[Cuboid[]] to plot the figure;
  2. Manipulate the figure at your will,such as zooming in, rotate and so on;
  3. Copy the manipulated figure and add //Options after it, and press enter. You will get the options of the manipulated figure.

enter image description here


The following function may be helpful:

ExtrahiereViews[ll_]:=
  Flatten[Union[Extract[ll,Position[ll,#]]&/@
  {ViewPoint->_, ViewCenter->_, ViewVertical->_,
   ViewAngle->_, ViewVector->_, ViewRange->_}]];  

How to do:

  1. Enter ExtrahiereViews[] in a cell below the graphic.
  2. Move the graphic to your liking.
  3. Set the cursor between the brackets of ExtrahiereViews.
  4. Make a "Copy output from above" (CtrlShiftL) and evaluate. You'll get the values.

Tags:

Graphics3D