Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematica RegionPlot on the surface of the unit sphere?

I am using RegionPlot3D in Mathematica to visualise some inequalities. As the inequalities are homogeneous in the coordinates they are uniquely determined by their intersection with the unit sphere. This gives some two-dimensional regions on the surface of the sphere which I would like to plot. My question is how?

If requested I would be more than happy to provide some Mathematica code; although I believe that the answer should be independent on the details of the regions I'm trying to plot.

Thanks in advance!

Update: In case anyone is interested, I have recently finished a paper in which I used Sasha's answer below in order to make some plots. The paper is Symmetric M-theory backgrounds and was arXived last week. It contains plots such as this one:

F-moduli space for a symmetric M-theory background

Thanks again!

like image 956
José Figueroa-O'Farrill Avatar asked Apr 26 '11 10:04

José Figueroa-O'Farrill


People also ask

What is plot points in Mathematica?

PlotPoints->{n1,n2,…} specifies different numbers of initial sample points for each successive direction. The initial sample points are usually equally spaced. Adaptive procedures controlled by MaxRecursion are used to choose more sample points.

What is region plot?

RegionPlot treats the variable x and y as local, effectively using Block. RegionPlot has attribute HoldAll and evaluates pred only after assigning specific numerical values to x and y. In some cases, it may be more efficient to use Evaluate to evaluate pred symbolically first.

How do you change the color of a plot in Mathematica?

Clicking the square will bring up the Color selection palette, which after evaluation will change the color of the plot: Copy to clipboard.


2 Answers

Please look into RegionFunction. You can use your inequalities verbatim in it inside ParametricPlot3D.

Show[{ParametricPlot3D[{Sin[th] Cos[ph], Sin[th] Sin[ph], 
    Cos[th]}, {th, 0, Pi}, {ph, 0, 2 Pi}, 
   RegionFunction -> 
    Function[{x, y, z}, And[x^3 < x y z + z^3, y^2 z < y^3 + x z^2]], 
   PlotRange -> {-1, 1}, PlotStyle -> Red], 
  Graphics3D[{Opacity[0.2], Sphere[]}]}]

enter image description here

like image 200
Sasha Avatar answered Sep 28 '22 09:09

Sasha


Here's the simplest idea I could come up with (thanks to belisarius for some of the code).

  • Project the inequalities onto the sphere using spherical coordinates (with θ=q, φ=f).
  • Plot these as a flat region plot.
  • Then plot this as a texture the sphere.

Here's a couple of homogeneous inequalities of order 3

ineq = {x^3 < x y^2, y^2 z > x z^2};

coords = {x -> r Sin[q] Cos[f], y -> r Sin[q] Sin[f], z -> r Cos[q]}/.r -> 1

region = RegionPlot[ineq /. coords, {q, 0, Pi}, {f, 0, 2 Pi}, 
  Frame -> None, ImagePadding -> 0, PlotRangePadding -> 0, ImageMargins -> 0]

flat region

ParametricPlot3D[coords[[All, 2]], {q, 0, Pi}, {f, 0, 2 Pi}, 
 Mesh -> None, TextureCoordinateFunction -> ({#4, 1 - #5} &), 
 PlotStyle -> Texture[Show[region, ImageSize -> 1000]]]

animation

like image 33
Simon Avatar answered Sep 28 '22 10:09

Simon