Message Boards Message Boards

GROUPS:

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

Posted 6 years ago
7699 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.

enter image description here

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

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!

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.

enter image description here

enter image description here - you earned "Featured Contributor" badge, congratulations !

Dear @Kevin Daily, this is a great post and it has been selected for the curated Staff Picks group. Your profile is now distinguished by a "Featured Contributor" badge and displayed on the "Featured Contributor" board.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract