MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Locator 3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84651] Re: [mg84618] Re: Locator 3D
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 8 Jan 2008 01:31:49 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <fi0ndv$5c5$1@smc.vnet.net> <fibg4o$5qo$1@smc.vnet.net> <200801070738.CAA26065@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Two unpleasant aspects of this (due to Mathematica 6, not your code!):

(1) the cursor within the graphic persists in displaying as two curled 
arrows (suggesting rotation); but

(2) there does not seem to be a way to actually rotate the 3D graphic 
while the event handler for the mouse is active.

Fred Klingener wrote:
>> <roby.nowak at gmail.com> wrote in message news:fi0ndv$5c5$1 at smc.vnet.net...
>>> Hi everybody,
>>>
>>> is there something like a 3D Locator in Mathematica 6.0 ?
>>> how could such a thing be realised ?
> 
> It's not Locator, but here's a cut at a way to pick 3D objects with the 
> mouse. It's based on the idea advanced by others, using the {"MouseDown" :> 
> ({f, b} = MousePosition["Graphics3DBoxIntercepts"])} return on a 3D graphic 
> inside an EventHandler.
> 
> The front and back box intercepts {f, b} can be used to construct a Pluecker 
> line through the displayed plot range, and interactions and picking can be 
> implemented with the contents.
> 
> The modern standard reference for Pluecker lines (at least in the CG world) 
> seems to be Shoemake's 1998 notes in the Ray Tracing News:
> 
> http://www.acm.org/tog/resources/RTNews/html/rtnv11n1.html.
> 
> Unfortunately (AFAIC), Shoemake defined his moment term with a left-hand 
> rule, and I've switched that to right-hand to inject confusion right at the 
> start but to save myself grief later.
> 
> The following example does about the simplest picking to illustrate the 
> method. I generate a random point cloud, then pick and highlight individual 
> points with mouse clicks (using MouseDown instead of MousePosition.)
> 
> (* 2008-01-06 Fred Klingener *)
> 
> (* Pluecker Line from point Q to point P
>    use this to construct a Pluecker pick line through the 3D space from the
>    front and back "Graphics3DBoxIntercepts" *)
> 
> pLine[P_, Q_] := {P - Q, Q\[Cross]P}
> 
> (* vector from point P normal to Pluecker line L *)
> 
>  vectorLP[P_, L_] := Module[{U = L[[1]], V = L[[2]]},
>   U\[Cross](P\[Cross]U - V)/U.U]
> 
> (* distance from point P to Pluecker line L *)
> 
> distanceLP[P_, L_] := Norm[vectorLP[P, L]];
> 
> (* Example - picking random 3D points *)
> nPoints = 10;
> DynamicModule[{
>   f = {0.556581, -1.43647, 1.5}
>   , b = {-1.14868, 1.5, -0.792715}
>   , cloud =
>    Table[{RandomReal[{-1, 1}], RandomReal[{-1, 1}],
>      RandomReal[{-1, 1}]}
>     , {i, nPoints}]
>   , d0
>   , p}
>  , Column[{
>    Row[{EventHandler[
>       image = Graphics3D[{Point[cloud]
>          , Line[Dynamic@{f, b}]
>          , {Red, PointSize[0.05],
>           Dynamic@Point[
>             p = cloud[[
>               Position[
>                 d0 = Table[
>                   distanceLP[cloud[[i]], pLine[f, b]], {i, nPoints}],
>                 Min@d0][[1, 1]]]]]}
>          , Dynamic@Text[ToString[p], p, {-1, 1}]
>          }
>         , PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 1.5}}
>         , Axes -> True
>         , AxesLabel -> {"x", "y", "z"}
>         , AspectRatio -> Automatic
>         , ImageSize -> {300, 300}
>         ] (* Graphics3D *)
>       , {"MouseDown" :> ({f, b} =
>           MousePosition["Graphics3DBoxIntercepts"])}
>       ] (* EventHandler *)
>      , Show[image, ViewPoint -> {2, 2, 2}]
>      }] (* Row *)
>    , Row[{Graphics[Text["Picking view.
>        The pick line is normal to the screen.
>        The point closest to the pick line is high-lighted.
>        Click on a point to select it."], ImageSize -> {300, 60}]
>      , Graphics[
>       Text["Side view of point field showing point field, selected \
> point and pick line.\nThe view can be manipulated with the mouse in \
> the usual way"], ImageSize -> {300, 60}]
>      }]
>    }] (* Col *)
>  ] (* DynamicModule *)
> 
> Pluecker lines have simple relations for picking polygons too, as long as 
> they're simple enough.
> 
> In principle anyway, we should be able to dissect a GraphicsComplex that
> Mathe>matica generates for more complicated forms (Plot3D, maybe
> RegionPlot3D, etc.) and 
> interact with their elements using the Pluecker pick line.
> 
> Hth,
> Fred Klingener 
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • References:
  • Prev by Date: Re: Global Fitting multiple equations to
  • Next by Date: Re: PC requirments
  • Previous by thread: Re: Locator 3D
  • Next by thread: 3D Picker (was: Locator 3D)