Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Re: Problems updating Graphics3D Polygons

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77715] Re: [mg77651] Re: Problems updating Graphics3D Polygons
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Fri, 15 Jun 2007 04:40:33 -0400 (EDT)
  • References: <21792802.1181814725599.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

A solution doesn't HAVE to be this flexible, but... why the heck not?

Clear[scaleZ, array, threeD]
array[dims_List] = ArrayQ[#] && Dimensions[#] == dims &;
threeD[m_?(array[{3, 3}])] := m
threeD[m_?(array[{3}])] := DiagonalMatrix@m
threeD[f_?NumericQ] := DiagonalMatrix@{1, 1, f}
scaleZ[graphics_, m_] :=
  graphics /. Polygon[pts_] :> Polygon[pts.threeD[m]]

Try it out:

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}}]}]

scaleZ[gobject, 1/3]

scaleZ[gobject, {1, 2, 1}]

scaleZ[gobject, RandomReal[{1/2, 3/2}, {3, 3}]]

Bobby

On Thu, 14 Jun 2007 04:33:03 -0500, chuck009 <dmilioto at comcast.com> wrot=
e:

> Hey guys.  I did make progress with this by coding:
>
> UpdatePoints[factor_][p_] := Block[{x, y, z},
>       {x, y, z} = p;
>       z *= factor;
>       Return[{x, y, z}];
>       ];
>
> ScaleZ[graphics_, factor_] := Module[{g2}, g2 = graphics /.Polygon=
[pts_]  =

> :> Polygon[UpdatePoints[factor] /@ pts];
>       Return[g2];
>       ];
>
> Perhaps though someone can suggest a more elegant "one-liner"
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: Re: licensing issues with V6.0 Financial Data
  • Next by Date: Re: Integrate question
  • Previous by thread: Re: Problems updating Graphics3D Polygons
  • Next by thread: Re: Problems updating Graphics3D Polygons