Mathematica Coloring surfaces in Mathematica

AI Thread Summary
To color a 3D parametric surface in Mathematica based on a function defined on the surface, use the ParametricPlot3D function combined with the ColorFunction option. The suggested approach involves defining a custom function that checks the value of f at each point p. Specifically, the ColorFunction can be set to return white for points where f(p) is greater than or equal to zero and gray for points where f(p) is less than zero. An example implementation is provided, demonstrating how to structure the ColorFunction to achieve the desired coloring effect.
Peaks Freak
Messages
6
Reaction score
0
Hi, all,

I have a question about coloring a 3D parametric surface in Mathematica.

Setup:

Take as given a surface M in R^3 and a parameterization of that surface p:[a,b] x [c,d] -> R^3. Let f:M -> R be a function defined on M.

Question:

How can I plot this surface so that points p with f(p) >= 0 are colored white and points p with f(p) < 0 are colored gray?

Notes:

I'm using ParametricPlot3D and trying to work with the ColorFunction -> Function construct, but can't quite get it right.

Thanks in advance!

P
 
Physics news on Phys.org
You can use the ColorFunction option when you are plotting parametric surfaces. For example, you can try something like this:

ParametricPlot3D[p[u,v], {u,a,b}, {v,c,d},
ColorFunction ->
Function[{x,y,z,u,v},
If[f[p[u,v]] >= 0, White, Gray]]]
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
19
Views
2K
Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
4
Views
1K
Back
Top