I am trying to find out how to plot a curve (or a more general area) on the surface of an object illustrated by RegionPlot3D.

Assume for example I plot a sphere


and I now want to add an illustration of all points that are on the sphere plus satisfy a further condition (such as y = 0 or even y>0). Does somebody know a way to do this?

I want to apply this to a slighty more complicated situation, so a general answer that doesn't depend on the exact type of geometry would be best!

  • $\begingroup$ Closely related. $\endgroup$ – aardvark2012 Dec 18 '17 at 10:26
  • 1
    $\begingroup$ Banana, welcome to mathemica.se! We suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign. $\endgroup$ – kglr Dec 19 '17 at 3:01

One way is to use Mesh options as follows:

legends = {{SwatchLegend[{Green}, {Style["  y  >  0 ", 16]}], 
   Right}, {LineLegend[{Red}, {Style["y == 0", 16]}], Right}}; 

Legended[RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
  MeshFunctions -> {#2 &}, Mesh -> {{0}}, MeshStyle -> Directive[Red, Thick], 
  MeshShading -> {Automatic, Green}, PlotStyle -> Opacity[.5]], legends]

enter image description here

Another example:

meshf = 3 Sin[# #2 #3] + Cos[#2 #3] - 1 &;
mesh = {-.1};
RegionPlot3D[x^2 + y^2 + z^2 <= 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 MeshFunctions -> {meshf }, Mesh -> {mesh}, 
 MeshStyle -> Directive[Red, Thick], 
 MeshShading -> {Automatic, Opacity[.7, Green]}, PlotPoints -> 100, 
 PlotStyle -> Opacity[.5]]

enter image description here

And with

meshf = Evaluate[Sum[Sin[RandomReal[5, 3].{#, #2, #3}], {7}]] &;
mesh = {-1, 0, 1};;

enter image description here

| improve this answer | |
  • $\begingroup$ This looks like a very nice idea! I will try this. However the reason I was saying "more general area" is because I tend to believe that my extra condition, stated as F(x,y,z)=c, does not describe a curve, but rather a mixture between curves, surface areas and points. This is only applicable for conditions that describe a curve on my object, do I understand that correctly? $\endgroup$ – Banana Dec 18 '17 at 7:35
  • 2
    $\begingroup$ @LiftingBanana, it would be helpful if you post and example of F(x,y,z) = c describing something other than a curve. $\endgroup$ – kglr Dec 18 '17 at 7:47
  • $\begingroup$ @klgr Unfortunately I can't think of any, at the moment, as I don't know the geometry of my problem (which is why I was looking for the plotting methods). I can imagine such situations geometrically though. I will try what you added as it seems very promising and tune back in if it shouldn't work. Thank you very much for the detailed mesh examples! $\endgroup$ – Banana Dec 18 '17 at 8:55
  • $\begingroup$ @LiftingBanana, my pleasure. Welcome to mma.se. $\endgroup$ – kglr Dec 18 '17 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.