Re: Re: planar polygon plot
- To: mathgroup at smc.vnet.net
- Subject: [mg16536] Re: [mg16442] Re: planar polygon plot
- From: Richard S Hsu <rhsu at U.Arizona.EDU>
- Date: Tue, 16 Mar 1999 04:00:14 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Dear Allan, Thank you for help. I tried 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]] ] ] ]; It works, but get a error message: First::normal: Nonatomic expression expected at position 1 in First[lst]. Append::normal: Nonatomic expression expected at position 1 in Append[lst, First[lst]]. I want to know why. Richard Hsu On Sat, 13 Mar 1999, Allan Hayes wrote: > > 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 > > > > > > >