# Code to do geometric transformation equivalent to dragging by mouse in circle

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}]]

• "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. Sep 11, 2022 at 14:17
• 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. Sep 11, 2022 at 14:22
• It is clearly some rotation. But you should define more clearly what rotation you want. About a fixed axes or about a moving axis. Sep 11, 2022 at 15:26
• The default option for "RotationControl" in Graphics3D is "ArcBall". Therefore, you should look online for the equations of the arcball camera (example). Sep 11, 2022 at 15:38
• @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/… Sep 11, 2022 at 16:12

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}]


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]}]]