MathGroup Archive 2005

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

Search the Archive

Re: Light and surface colors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58702] Re: [mg58688] Light and surface colors
  • From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
  • Date: Fri, 15 Jul 2005 03:02:17 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Daniele, with the following commands you will see a red sphere with shadows
from the lighting:

<<Graphics`;
mySphere=ContourPlot3D[x^2+y^2+z^2-1,{x,-1,1},{y,-1,1},{z,-1,1},
      DisplayFunction-> Identity];
Show[Graphics3D[SurfaceColor[RGBColor[1,0,0]]],mySphere,
  DisplayFunction-> $DisplayFunction]
 

This is an improvement:

<<Graphics`;
mySphere=ContourPlot3D[x^2+y^2+z^2-1,{x,-1,1},{y,-1,1},{z,-1,1},
      PlotPoints->{7,5},DisplayFunction-> Identity];
Show[Graphics3D[EdgeForm[]],
  Graphics3D[SurfaceColor[RGBColor[1,0,0]]],mySphere,
  DisplayFunction->$DisplayFunction]

Bye!
Jose Luis
http://homepage.cem.itesm.mx/lgomez/ 

-----Mensaje original-----
De: Daniele Lupo [mailto:danwolf_no_spam_please_ at libero.it] 
Enviado el: Jueves, 14 de Julio de 2005 01:49 a.m.
Para: mathgroup at smc.vnet.net
Asunto: [mg58688] Light and surface colors

Hi to everyone.

I've just obtained a Student License of Mathematica, and I'm working in
graphics...

I've created, after a half-day of work, an image representing an ellipsoid,
with a colored surface

When I try to represent it, I must put Ligthing->False to see surface
colors.

I'd like to know if there's a way to obtain a rendered image, in which I
can have both light and surface color, to give a shadow to the figure and
create a more 3D effect.

Thanks for replies.

Below there's the code...


Daniele


--------------------------

<< Graphics`ContourPlot3D`;

a = 7; b = 5; c = 4; r = 1;

ellipsoid = ContourPlot3D[
    (x/a)^2 + (y/b)^2 + (z/c)^2 - r, {
    x, -10, 10}, {y, -10, 10}, {z, -10, 10},
    PlotPoints -> 12,
    AspectRatio -> Automatic
    ];

(*It finds the median point of vertices of a list of a 3D coordinates*)
midpoint[l_] := Apply[Plus, Transpose[l], 2]/Length[l];


(*Function to map in the ellipsoid surface*)
pressure[x_, y_, z_] := x^2 + y^2 + Sin[4z];

(*Color Function*)
color[x_] := Hue[pressure @@ midpoint[x]/50];

(*Rule to change original graphic object*)
colorpolygon = Polygon[coord_] :>
{color[coord],EdgeForm[{}],Polygon[coord]};

(*creation of new, colored ellipsoid*)
coloredellipse = ellipsoid /. colorpolygon;

(*Visualization of the shape*)
(*I'd like to have also the light...*)
Show[coloredellipse, Lighting -> False];


  • Prev by Date: Re: Light and surface colors
  • Next by Date: Re: Light and surface colors
  • Previous by thread: Re: Light and surface colors
  • Next by thread: Re: Light and surface colors