2
$\begingroup$

I'd like to know why I can't rotate this all the way around in a circle. The view flips rather than turning upside down, when trying to rotate about the Y-axis:

g = Graphics3D[{Blue, Cylinder[], Red, Sphere[{0, 0, 2}]}];
Manipulate[Graphics3D[g[[1]], 
  ViewPoint -> RotationTransform[i*2 \[Pi], {0, 1, 0}][{1, 0, 0}], 
  SphericalRegion -> True, Boxed -> False, Axes -> False, 
  ViewAngle -> Automatic], {i, 0, 1}]

enter image description here

Confusingly, this approach works just fine for rotating around the Z-axis!

g = Graphics3D[{Blue, Cylinder[], Red, Sphere[{0, 0, 2}], Line[{{-2, 0, 2}, {2, 0, 2}, {0, 0, 4}, {-2, 0, 2}}]}];
Manipulate[Graphics3D[g[[1]], ViewPoint -> RotationTransform[i*2 \[Pi], {0, 0, 1}][{1, 0, 0}], SphericalRegion -> True, Boxed -> False, Axes -> False, ViewAngle -> Automatic], {i, 0, 1}]

enter image description here

$\endgroup$
  • $\begingroup$ Do you have to include the viewvertical here? $\endgroup$ – M.R. Feb 1 at 6:51
  • 1
    $\begingroup$ Closely related: 42314 $\endgroup$ – Kuba Feb 1 at 10:19
  • $\begingroup$ It works for the z axis, but not the x or y... $\endgroup$ – M.R. Feb 1 at 17:41
2
$\begingroup$

You have to include the ViewVertical in your transformation. Otherwise, the camera just flips around.

g = Graphics3D[{Blue, Cylinder[], Red, Sphere[{0, 0, 2}], Green, 
    Sphere[{2, 0, 2}, 0.1]}];
Manipulate[Graphics3D[g[[1]],
  ViewPoint -> RotationTransform[i*2 \[Pi], {0, 1, 0}][{1, 0, 0}],
  ViewVertical -> RotationTransform[i*2 \[Pi], {0, 1, 0}][{0, 0, 1}],
  SphericalRegion -> True, Boxed -> False, Axes -> False, 
  ViewAngle -> Automatic], {i, 0, 1}]

And it works for your second example because the up-direction of the camera is always correct since you are rotating around the z-axis

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.