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

Posted 6 years ago
7697 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
 This is a very nice approach to indeed a challenging interface problem of 3D locators. Thanks for sharing! I added a short movie to your post. I remember another idea from Maxim Rytin Voronoi Diagram on a Sphere, but that needs to be updated for the latest version of Mathematica.