Re: Coordinates from Graphics3D images
- To: mathgroup at smc.vnet.net
- Subject: [mg117450] Re: Coordinates from Graphics3D images
- From: Fred Klingener <gigabitbucket at BrockEng.com>
- Date: Sat, 19 Mar 2011 05:17:43 -0500 (EST)
- References: <ilvdvf$eiu$1@smc.vnet.net>
On Mar 18, 6:59 am, Russell Chipman <rchip... at optics.arizona.edu>
wrote:
> 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}]
As nifty as your approach is, the easy way to get the nodes for this
surface is to look at the structure:
pp3D= ParametricPlot3D[ff[u,v],{u,0,2\[Pi]},{v,0,2 \[Pi]},ViewPoint-
>{4,-4,8}]
pp3D is a GraphicsComplex, and you can browse the structure with
something like
Pane[
FullForm[
pp3D]
, Scrollbars -> {False, True}
, ImageSize -> {300, 300}
]
(I don't know why Mathematica doesn't have a ScrollForm)
The first argument of the GraphicsComplex is a list of the points on
the surface, and you can retrieve them with
Graphics3D[
Point[
points=
Cases[
pp3D
, GraphicsComplex[pt__, ___] :> pt
, Infinity
]
]
]
Most of Mathematica's 3D structures can be dissected this way, and if
you need the connectivity, look at the list of primitives pp3D//Normal
produces. For example, you can get all the isolated Polygons with
Graphics3D[
polygons=
Cases[
pp3D // Normal
, _Polygon
, Infinity
]
or the mesh lines (if you specified meshing in the original.)
Graphics3D[
lines=
Cases[
pp3D // Normal
, _Line
, Infinity
]
]
Hth,
Fred Klingener