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

Incorrect, misleading, "Operate Directly on Graphics" example.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80899] Incorrect, misleading, "Operate Directly on Graphics" example.
  • From: "Q.E.D." <aoe at netzero.net>
  • Date: Wed, 5 Sep 2007 02:49:55 -0400 (EDT)

I looked at another example, "Operate Directly on Graphics".
It's off the "New in 6" "Dynamic Graphical Input" page, the top right image,
the small/large polyhedrons.
URL:
http://www.wolfram.com/products/mathematica/newin6/content/DynamicGraphicalInput/

This looks so neat, just apply a simple rule and you get this
change...except you don't.

Here's what I tried -- input and evaluate:

PolyhedronData["SnubDodecahedron"]

Then cut and paste the graphics object and append:

/. Polygon[x : {_, _, _}] :> {Yellow, Opacity[.3], Polygon[x]}

Nothing happens, the resulting graphics object is unchanged.

So I dug around a bit and came up with a graphics object which is of the
form (a list of polygons) expected by the rule:

Graphics3D[
 Map[Polygon,
  PolyhedronData["SnubDodecahedron", "VertexCoordinates"][[#]] & /@
   PolyhedronData["SnubDodecahedron", "FaceIndices"]]]

Now cut and paste this special graphics object and again append the rule
given by the "Operate Directly on Graphics" example:

/. Polygon[x : {_, _, _}] :> {Yellow, Opacity[.3], Polygon[x]}

And, yes it works, giving the graphics object shown as output by the
example.

So how do you get this result just using the plain graphics object from
PolyhedronData["SnubDodecahedron"]?

Here's what I ended up with as a rule:

/.Polygon[x_] :> {Polygon[Cases[x, Except[{_, _, _}]]],
 {Yellow, Opacity[.3], Polygon[Cases[x, {_, _, _}]]}}

The complexity is necessary due to the way the plain graphics object is
structured.
It keeps an array of shared vertex coordinates and a single polygon object
with a list of index lists into that array.
So the rule breaks the polygon object into two parts, one without triangles
the other with only triangles and the change applied.
This keeps the graphics object small and allows the change to be made
rapidly.

Q.E.D.




  • Prev by Date: Re: is there a better way to do constraint logic programming in Mathematica?
  • Next by Date: Re: Fwd: correction to: more than 1.5 hrs of trying: Grid
  • Previous by thread: Re: Problem in Solving Double Integral for PDF transformation
  • Next by thread: Re: Incorrect, misleading, "Operate Directly on Graphics" example.