Mathematica Asked on February 7, 2021
I want to use the locator in MMA to reproduce the following animation:
But MMA’s function Locator
doesn’t support 3D coordinates. What can I do to reproduce this animation?
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"])}]]
Answered by A little mouse on the pampas on February 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP