Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Countur/Density plot on sphere

365 views
Skip to first unread message

Blaž Kranjc

unread,
Jul 25, 2012, 2:36:41 AM7/25/12
to
Hello,
I have a problem in which I need to evaluate a function on the the surface of the sphere. I've used ColorFunction and MeshFunctions before, but they seem to work only on analicial functions, my function is numerical integration in given point and returns a number. Is there any way to plot that kind of graph (colored sphere depending on a value) or can anybody suggest other ways to represent this.

Thank you,

Bla=C5=BE Kranjc

Blaž Kranjc

unread,
Jul 26, 2012, 3:33:34 AM7/26/12
to

Suprisingly this work now (I tried it 10+ times before and it didn't), I
just have another question,
SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, Hue[f[Abs@z]]] and SphericalPlot3D[1, {t,
0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, Hue[f[z]]]
returned the same plots, therefore this isn't really plotting my values??
I don't really trust this now.

I also tried calculating a lot of points on a sphere and finding a value in
given point, than Show them all with Graphics3D giving them color based on
value, BUT sphere loses it's depth and is full of holes now. so it doesn't
look ok.

2012/7/25 Bob Hanlon <hanlo...@gmail.com>

> This is quite slow but if I understand what you want
>
> f[t_?NumericQ, p_?NumericQ] :=
> NIntegrate[(t + x)/(1 + p + x), {x, 0, 1}]
>
>
> SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi},
> ColorFunction ->
> Function[{x, y, z, t, p, r}, Hue[f[t, p]]],
> Mesh -> 10,
> MeshFunctions ->
> {Function[{x, y, z, t, p, r}, f[t, p]]}]
>
>
> Bob Hanlon

Bob Hanlon

unread,
Jul 26, 2012, 3:34:35 AM7/26/12
to
The default is ColorFunctionScaling -> True. Either set it to False
or rescale to taste.

f[x_] = x;

Row[SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, #],
ColorFunctionScaling -> False,
ImageSize -> 275,
ViewPoint -> {5, -5, 0}] & /@
{Hue[f[Abs@z]], Hue[f[z]]}]


Bob Hanlon

Bob Hanlon

unread,
Jul 26, 2012, 3:37:36 AM7/26/12
to
This is quite slow but if I understand what you want

f[t_?NumericQ, p_?NumericQ] :=
NIntegrate[(t + x)/(1 + p + x), {x, 0, 1}]


SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, Hue[f[t, p]]],
Mesh -> 10,
MeshFunctions ->
{Function[{x, y, z, t, p, r}, f[t, p]]}]


Bob Hanlon


christopher arthur

unread,
Jul 26, 2012, 3:33:04 AM7/26/12
to
Hello,

Each point would be a polygon, and you would set the color like for any
polygon. This is not very useful for many points on the surface of the
sphere because it takes a lot of memory.

I would use POVRay years ago to put a texture map around the sphere with
the right image of the function. You could evaluate the integration at
all the points in mathematica then take the data into POVRay as an image
map. Maybe this isn't necessary with the newer versions of mathematica.

Bla� Kranjc a �crit :

djmpark

unread,
Jul 27, 2012, 5:01:29 AM7/27/12
to
For those who have Presentations here is a solution.

f[t_?NumericQ, p_?NumericQ] =
Integrate[(t + x)/(1 + p + x), {x, 0, 1}, Assumptions -> p > -1]

<< Presentations`

Draw2D[
{g1 = ContourDraw[
f[\[Theta], \[Phi]], {\[Theta], 0, 2 \[Pi]}, {\[Phi], 0, \[Pi]},
ColorFunction -> (ColorData["BrownCyanTones"][1 - #] &),
MaxRecursion -> 3]},
Frame -> True, FrameLabel -> {\[Theta], \[Phi]},
ImageSize -> 300]

f1 = n1 =
Function[{\[Theta], \[Phi]}, {Sin[\[Phi]] Cos[\[Theta]],
Sin[\[Phi]] Sin[\[Theta]], Cos[\[Phi]]}];
Draw3DItems[
{Opacity[1], g1 // RaiseTo3D[f1, n1]},
NeutralLighting[0, .5, .4, 120 Degree, -40 Degree],
NiceRotation,
Boxed -> False,
PlotRegion -> {{-0.3, 1.3}, {-0.3, 1.3}},
ViewPoint -> {1, -1, 1} 3,
ImageSize -> 250]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/index.html


From: Bla=BE Kranjc [mailto:blaz.k...@gmail.com]


Suprisingly this work now (I tried it 10+ times before and it didn't), I
just have another question, SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, Hue[f[Abs@z]]] and SphericalPlot3D[1, {t,
0, 2 Pi}, {p, 0, Pi},
ColorFunction ->
Function[{x, y, z, t, p, r}, Hue[f[z]]] returned the same plots,
therefore this isn't really plotting my values??
I don't really trust this now.

I also tried calculating a lot of points on a sphere and finding a value in
given point, than Show them all with Graphics3D giving them color based on
value, BUT sphere loses it's depth and is full of holes now. so it doesn't
look ok.

2012/7/25 Bob Hanlon <hanlo...@gmail.com>

> This is quite slow but if I understand what you want
>
> f[t_?NumericQ, p_?NumericQ] :=
> NIntegrate[(t + x)/(1 + p + x), {x, 0, 1}]
>
>
> SphericalPlot3D[1, {t, 0, 2 Pi}, {p, 0, Pi}, ColorFunction ->
> Function[{x, y, z, t, p, r}, Hue[f[t, p]]], Mesh -> 10,
> MeshFunctions ->
> {Function[{x, y, z, t, p, r}, f[t, p]]}]
>
>
> Bob Hanlon
>
>
> On Wed, Jul 25, 2012 at 2:33 AM, Bla=BE Kranjc
> <blaz.k...@gmail.com>
0 new messages