Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Colored Surface

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53539] Re: [mg53520] Colored Surface
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 16 Jan 2005 22:23:56 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Different methods...

Needs["Graphics`Colors`"]

Define a parametrization for a unit sphere with the fourth parameter as the
color according to the Help for ParametricPlot3D. Then plot the sphere.

sphere[\[Theta]_, \[Phi]_] := {Sin[\[Theta]]Cos[\[Phi]],
    Sin[\[Theta]]Sin[\[Phi]], Cos[\[Theta]], Blue}

ParametricPlot3D[
    sphere[\[Theta], \[Phi]] // Evaluate, {\[Theta], 0, \[Pi]}, {\[Phi], 0,
      2\[Pi]},
    Lighting -> False];

It was necessary to turn off the lighting so that the blue color would show.
The trouble with the plot is that is has no shading. We can obtain shading
by turning the lighting back on (the default) and using SurfaceColor for the
color.

sphere[\[Theta]_, \[Phi]_] := {Sin[\[Theta]]Cos[\[Phi]],
    Sin[\[Theta]]Sin[\[Phi]], Cos[\[Theta]], {SurfaceColor[Blue]

ParametricPlot3D[
    sphere[\[Theta], \[Phi]] // Evaluate, {\[Theta], 0, \[Pi]}, {\[Phi], 0,
      2\[Pi]},
    Lighting -> True];

This has shading but the trouble is that the whole sphere is too dark. So
let's try using a lighter blue color.

sphere[\[Theta]_, \[Phi]_] := {Sin[\[Theta]]Cos[\[Phi]],
    Sin[\[Theta]]Sin[\[Phi]], Cos[\[Theta]], {SurfaceColor[CornflowerBlue]}}

ParametricPlot3D[
    sphere[\[Theta], \[Phi]] // Evaluate, {\[Theta], 0, \[Pi]}, {\[Phi], 0,
      2\[Pi]},
    Lighting -> True];

That is better, but the sphere is still rather darker than CornflowerBlue
and some other color is coming in. That is because the natural lighting is
colored and highly saturated. The natural lighting overwhelms lighter
surface colors.

Better control, and a more natural construction can be obtained by using the
DrawGraphics package from my web site below.

Needs["DrawGraphics`DrawingMaster`"]

Now you can use a standard parametrization for the sphere because the color
is specified separately in the drawing statement.

sphere[\[Theta]_, \[Phi]_] := {Sin[\[Theta]]Cos[\[Phi]],
    Sin[\[Theta]]Sin[\[Phi]], Cos[\[Theta]]}

Draw3DItems[
    {SurfaceColor[CornflowerBlue],
      EdgeForm[ColorMix[CornflowerBlue, Black][0.4]],
      ParametricDraw3D[
        sphere[\[Theta], \[Phi]] // Evaluate, {\[Theta], 0, \[Pi]}, {\[Phi],
          0, 2\[Pi]}]},
    NeutralLighting[0.3, 0.5, 0.2],
    Background -> Linen,
    Axes -> False,
    BoxStyle -> Gray,
    Axes -> True];

Here the SurfaceColor was specified before drawing the sphere. I also added
an EdgeForm that makes the edges (the "mesh") only slightly darker than the
surface color. That gives a more subdued mesh. ColorMix is a DrawGraphics
function that allows you to mix any two from Graphics`Colors`.
NeutralLighting[saturation, brightness, ambientlight] inserts a set of
Lighting options to specify the lighting used by Mathematica. By turning
down the color saturation we obtain more neutral lighting that doesn't
interfere with the surface color. It is also possible to rotate the lights.

That gives a lighter colored surface with shading and a subdued "mesh".

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/






From: Hannachi [mailto:nicolas_hannachi at yahoo.fr]
To: mathgroup at smc.vnet.net

How to do a just blue sphere (for example) ?





  • Prev by Date: Re: Re: importing mat format doesn't import variable names
  • Next by Date: Re: Re: easy question about random numbers
  • Previous by thread: Re: Colored Surface
  • Next by thread: gyrocompass notebook