Re: Coloring a Sphere
- To: mathgroup at smc.vnet.net
- Subject: [mg9382] Re: Coloring a Sphere
- From: "Xah" <xah at best.com>
- Date: Sun, 2 Nov 1997 01:02:16 -0500
- Organization: smtp.best.com
- Sender: owner-wri-mathgroup at wolfram.com
In article <63etvv$k18 at smc.vnet.net>, david at therch.chem.usu.edu (David
Farrelly) wrote:
>What I would like to do is to plot the sphere and color it
>according to the value of the function Abs[D] (on each polygon)
Hi,
It may be possible to do it with ParametricPlot3D or ContourPlot3D with
some special options, but I havn't looked into them. Here's a primitive
solution:
The outline is this: You generate a regular polyhedron and project it to
a sphere. For each Polygon in the graphics object, you calculate their
centroid, feed this centroid into your colorFun that returns a
SurfaceColor object. Then show the result:
Needs["Graphics`Polyhedra`"];
Clear[colorFun];
colorFun::"usage"="colorFun[{x,y,z}] returns a SurfaceColor object.";
colorFun[{_,_,_}]:=
Module[{},SurfaceColor[RGBColor[Random[],Random[],Random[]]]];
Show[Graphics3D[{EdgeForm[],
First@((Geodesate[#,4]&@
Polyhedron at Icosahedron)/.Polygon[pts_]:>{
colorFun@(Plus@@pts/Length at pts),Polygon at pts})}],
AspectRatio->Automatic,LightSources->{{{1,1,1},GrayLevel[1]}}];
The code Polyhedron at Icosahedron generates an icosahedron. The code
Geodesate[#,4]&@Polyhedron at Icosahedron project it onto a sphere. Each
Polygon is then replaced by {color,Polygon}. The color is calculated
using colorFun@(Plus@@pts/Length at pts), which is colorFun applied to the
centroid.
With a carefully designed colorFun, you could have a beautifully
rendered sphere. If you do, show us!
Xah, xah at best.com
http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
Mountain View, CA, USA