3
$\begingroup$

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?

$\endgroup$

1 Answer 1

3
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – federico
    Apr 20, 2013 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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