Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to plot a 3D graphic and I want to highlight the intersection between two graphics: a plane and a surface. I thought that Meshfunction->{#3&} was a good idea, but I realized that I can't change the position of the mesh!

This is my code:

a = 0.5;
J = -3.00;

U[x_,y_,a_] := -(1-a)/Sqrt[(x-a)^2+y^2] - a/Sqrt[(x+1-a)^2+y^2] - 0.5*(x^2+y^2);
t=Table[
  Show[
    Plot3D[2*U[x,y,a], {x,-1.5,1.5}, {y,-1.5,1.5},
           PlotRange -> {-2.7,-4.0}, Mesh -> 1, MeshFunctions -> {#3&}, 
           MeshStyle -> {Orange, Thick}, ClippingStyle->None,
           PlotStyle -> Directive[Gray], 
           AxesLabel -> {Style["x",Italic,20],Style["y",Italic,20],Style["J=2U(x,y,a)",Italic,20]}],
    Plot3D[J-t, {x,-1.5,1.5}, {y,-1.5,1.5}, 
           Mesh -> False, PlotStyle -> Directive[Green,Opacity[0.5]]],
    ImageSize->700], 
  {t, 0., .7, .2}]

Someone can help me please?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Is this what you want?

a = 0.5;
J = -3.00;

U[x_, y_, a_] := -((1 - a)/Sqrt[(x - a)^2 + y^2]) - 
   a/Sqrt[(x + 1 - a)^2 + y^2] - 0.5*(x^2 + y^2);
t = Table[
  Show[Plot3D[2*U[x, y, a], {x, -1.5, 1.5}, {y, -1.5, 1.5}, 
    PlotRange -> {-2.7, -4.0}, Mesh -> {{0}}, 
    MeshFunctions -> {(#3 - (J - t)) &}, MeshStyle -> {Orange, Thick},
     ClippingStyle -> None, PlotStyle -> Directive[Gray], 
    AxesLabel -> {Style["x", Italic, 20], Style["y", Italic, 20], 
      Style["J=2U(x,y,a)", Italic, 20]}], 
   Plot3D[J - t, {x, -1.5, 1.5}, {y, -1.5, 1.5}, Mesh -> False, 
    PlotStyle -> Directive[Green, Opacity[0.5]]], 
   ImageSize -> 700], {t, 0., .7, .2}]

enter image description here

You can have a look at Mesh and MeshFunction documentation, it's very helpful I think.

share|improve this answer
    
Thanks a lot this is what i need !!!! Very good answer ! Yes i see the MeshFunction documentation but i didn't understand how to modify the simple MeshFunction->{#3&} to a dynamic version that change the meshLevel. –  federico Apr 20 '13 at 2:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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