# Extraneous curve due to MeshFunctions

I was using MeshFunctions to get intersection of quadratic with plane, but am getting some unexpected curves, any idea how to get rid of them, or maybe a more elegant way to achieve this effect? genPlot[theta_] := (
plot1 =
Plot3D[3 x^2 + y^2, {x, -2, 2}, {y, -2, 2},
MeshFunctions -> {#3 &, If[#1 != 0, ArcTan[#1, #2], -1] &},
MeshStyle -> {Automatic, Thick},
Mesh -> {5, {theta, theta - Pi}}, Boxed -> False, Axes -> False,
RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 3],
PlotPoints -> 25];
point = 2 {Cos[theta], Sin[theta], 0};

plot2 =
Graphics3D[{Opacity[.5], EdgeForm[None],
Polygon[{-point, point,
point + {0, 0, 10}, -point + {0, 0, 10}}]}];
Show[plot1, plot2, SphericalRegion -> True]
);
genPlot[Pi/4]


edit Brett's solution below fixes it (notebook) MeshFunctions works by detecting where the function crosses your values, in this case where ArcTan becomes equal to theta. Unfortunately this is done numerically, checking sign changes, and so the branch cut along the negative $$y$$ axis is included. (It goes from $$-\pi$$ to $$\pi$$, so must have crossed theta somewhere in there, right?)

The cleanest solution I've found for removing it in your example is to rotate the branch cut to align along where you want to draw the mesh line by using Mod[ArcTan[#1, #2], 2 Pi, theta] for the mesh function:

genPlot[theta_] := (plot1 =
Plot3D[3 x^2 + y^2, {x, -2, 2}, {y, -2, 2},
MeshFunctions -> {#3 &, Mod[ArcTan[#1, #2], 2 Pi, theta] &},
MeshStyle -> {Automatic, Thick},
Mesh -> {5, {theta, theta + Pi}}, Boxed -> False, Axes -> False,
RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 3],
PlotPoints -> 25];
point = 2 {Cos[theta], Sin[theta], 0};
plot2 =
Graphics3D[{Opacity[.5], EdgeForm[None],
Polygon[{-point, point,
point + {0, 0, 10}, -point + {0, 0, 10}}]}];
Show[plot1, plot2, SphericalRegion -> True]);
genPlot[Pi/4] • Thanks! BTW, any tips how to get rid of that artifact on the left edge of the bowl? (right above the bold curve) Sep 10, 2021 at 22:53
• This gets rid of that artifact: Plot3D[3 x^2 + y^2, {x, y} \[Element] BoundaryDiscretizeRegion[Disk[{0, 0}, Sqrt], AccuracyGoal -> 5], opts], where opts omits the RegionFunction option. Note that the call to BoundaryDiscretizeRegion is not necessary, but I added it to make the boundary smoother. Sep 11, 2021 at 13:58
• @chip thanks! Curious, how did you come up with this idea? Sep 11, 2021 at 15:37
• Just happened to know the syntax. It would be nice if the boundary by default was just as smooth as what we get with RegionFunction. Sep 11, 2021 at 22:02