# Pseudo 3D locators: 3D controler for a 2D locator pane:

Posted 6 years ago
7698 Views
|
3 Replies
|
10 Total Likes
|
 I've always enjoyed Mathematica's ability to create interactive figures. However, one challenge is creating 3D locators. In an effort to create pseudo-3D locators, I designed a locator pane whose locators can be rotated in three dimensions. Said differently, the 2D plane is the projection of locators that would exist in 3D if they had a third dimension. In reality, this is only a starting point proof-of-concept, and is kind of hackey. I use the ViewPoint, ViewVertical, and ViewCenter to determine the geometric transformation needed update the locators' positions as they are moved by rotating a corresponding 3D bounding box, or independently moved within the LocatorPane (the 2D projection of the 3D space). The locators are initialized with a random third dimension. The viewpoint is not at infinity to avoid issues with the cross product, but it's close enough to mimic the desired behavior. DynamicModule[{aa = 200, vp = {0, 0, 200}, vv = {0, 1, 0}, pts = RandomReal[{-2, 2}, {10, 3}], pts2, zvs}, pts2 = Transpose[{Dot[#, Cross[vv, vp/aa]] & /@ pts, Dot[#, vv] & /@ pts}]; zvs = pts - Map[#[[1]] Cross[vv, vp/aa] + #[[2]] vv &, pts2]; Panel@Column[{ Row[{ EventHandler[ Dynamic@ Graphics3D[{}, ImageSize -> Tiny, Boxed -> True, ViewPoint -> Dynamic@vp, ViewVertical -> Dynamic@vv, ViewCenter -> {1/2, 1/2, 1/2}, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}], {"MouseDragged" :> ( pts2 = Transpose[{Dot[#, Cross[vv, vp/aa]] & /@ pts, Dot[#, vv] & /@ pts}]; zvs = pts - Map[#[[1]] Cross[vv, vp/aa] + #[[2]] vv &, pts2])}, PassEventsDown -> True ], " 3-D Slider" }], Framed@EventHandler[ LocatorPane[Dynamic@pts2, Plot[{}, {x, -2, 2}, PlotRange -> Sqrt[2] {{-2, 2}, {-2, 2}}, ImageSize -> Medium, AspectRatio -> 1]], {"MouseDragged" :> ( pts = zvs + Map[#[[1]] Cross[vv, vp/aa] + #[[2]] vv &, pts2]; )}, PassEventsDown -> True ] }] ] 
3 Replies
Sort By:
Posted 6 years ago
 Very interesting.On the same topic, one thing that I have always missed, and that is fundamental on a 3D engineering environment where we need to navigate through big 3D spaces without getting lost (or seasick...), is dynamic manipulation of the ViewCenter. I have tried to produce this before, but it always felt too hacky. Have you thought on such application for you code?Many times I manipulate big 3D objects, and it always feels too difficult inside Mathematica, because the 3D manipulation paradigm was thought for mathematic plots. For instance, most (all?) CAD software (or viewers), use the mouse wheel either to zoom in or out, or to accelerate when in fly mode (which is kind of a wing commander game mode; one software where it works great is on Blender). Since Mathematica is a vertical document, the wheel is locked to scroll along the document. But why can't it have a more CAD oriented behaviour when a Graphics object is selected? Well, sorry, this is already getting out of your topic.Again, nice work!