MathGroup Archive 2011

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

Search the Archive

Coordinates from Graphics3D images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117424] Coordinates from Graphics3D images
  • From: Russell Chipman <rchipman at optics.arizona.edu>
  • Date: Fri, 18 Mar 2011 05:59:46 -0500 (EST)

Dear MathGroup
I am searching for a way to find the {x,y,z} coordinates at every pixel in a Graphics3D view.

I found a way to do this in ParametricPlot3D using ColorFunction, but Graphics3D does not accept ColorFunction as an option.

To get the pixels at every coordinate ParametricPlot3D view, I encode the coordinates into an RGBColor image, then recover them from the three color planes.  Because the arguments to RGBColor are 0 < x < 1, first I scale all coordinates into this range.  Later I unscale them.

Take the example function

ff[u_,v_]:={(2+Cos[v])Cos[u]/\[Pi],(2+Cos[v])Sin[u]/\[Pi],Sin[v]}

and the view

ParametricPlot3D[ff[u,v],{u,0,2\[Pi]},{v,0,2 \[Pi]},ViewPoint->{4,-4,8}]

My scaling and unscaling utilities need the maximum and minimum coordinates as inputs

squeeze[x_,min_,max_]:=(x-min)/(max-min)
unsqueeze[fx_,min_,max_]:=fx (max-min)+min

Now I can get an list with each pixel's {x,y,z} as

xyz=Map[unsqueeze[#,-1,1]&,ImageData[Image[ParametricPlot3D[ff[u,v],{u,0, 2\[Pi]},{v,-\[Pi]/2,\[Pi]/2},
ColorFunction->Function[{x,y,z},Glow[RGBColor[squeeze[x,-1,1],squeeze[y,-1, 1],squeeze[z,-1,1]]]],
ColorFunctionScaling->False,ViewPoint->{4,-4,8},Mesh->False,Boxed->False,Axes->False,Background->Black]]],{2}];

Now, for example, you can print the pixel coordinates or  view the points in 3D with a function like

Graphics3D[Map[{Hue[(#[[3]]+1)/2],Point[#]} &,xyz[[ ;; ;;10, ;; ;;10,All]],{2}]]

My question is if there is a method for Graphics3D which can recover pixel coordinates with a similar result?

Thank you,
Russell Chipman


  • Prev by Date: Re: The derivative of 1
  • Next by Date: Re: Wolfram, meet Stefan and Boltzmann
  • Previous by thread: Re: InheritScope
  • Next by thread: Re: Coordinates from Graphics3D images