I am trying to plot a cut on a surface. The idea is to show half of the surface with low opacity, and the other one with full opacity. Using ClipPlanes I cannot make it to work, since it seem to affect the whole Show command rather than only the Plot3D in which is contained. I assumed that by plotting 2 times the same function, one with ClipPlanes and a second time without will do the trick but I was wrong.

Pl=InfinitePlane[{{0, 1, 0},{0,0,1}, {0, 0, 0}}];
Show[Plot3D[-Log[x^2+y^2],{x,-4,4},{y,-4,6},ClipPlanes->Pl,PlotRange->All, ClipPlanesStyle -> Opacity[0.3]],Plot3D[-Log[x^2+y^2],{x,-4,4},{y,-4,6},ClipPlanes->Pl,PlotRange->All,PlotStyle->Opacity[0.4]]]


The idea later is to be able to use Manipulate to visualize any cut of a surface by changing the plane. Also, coloring the curve over the surface will be neat.

Thanks.

Edit

We can use two ClipPlanes.

Here we avoid use Show since Show will use the options of the first plot to the others,that is why we can not cut the two plots in two different way.

normal = {1, 1, 1};
ani = Manipulate[
Graphics3D[{{ClipPlanes -> Flatten@{normal, t},
ClipPlanesStyle -> Opacity[0.3],
Plot3D[-Log[x^2 + y^2], {x, -4, 4}, {y, -4, 6}, PlotRange -> All,
PlotStyle -> Green,
PerformanceGoal -> "Quality"][[1]]}, {ClipPlanes ->
Flatten@{-normal, -t},
Plot3D[-Log[x^2 + y^2], {x, -4, 4}, {y, -4, 6}, PlotRange -> All,
PlotStyle -> Opacity[.3],
PerformanceGoal -> "Quality"][[1]]}}, Axes -> True], {t, -3,
3}]


Original

Use the form a*x+b*y+c*z+d<=0 where {a,b,c} is the normal of plane.

Manipulate[
Plot3D[-Log[x^2 + y^2], {x, -4, 4}, {y, -4, 6},
ClipPlanes -> {{1, 0, 0, t}}, PlotRange -> All,
ClipPlanesStyle -> Opacity[0.3], PerformanceGoal -> "Quality"], {t,
0, 2}]


Or maybe

normal = {1, 1, 1};
ani = Manipulate[
Show[Plot3D[-Log[x^2 + y^2], {x, -4, 4}, {y, -4, 6},
MeshFunctions -> Function[{x, y, z}, normal . {x, y, z}],
Mesh -> {{t}}, MeshStyle -> Directive[Thick, Red],
MeshShading -> {Opacity[.5], Green}, PlotRange -> All,
ClipPlanesStyle -> Opacity[0.3], PerformanceGoal -> "Quality"],
Graphics3D[{Opacity[.5], Gray, Hyperplane[normal, t]}]], {t, -4, 4}]


• Thanks, but a problem with your answer is that if you tilt the plane then does not work. Hyperplane[{1,1, 0}, -t]
– root
Commented Jan 31, 2022 at 6:11
• @root Set the normal of plane. Commented Jan 31, 2022 at 6:29

Use ConditionalExpression to specify the separate regions

Manipulate[
Show[
Plot3D[{
ConditionalExpression[-Log[x^2 + y^2], x >= -t],
ConditionalExpression[-Log[x^2 + y^2], x < -t]},
{x, -4, 4}, {y, -4, 6},
PlotStyle -> {Automatic,
Opacity[op, ColorData[97][2]]},
PlotRange -> {{-4, 4}, {-4, 6}, {-4, 6}},
PerformanceGoal -> "Quality"],
Graphics3D[{Opacity[0.5],
Hyperplane[{1, 0, 0}, -t]}]],
{{op, 0.5, opacity}, 0, 1, 0.05, Appearance -> "Labeled"},
{{t, 1}, -4, 4, 0.01, Appearance -> "Labeled"}]


• Thanks, but a problem with your answer is that if you tilt the plane then does not work. Hyperplane[{1,1, 0}, -t]
– root
Commented Jan 31, 2022 at 4:56

If we use ClipPlanes as a directive in PlotStyle (as opposed to using it as an option) and have two copies of the input function in the first argument of Plot3D we can get the desired result using a single Plot3D:

clipplanes = {1, 1, 1, -3/2};

Plot3D[{-Log[x^2 + y^2], -Log[x^2 + y^2]}, {x, -4, 4}, {y, -4, 6},
PlotStyle -> {Directive[ClipPlanes -> clipplanes],
Directive[Opacity[0.4, Green], ClipPlanes -> - clipplanes]},
PlotRange -> All,
PlotLabel -> ClipPlanes -> InputForm @ clipplanes,
BoxRatios -> 1,
ImageSize -> 500]


With a helper function to flip the clipping side we can use ClipPlanes -> {a,b,c,d} or ClipPlanes -> InfinitePlane[...] to specify clip planes:

ClearAll[flipSide]
flipSide[{a_?NumericQ, b_, c_, d_}] := -{a, b, c, d};
flipSide[ip_InfinitePlane] := SubsetMap[Reverse, ip, {{1, 1}, {1, 2}}];


Examples:

clipplanes = {1, 1, 1, -3/2};

Show[Plot3D[{-Log[x^2 + y^2], -Log[x^2 + y^2]}, {x, -4, 4}, {y, -4, 6},
PlotStyle -> {Directive[ClipPlanes -> clipplanes ],
Directive[Opacity[0.4, Green], ClipPlanes -> flipSide[clipplanes ]]},
PlotRange -> All,
PlotLabel -> ClipPlanes -> InputForm @ clipplanes ,
BoxRatios -> 1,
ImageSize -> 500],
Graphics3D[{EdgeForm[], Opacity[.5, Gray],
clipplanes /. {a_, b_, c_, d_?NumericQ} :> Hyperplane[{a, b, c}, -d]}]]


Replace clipplanes above with

clipplanes2 = InfinitePlane[{{0, 1.5, 0}, {0, 0, 1}, {1, 0, 0}}];


to get

frames = Table[With[{cp = {1, 1, 1, -w}},
Show[Plot3D[{-Log[x^2 + y^2], -Log[x^2 + y^2]}, {x, -4, 4}, {y, -4, 6},
PlotStyle -> {Directive[ClipPlanes -> cp],
Directive[Opacity[0.4, Green], ClipPlanes -> -cp]},
PlotRange -> {{-4, 4}, {-4, 6}, {-5, 5}},
BoxRatios -> 1, ImageSize -> 450],
Graphics3D[{EdgeForm[], Opacity[.5, Gray],
Hyperplane[{1, 1, 1}, w]}]]], {w, -10, 6, 1/4}];

Export["clipplanesanimation.gif", frames, AnimationRepetitions -> ∞]