MathGroup Archive 2007

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

Search the Archive

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

  • To: mathgroup at
  • Subject: [mg80899] Incorrect, misleading, "Operate Directly on Graphics" example.
  • From: "Q.E.D." <aoe at>
  • 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.

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:


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:

  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

So how do you get this result just using the plain graphics object from

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


  • 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.