view is not fixed completely regardless of vewpoint

6

1

If I run code

Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}]

the output is

enter image description here

After rotating (by mouse click and drag) the output in some direction, and run the same code again

Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}]

then the output becomes

enter image description here

Again, rotate the output in some direction, and run the same code

Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}]

then the output becomes

enter image description here

I knew that with ViewPoint option, Mathematica tries to fix 'a kind of view property'. The code stated above, will not generate graphics like

enter image description here

But also I knew that it is not enough to fix the view completely, with ViewPoint option only.

How can I completely fix the view ? For example, How can I generate

enter image description here

from a certain code, with 100% assurance, regardless of the state (what I've done so far since starting mathematica program) of Mathematica ?

imida k

Posted 2019-08-27T21:07:18.317

Reputation: 305

1The FE is clever(ish) about how it handles stuff like this. If it sees a following Output cell with a Graphics expression it tries to preserve the options that expression currently has. That's what you're running into. Just delete the cell if it's an issue. – b3m2a1 – 2019-08-27T21:29:01.403

2try (1) setting an explicit value for ViewVertical and (2) adding the option PreserveImageOptions ->True. E.g., try if Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}, ViewVertical -> {-0.3, 0.6, 0.7}, PreserveImageOptions -> True] works. – kglr – 2019-08-27T21:39:49.787

2@b3m2a1 Too clever I'd say! – Chris K – 2019-08-27T22:09:34.030

Answers

6

Set an explicit value for ViewPoint and for ViewVertical.

Add the option PreserveImageOptions -> True if you want to preserve other options (such as ImageSize) set interactively, PreserveImageOptions -> False if you want them to revert to the original values after interactive changes:

Graphics3D[Cuboid[], 
 ViewPoint -> {1, 1, 1}, 
 ViewVertical -> {0.5, 0, 1},
 PreserveImageOptions -> True]

enter image description here

Graphics3D[Cuboid[], 
 ViewPoint -> {1, 1, 1}, 
 ViewVertical -> {0.5, 0, 1},
 PreserveImageOptions -> False]

enter image description here

kglr

Posted 2019-08-27T21:07:18.317

Reputation: 302 076

What is the value of PreserveImageOptions here? – CA Trevillian – 2019-08-28T13:01:26.267

Thank you very much! I posted another related question, https://mathematica.stackexchange.com/questions/204461/image-option-is-initialized-when-a-graphic-is-in

– imida k – 2019-08-28T13:25:00.043

3

We can find the appropriate options from this input:

Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}] // AbsoluteOptions

(*{AlignmentPoint -> Center, AspectRatio -> Automatic, 
AutomaticImageSize -> False, Axes -> False, AxesEdge -> Automatic, 
AxesLabel -> None, AxesOrigin -> Automatic, AxesStyle -> {}, 
Background -> None, BaselinePosition -> Automatic, BaseStyle -> {}, 
Boxed -> True, BoxRatios -> {1., 1., 1.}, BoxStyle -> {}, 
ClipPlanes -> None, ClipPlanesStyle -> Automatic, 
ColorOutput -> Automatic, ContentSelectable -> Automatic, 
ControllerLinking -> Automatic, ControllerMethod -> Automatic, 
ControllerPath -> Automatic, CoordinatesToolOptions -> Automatic, 
DisplayFunction -> Identity, Epilog -> {}, FaceGrids -> None, 
FaceGridsStyle -> {}, FormatType -> TraditionalForm, 
ImageMargins -> 0., ImagePadding -> All, ImageSize -> Automatic, 
ImageSizeRaw -> Automatic, LabelStyle -> {}, Lighting -> Automatic, 
Method -> Automatic, PlotLabel -> None, 
PlotRange -> {{0., 1.}, {0., 1.}, {0., 1.}}, 
PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
PreserveImageOptions -> Automatic, Prolog -> {}, 
RotationAction -> "Fit", SphericalRegion -> False, 
Ticks -> Automatic, TicksStyle -> {}, TouchscreenAutoZoom -> False, 
ViewAngle -> Automatic, ViewCenter -> {0.5, 0.5, 0.5}, 
ViewMatrix -> Automatic, ViewPoint -> {1., 1., 1.}, 
ViewProjection -> Automatic, ViewRange -> All, 
ViewVector -> Automatic, ViewVertical -> {0., 0., 1.}}*)  

Then, the desired & appropriate parameters may be set:

Graphics3D[Cuboid[], ViewPoint -> {1, 1, 1}, 
ViewCenter -> {0.5`, 0.5`, 0.5`}, ViewVertical -> {0.`, 0.`, 1.`}]

Use AbsoluteOptions to determine the definitive options for the current viewpoint you have outputted. From here, copy and paste these into your desired definition. What I mean by this is that you take your Cuboid output, defined with the noted Viewpoint, and then type //AbsoluteOptions after the output. Evaluate this and use the output to be applied to your definition.

I have no experience with the answer of user @kglr, however, I can say with absolute certainty and confidence that if you find a viewpoint you like, perform the above procedure and you will have the desired output every time you evaluate it, just as you need/ask for here.

Hope this helps!

CA Trevillian

Posted 2019-08-27T21:07:18.317

Reputation: 2 817

1Thank you for AbsoluteOptions! I didn't know that. – imida k – 2019-08-28T13:41:44.413