Hello guys. Can you help me write a function which takes a Graphics3D object and multiplies the z-coordinate of each point of all the polygons by a ratio. This is what I have so far but it's not working:
In[473]:=
ExpandZ[g_,ratio_]:=
g/.Polygon[pts_]:>Polygon[{#[[1]],#[[2]],#[[3]]*ratio}& /@pts];
When I test it with this simple Graphics3D object:
gobject=Graphics3D[{Polygon[{{0.,0.5,1.28},{0.,0.,1.},{0.5,0.,1.28},{0.5,
0.5,1.64}}],Polygon[{{
0.5,0.5,1.64},{0.5,0.,1.28},{1.,0.,2.71},{1.,0.5,3.49}}]}];
It doesn't do anything:
g2=Expand[gobject,2]
InputForm[g2]
Out[475]=
â??Graphics3Dâ??
Out[476]//InputForm=
Graphics3D[{Polygon[{{0., 0.5, 1.28}, {0., 0., 1.},
{0.5, 0., 1.28}, {0.5, 0.5, 1.64}}],
Polygon[{{0.5, 0.5, 1.64}, {0.5, 0., 1.28},
{1., 0., 2.71}, {1., 0.5, 3.49}}]}]
I'll keep working on it. Thanks!