       Re: Coordinates from Graphics3D images

• To: mathgroup at smc.vnet.net
• Subject: [mg117476] Re: Coordinates from Graphics3D images
• From: Heike Gramberg <heike.gramberg at gmail.com>
• Date: Sat, 19 Mar 2011 06:17:39 -0500 (EST)

```If you're using mathematica 8 and your 3D object consists of polygons, you =
could use Texture. You would get the same effect as the ColorFunction in Pa=
rametricPlot3D when you take the texture data to be a suitable 3-dimensiona=
l matrix and the VertexTexturCoordinates of your Graphics3D object equal to=
its (scaled) vertex coordinates. There is an example in basic examples sec=
tion in the documentation for VertexTextureCoordinates where they do exactl=
y that. From there on I guess you can use the same functions as before.

Heike

On 18 Mar 2011, at 10:59, Russell Chipman wrote:

> Dear MathGroup
> I am searching for a way to find the {x,y,z} coordinates at every pixel i=
n a Graphics3D view.
>
> I found a way to do this in ParametricPlot3D using ColorFunction, but Gra=
phics3D 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 al=
l 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 coordinat=
es 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[(#[]+1)/2],Point[#]} &,xyz[[ ;; ;;10, ;; ;;10,All]=
],{2}]]
>
> My question is if there is a method for Graphics3D which can recover pixe=
l coordinates with a similar result?
>
> Thank you,
> Russell Chipman

```

• Prev by Date: Re: How to add window with values a,b
• Next by Date: Following position change in different vectors
• Previous by thread: Re: Coordinates from Graphics3D images
• Next by thread: Re: Coordinates from Graphics3D images