1
$\begingroup$

Is there a way how to rotate by clicking and dragging just one of the 3D graphics inside Show?

For example rotating the cube without rotating the tetrahedron in this code:

Show[Graphics3D[{Opacity[0.5], Cube[]}, Boxed -> False], 
 Graphics3D[{Opacity[0.5], Tetrahedron[]}, Boxed -> False]]

I know how to do it by code, I just want to know whether there exist some parameter for Graphics3D that disables rotating by mouse, something like RotationDisable->True. And then one graphics would have RotationDisable->True and the other RotationDisable->False.

If there is no way how to do it for Show then what would be the easiest way to achieve rotating of cube by mouse while tetrahedron stays stationary?

$\endgroup$
3
  • $\begingroup$ Manipulate or DynamicModule seems the only way right now. $\endgroup$
    – cvgmt
    Commented Nov 4, 2020 at 9:47
  • 1
    $\begingroup$ this may be useful: How can locators be added to the points on a 3D grid? $\endgroup$
    – kglr
    Commented Nov 4, 2020 at 10:24
  • $\begingroup$ @cvgmt, @kglr: I did it with DynamicModule but it is not as good as it would be with mouse dragging straight on the graphics itself. See my answer. $\endgroup$ Commented Nov 4, 2020 at 11:41

1 Answer 1

2
$\begingroup$
angularSlider[Dynamic[angle_]] := 
 DynamicModule[{p = {1, 0}, angleCalc}, 
  LocatorPane[Dynamic[p, (angleCalc @@ Normalize /@ {#, p}) &], 
   Graphics[{Circle[], Arrowheads[0.15], Arrow[Dynamic[{{0, 0}, p}]]},
     ImageSize -> Tiny], Appearance -> None], 
  Initialization :> (angle = 0; 
    angleCalc[newp_, 
      oldp_] := (angle = 
       angle + ArcCos[newp.oldp] Sign[Cross[newp].(newp - oldp)]; 
      p = {Cos[angle], Sin[angle]}))]

Then using this code:

angularSlider[Dynamic[\[Theta]]]
Graphics3D[{Opacity[0.7], Cube[1/2], 
  GeometricTransformation[Tetrahedron[], 
   RotationMatrix[Dynamic[\[Theta]], {0, 1, 1}]]}, Boxed -> False, 
 SphericalRegion -> True, ViewVector -> {{3, 3, 3}, {0, 0, 0}}, 
 RotationAction -> "Clip", PlotRange -> 2]

enter image description here

You can rotate whole graphics with mouse as usually, plus you can rotate only tetrahedron using the mouse on the arrow inside circle.

Lots of code for a trivial thing to do... I think it should be implemented in Mathematica naturally to rotate graphics inside Show separately, because doing this by code is very cumbersome and still not as good as if rotated by mouse dragging straight on the graphics itself.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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