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:

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

enter image description here

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.

  • 1
    $\begingroup$ Did you try ArcTan[Sqrt[#1^2 + #2^2], #3]? $\endgroup$
    – Coolwater
    Jun 18 '15 at 5:10
  • 2
    $\begingroup$ @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? $\endgroup$
    – J. M.'s torpor
    Jun 18 '15 at 8:33
  • $\begingroup$ @J.M. Sorry, I don't know if it's called "polar angle" but I mean the angle in the xy pane (Azimuth?). $\endgroup$
    – Ivan
    Jun 18 '15 at 16:07
  • $\begingroup$ @Coolwater sorry, I meant Azimuthal angle. $\endgroup$
    – Ivan
    Jun 18 '15 at 16:12
  • 5
    $\begingroup$ 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. $\endgroup$
    – 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:

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

    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}

static example of output


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.