3

I want to use the locator in MMA to reproduce the following animation:

enter image description here

But MMA's function Locator doesn't support 3D coordinates. What can I do to reproduce this animation?

1 Answers1

-1

The following code is written by chyanog:

DynamicModule[{x0, y0, z0, x1, y1, z1, pts = {{0, 0, 0}, {0, 0, 1}}, 
  pos, pos1}, 
 EventHandler[
  Graphics3D[{EventHandler[
     Dynamic@{{Riffle[{Red, Green}, 
         Tooltip[Sphere[#, 0.075], #] & /@ pts]}, 
       Line[pts], {{x0, y0, z0}, {x1, y1, z1}} = pts; 
       InfinitePlane[
        pts[[1]], {{0, z0 - z1, y1 - y0}, {z0 - z1, 0, 
          x1 - x0}}]}, {"MouseDown" :> (pos = 
         Nearest[pts, MousePosition["Graphics3DBoxIntercepts"]][[1, 
           1]];
        pos1 = FirstPosition[pts, pos]), 
      "MouseDragged" :> (pts[[pos1]] = (#[[2]] + 
             Projection[
              pos - #[[2]], #[[1]] - #[[2]]]) &@(MousePosition[
            "Graphics3DBoxIntercepts"]))}]}, ImageSize -> 400, 
   PlotRange -> 
    Table[{-1, 2}, 3]], {{"MouseClicked", 
     2} :> (First@MousePosition["Graphics3DBoxIntercepts"])}]]
  • 4
    This code is buggy and, IMO, doesn't answer the question. Also, I think you should supply a link to the code and not to chyanog's user profile. – m_goldberg Nov 25 '20 at 03:51