# MeshFunction at azimuthal angles for RegionPlot3D

Edit: I said "polar angle"... It should be "Azimuthal angle". Sorry.

I want to plot a mesh line at a certain azimuthal angle in RegionPlot3D. My goal is to show the intersection of a rotating vertical plane with the surface of RegionPlot3D.

I tried with ArcTan[#1,#2]& but it doesn't work as expected. See for example:

SeedRandom[100];
pts = RandomVariate[NormalDistribution[], {100, 3}];
RegionPlot3D[ConvexHullMesh[pts],
MeshFunctions -> {ArcTan[#1, #2] & }, Mesh -> {{-Pi/4}}, Axes -> True]

I just want the line at -Pi/4 (and also at 3Pi/4), but it shows another at Pi. Also this method, sometimes complains about ArcTan[0,0]. I tried with Arg[#1+#2*I]& but got the same result.

• Did you try ArcTan[Sqrt[#1^2 + #2^2], #3]? Jun 18 '15 at 5:10
• @Coolwater, that might work, but we'll need OP to clarify what he meant by "polar angle". Ivan: This is spherical coordinates we're discussing, yes? Jun 18 '15 at 8:33
• @J.M. Sorry, I don't know if it's called "polar angle" but I mean the angle in the xy pane (Azimuth?).
– Ivan
Jun 18 '15 at 16:07
• @Coolwater sorry, I meant Azimuthal angle.
– Ivan
Jun 18 '15 at 16:12
• Try using the equation of the azimuthal plane: MeshFunctions -> {Det[{{#1, #2}, {Cos[t], Sin[t]}}] &}, Mesh -> {{0}}, where t is the azimuthal angle you want.
– user484
Jun 20 '15 at 5:17

This serves to preserve @Rahul's excellent answer that was provided in a comment to the question. Rahul suggested to use the equation of the azimuthal plane directly: assuming that $t$ is the azimuthal angle you want to highlight, then:

MeshFunctions -> {Det[{{#1, #2}, {Cos[t], Sin[t]}}] &}, Mesh -> {{0}}

In context, this turns into the following:

SeedRandom[100];
pts = RandomVariate[NormalDistribution[], {100, 3}];

Manipulate[
RegionPlot3D[
ConvexHullMesh[pts],
MeshFunctions -> {Det[{{#1, #2}, {Cos[t], Sin[t]}}] &},
Mesh -> {{0}},
MeshStyle -> Directive[Thickness[0.01], Red],
PlotStyle -> Directive[Blue, Opacity[0.6]],
Axes -> True
],
{{t, Pi/3}, 0, Pi}
]