0
$\begingroup$

We can click and drag Graphics3D objects. Suppose you click and drag on such an object in the center of it and move your pointer of mouse in a circle of radius r.

If I wanted to do the same by code instead of mouse what would be the equivalent geometric transformation?

I tried using code with parameter fi, but it is behaving strangely, not as expected.

GeometricTransformation[graphics,RotationTransform[{{1, 0, 0}, 
   RotationMatrix[fi, {1, 1, 1}] . {1, 0, 0}}, (0,0,0}]]
$\endgroup$
6
  • $\begingroup$ "Strangely" - what is happening exactly? If you describe the problem, it's easier to propose a solution. Also please include complete executable code, for instance including a sample graphics object to work on, values of fi, and how you used your code for visualization. $\endgroup$
    – MarcoB
    Sep 11, 2022 at 14:17
  • $\begingroup$ I mean I can not figure out the required transformation. Just evaluate Graphics3D[Cuboid[], SphericalRegion -> True] then click somewhere in the middle of the object and drag by mouse in a circle. Then do the same with code using Manipulate or Animate. $\endgroup$ Sep 11, 2022 at 14:22
  • $\begingroup$ It is clearly some rotation. But you should define more clearly what rotation you want. About a fixed axes or about a moving axis. $\endgroup$ Sep 11, 2022 at 15:26
  • 2
    $\begingroup$ The default option for "RotationControl" in Graphics3D is "ArcBall". Therefore, you should look online for the equations of the arcball camera (example). $\endgroup$
    – Domen
    Sep 11, 2022 at 15:38
  • $\begingroup$ @Daniel Huber: What is not clear? Exact same transformation that dragging by mouse is doing on 3D objects + mouse is doing circle on the screen. It is perfectly stated. mathematica.stackexchange.com/questions/273253/… $\endgroup$ Sep 11, 2022 at 16:12

1 Answer 1

2
$\begingroup$

Likely not the simpler approach or the smoother movement. I want the ViewPoint to move in a circle around the current ViewPoint. This is a circle on a sphere. I get a bunch of points on this circle, order them and use them to adjust the ViewPoint in animate.

g = Graphics3D[Cuboid[]]
vp = Options[g, ViewPoint][[1]][[2]];
d = EuclideanDistance[{0, 0, 0}, vp];
fi = Values[
   FindInstance[
    EuclideanDistance[{0, 0, 0}, {x, y, z}] == d && 
     EuclideanDistance[vp, {x, y, z}] == 0.4, {x, y, z}, Reals, 300]];
nr = NestList[Flatten[Nearest[fi = DeleteCases[fi, #], #], 1] &, 
   fi[[1]], 299];
Animate[
Show[g, ViewPoint -> n],
 {n, nr}]

enter image description here

The following shows the initial camera position (ViewPoint) in red and the circular ViewPoints generated by 300 points for the animation.

Show[g, Graphics3D[{Point[nr], Red, Point[vp]}]]

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.