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

Light and surface colors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58688] Light and surface colors
  • From: Daniele Lupo <danwolf_no_spam_please_ at libero.it>
  • Date: Thu, 14 Jul 2005 02:49:15 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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: Simplify
  • Next by Date: Re: //N bug, but WHY?
  • Previous by thread: D[...] change in 5.1
  • Next by thread: Re: Light and surface colors