A way to fix coloring

*Subject*: [mg3201] A way to fix coloring*From*: reinsch at tops.lbl.gov (Matthias Reinsch)*Date*: 18 Feb 1996 03:56:13 -0600*Approved*: usenet@wri.com*Distribution*: local*Newsgroups*: wri.mathgroup*Organization*: Lawrence Berkeley Laboratory, Berkeley CA*Sender*: daemon at wri.com

are colored incorrectly (see ProblemPlot below). Enclosed in this message is FastFixColoring, a solution to this problem. I have already notified WRI about this, and they suggested I provide this information to other sites so that users who need correctly colored plots can generate them. ====================================================================== An example of a plot in which the coloring has errors: ====================================================================== f = N @ ComplexExpand @ Expand[SphericalHarmonicY[6, 3, th, ph] - SphericalHarmonicY[6,-3, th, ph] ] ProblemPlot = ParametricPlot3D[ (1+.2 f Sin[6/11 Pi]) * {Sin[th] Cos[ph],Sin[th] Sin[ph],Cos[th]}, {th,0,Pi},{ph,0,2 Pi}] ====================================================================== The corrected plot: ====================================================================== FastFixColoring[gr3D_] := (viewpt = ViewPoint /. gr3D[[2]]; Graphics3D[ Flatten @ Map[ (p4 = #[[1]]; p42=Drop[p4,{2}]; p44=Drop[p4,{4}]; m={viewpt,p4[[1]],p4[[1]]}; If[ Det[m-p44] Det[m-p42] < 0, {Polygon @ p44, Polygon @ p42}, {#}])&, gr3D[[1]] ], gr3D[[2]] ] ) Show @ FastFixColoring @ ProblemPlot