Re: planar polygon plot
- To: mathgroup at smc.vnet.net
- Subject: [mg16442] Re: planar polygon plot
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 13 Mar 1999 02:21:50 -0500
- References: <7c6fad$i0s$7@dragonfly.wolfram.com>
- Sender: owner-wri-mathgroup at wolfram.com
Richard S Hsu wrote in message <7c6fad$i0s$7 at dragonfly.wolfram.com>... >Hi, > >I want to plot a planar polygon in 3D with shading. >when the polygon is concave, the shading could be wrong. > >For a simple example: > > Show[ Graphics3D[ Polygon[ { {0,0,0}, {1,0.5,0}, {2,0,0}, > {2,2,0}, {1,1.5,0}, {0,2,0} } ] ] ]; > >I know what Mathematica is doing here, but want to know >if there is a easy way to get correct shading for general >3D planar polygons. > >Thanks Richard, Not a general solution but it works if the polygon is starlike from its centroid: Show[ Graphics3D[ Polygon[ { {0,0,0}, {1,0.5,0}, {2,0,0}, {2,2,0}, {1,1.5,0}, {0,2,0} } ] /.Polygon[lst_]:> {Line[#],EdgeForm[], Polygon[ Prepend[#, Plus@@lst/Length[lst]]]}&[Append[lst,First[lst]]]] ]; For a general solution see Tom Wickham-Jones's book, Mathematica Graphics p448. This uses the accompanying package ExtendGraphics`NonConvexTriangulate` - available from MathSource. --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565