6
$\begingroup$

I would like to show the intersection between the plane $2x-y-2=0$ and the surface $z=\sqrt{4-x^{2}-y^{2}}$.

This is what I tried:

Show[Plot3D[Sqrt[4 - x^2 - y^2], {x, 0, 2}, {y, 0, 2}, 
  PlotStyle -> Opacity[0.4], Mesh -> None, 
  PlotStyle -> Thickness[0.02], AxesStyle -> Thick, Boxed -> False, 
  AxesOrigin -> {0, 0, 0}, AxesLabel -> {x, y, z}], 
 Graphics3D[{Blue, PointSize[0.01], 
   Sphere[{1.5, 1, Sqrt[4 - 1.5^2 - 1]}, 0.03]}], 
 Graphics3D[Text["2x-y-2=0", {1.7, 1.7, 1.7}]], 
 ContourPlot3D[{z - Sqrt[4 - x^2 - y^2] == 0, 2*x - y - 2 == 0}, {x, 
   0, 2}, {y, 0, 2}, {z, 0, 2}, PlotPoints -> 10, 
  MeshFunctions -> {Function[{x, y, z, 
      f}, (z - Sqrt[4 - x^2 - y^2]) - (2*x - y - 2)]}, 
  MeshStyle -> {{Thick, Green}}, Mesh -> {{0}}, 
  ContourStyle -> 
   Directive[Orange, Opacity[0.1], Specularity[White, 30]]], 
 BoxRatios -> {1, 1, 1}]

As you can see the green curve having the unwanted part. How can I remove this part? If I increase PlotPoints to 60 then I took so long to run and still gave the zig-zag part.

enter image description here

$\endgroup$
9
$\begingroup$

1

You can use the option BoundaryStyle instead of MeshFunctions and Mesh in ContourPlot3D:

cp1 = ContourPlot3D[{z - Sqrt[4 - x^2 - y^2] == 0, 2*x - y - 2 == 0}, 
  {x, 0, 2}, {y, 0, 2}, {z, 0, 2}, 
  Mesh -> None, 
  ContourStyle -> Directive[Orange, Opacity[0.1], Specularity[White, 30]], 
  BoundaryStyle -> {{1, 2} -> Directive[Green, Thick]}];

Show[Plot3D[Sqrt[4 - x^2 - y^2], {x, 0, 2}, {y, 0, 2}, 
  PlotStyle -> Opacity[0.4], Mesh -> None, 
  PlotStyle -> Thickness[0.02], AxesStyle -> Thick, Boxed -> False, 
  AxesOrigin -> {0, 0, 0}, AxesLabel -> {x, y, z}], 
 Graphics3D[{Blue, PointSize[0.01], Sphere[{1.5, 1, Sqrt[4 - 1.5^2 - 1]}, 0.03]}], 
 Graphics3D[Text["2x-y-2=0", {1.7, 1.7, 1.7}]],
 cp1, 
 BoxRatios -> {1, 1, 1}]

enter image description here

2

Alternatively, generate the two contour surfaces separately and use the options MeshFunctions + Mesh in the first ContourPlot3D:

cp1a = ContourPlot3D[z - Sqrt[4 - x^2 - y^2] == 0, 
   {x, 0, 2}, {y, 0, 2}, {z, 0, 2}, 
   MeshFunctions -> {2 # - #2 - 2 &}, Mesh -> {{0}}, 
   MeshStyle -> Directive[Green, Thick], 
   ContourStyle -> Directive[Orange, Opacity[0.1], Specularity[White, 30]]];

cp1b = ContourPlot3D[2*x - y - 2 == 0, 
   {x, 0, 2}, {y, 0, 2}, {z, 0, 2}, 
   Mesh -> None, 
   ContourStyle -> Directive[Orange, Opacity[0.1], Specularity[White, 30]]];

Show[Plot3D[Sqrt[4 - x^2 - y^2], {x, 0, 2}, {y, 0, 2}, 
  PlotStyle -> Opacity[0.4], Mesh -> None, 
  PlotStyle -> Thickness[0.02], AxesStyle -> Thick, Boxed -> False, 
  AxesOrigin -> {0, 0, 0}, AxesLabel -> {x, y, z}], 
 Graphics3D[{Blue, PointSize[0.01], 
   Sphere[{1.5, 1, Sqrt[4 - 1.5^2 - 1]}, 0.03]}], 
 Graphics3D[Text["2x-y-2=0", {1.7, 1.7, 1.7}]], 
 cp1a, 
 cp1b, 
 BoxRatios -> {1, 1, 1}]

enter image description here

3

Yet another approach is to use Mesh -> None in contour plots and generate the green line using MeshFunctions in Plot3D:

Show[Plot3D[Sqrt[4 - x^2 - y^2], {x, 0, 2}, {y, 0, 2}, 
  PlotStyle -> Opacity[0.4],
  MeshFunctions -> {2 # - #2 - 2 &}, 
  Mesh -> {{0}}, 
  MeshStyle -> Directive[Green, Thick], 
  PlotStyle -> Thickness[0.02], AxesStyle -> Thick, Boxed -> False, 
  AxesOrigin -> {0, 0, 0}, AxesLabel -> {x, y, z}], 
 Graphics3D[{Blue, PointSize[0.01], Sphere[{1.5, 1, Sqrt[4 - 1.5^2 - 1]}, 0.03]}], 
 Graphics3D[Text["2x-y-2=0", {1.7, 1.7, 1.7}]], 
 ContourPlot3D[{z - Sqrt[4 - x^2 - y^2] == 0, 2*x - y - 2 == 0},
  {x, 0, 2}, {y, 0, 2}, {z, 0, 2}, 
  Mesh -> None, ContourStyle -> Directive[Orange, Opacity[0.1], Specularity[White, 30]]], 
 BoxRatios -> {1, 1, 1}]

enter image description here

$\endgroup$

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.