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: [mg77756] Re: [mg77705] Re: Problems updating Graphics3D Polygons
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sat, 16 Jun 2007 03:25:22 -0400 (EDT)
  • References: <12927846.1181901440802.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

I'm multiplying the polygon list by a 3x3 matrix.

(I posted this before, but just in case...)

array[dims] checks the dimensions of its argument, threeD changes a scalar  
or 3-vector into a 3x3, and scaleZ multiplies the polygon list by that  
matrix. The multiplication is pts.matrix; pts is n x 3 and matrix is 3x3,  
so the result is n x 3 again, still suitable as the argument to Polygon.

(This could be modified to work for 2D plots as well, but I haven't.)

Clear[scale, 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}
scale[graphics_, m_] :=
  graphics /. Polygon[pts_] :> Polygon[pts.threeD[m]]

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

scale[gobject, 1/3]

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

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

Bobby

On Fri, 15 Jun 2007 03:35:22 -0500, chuck009 <dmilioto at comcast.com> wrote:

> Thanks.  Jean-Marc noticed in my original post that I just didn't call 
> the function correctly.  I like the code you used below, the  
> pts.{{1,0,0},{0,1,0},{0,0,ratio}}.  I see what it does just not sure of  
> the construct.  I'll figure it out though.  Thanks!
>
>> "In[473]:ExpandZ[g_,ratio_]:
>> g/.Polygon[pts_]:>Polygon[{#[[1]],#[[2]],#[[3]]*ratio}
>> & /@pts];"
>>
>> There are a couple of "=" signs missing; not sure
>> what you're seeing at
>> your machine.
>>
>> This works at mine:
>>
>> Clear[expandZ]
>> expandZ[g_, ratio_] :=
>>    g /. Polygon[pts_] :>
>> Polygon[{#[[1]], #[[2]], #[[3]]*ratio} & /@
>> & /@ pts];
>>
>> But I prefer
>>
>> Clear[expandZ]
>> expandZ[g_, ratio_] :=
>>    g /. Polygon[pts_] :>
>> Polygon[pts.{{1, 0, 0}, {0, 1, 0}, {0, 0,
>> 0, 0, ratio}}];
>>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: REgarding grid point superposition
  • Next by Date: Re: Help with formatting output
  • Previous by thread: Re: Re: Problems updating Graphics3D Polygons
  • Next by thread: Re: Re: Problems updating Graphics3D Polygons