Re: Function Coloring with ParametricPlot3D
- To: mathgroup at smc.vnet.net
- Subject: [mg31270] Re: Function Coloring with ParametricPlot3D
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 26 Oct 2001 04:28:10 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <9r57ic$s3v$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
a simple trick,
Needs["Graphics`Colors`"]
cfun[x_, y_] :=
Module[{val = Sqrt[x^2 + y^2]},
Which[val <= 7, PaleGreen, val > 7, OrangeRed]]
(* don't display it because anyUndefinedFunction[] is not a color ...*)
pp = ParametricPlot3D[{x, y, 0, anyUndefinedFunction[x, y]}, {x, 0, 10},
{y, 0, 10},
PlotPoints -> 8, Lighting -> False, DisplayFunction -> Identity];
(* but it has numbers for it's arguments and *)
Show[pp /. anyUndefinedFunction-> cfun, DisplayFunction ->
$DisplayFunction]
work as expected.
Regards
Jens
David Park wrote:
>
> Dear MathGroup,
>
> There is a percularity of the ParametricPlot3D command with color
> specification as the fourth element that bugs me.
>
> It appears that this is the way that the algorithm works. Mathematica
> calculates the color that would result from the four corners of the square
> and then blends the colors. I suppose that in some sense this can be
> considered to be reasonable. But if you write a color function that
> specifices a specific set of colors, this blending introduces new colors
> which one may not want. Here is an example.
>
> Needs["Graphics`Colors`"]
>
> cfun[x_, y_] :=
> Module[{val = Sqrt[x^2 + y^2]},
> Which[
> val <= 7, PaleGreen,
> val > 7, OrangeRed]]
>
> ParametricPlot3D[{x, y, 0, cfun[x, y]}, {x, 0, 10}, {y, 0, 10},
> PlotPoints -> 8,
> Lighting -> False];
>
> What I would like to do is have Mathematica determine a single function
> value for each square, perhaps by averaging the values at the four corners,
> and then apply my color function to that single value. In that case there
> would be no blending, unless I decide to do the blending in my color
> function.
>
> Does anyone know how to work around this?
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/