# Plot the intersection of a plane with the volume of a function

I have the following function:

r1[x_, y_] := 25.029205084016887* E^(0.07848246*-68.66347844300994 - 0.005271437722209233*(53.03569084 + -68.66347844300994 + 6.37084885* Log[(6.768705880738582 - x)^2 + (1.2337283006959585 - y)^2])^2);


and three points that define a plane:

A := {4.514129804574033, -1.323657939915483, 0};
B := {4.514129804574033, -1.323657939915483, 20000};
C1 := {6.768705880738582, 1.2337283006959585, 0};


I want to plot only the intersection between the plane and the volume of this function (above the plane of XY origin). For example, the slice* below the red intersection curve that you see in the following picture:

*A slice looking something like that:

I thought it would be very easy but after a full day of failing.. I decided to reach here for help!

Note your plane is perpendicular to the x/y plane. Therefore, the y value only depends on x. We can define a function y[x] by requesting that the line goes through A and C1:

eq = {A[[1]] cx + c0 == A[[2]], C1[[1]] cx + c0 == C1[[2]]};
y[x_] = cx x + c0 /. Solve[eq, {cx, c0}][[1]]


We may now plot the surface of r1 and combine it with a plot of the parametrized line: {x,y[x],r1[x,y[x]]}:

Show[{Plot3D[r1[x, y], {x, -20, 20}, {y, -20, 20}, PlotPoints -> 50],
ParametricPlot3D[{x, y[x], r1[x, y[x]]}, {x, -20, 20},PlotStyle -> Red]
}]


You may use ImplicitPlot but you have to scale r1 as this is not done automatically:

Region[ImplicitRegion[{0 <= z <= 100 r1[x, y] &&
y == fy[x] && -20 < x < 20 && -20 < y < 20}, {x, y, z}],
Axes -> True, Boxed -> True]


• Thank you, to have a line there (instead of what I had managed to have is nice), yet what I wanted was to plot the intersection area of the plane with the volume of that function. So r1 would be gone and only a slice (not only the red curve) of that would be visible.
– Gouz
Oct 6, 2021 at 23:17
• @Gouz I added the intersection area, but note you need to scale the plot by hand. Oct 7, 2021 at 8:39

One possible method.

section =
ContourPlot3D[({x, y, z} - B) . Cross[A - B, C1 - B] == 0, {x, -20,
20}, {y, -20, 20}, {z, -.1, .2},
RegionFunction -> Function[{x, y, z}, 0 <= z <= r1[x, y]],
PlotPoints -> 80, ContourStyle -> Blue, Mesh -> None,
RegionBoundaryStyle -> Directive[Opacity[.2], Yellow],
BoundaryStyle -> Directive[Thick, Red], Boxed -> False]


Another way maybe as below.

reg = RegionIntersection[InfinitePlane[{A, B, C1}],
ImplicitRegion[
z <= r1[x, y], {{x, -20, 20}, {y, -20, 20}, {z, -.1, .2}}]];
dreg = DiscretizeRegion[reg, BoxRatios -> 1, PlotRange -> All,
BaseStyle -> Red]