2
$\begingroup$

This question already has an answer here:

Edit: This question has very useful answers, but none address how to work with spherical coordinates.


I want to plot a 2D disk in 3D space, angled perpendicular to a given direction. That direction is given by $\theta$ and $\phi$ in spherical coordinates (where $\theta$ is polar and $\phi$ is azimuthal cause I'm a physicist, sorry math people!).

Here's four approaches I've tried that nearly work but not quite:

  1. ContourPlot3D in cartesian coordinates

    ContourPlot3D[{x + y + z == 1}, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]
    

    This gives an inclined plane, but I can't figure out how to put it at the desired angles $\theta$ and $\phi$. I also wouldn't know how to make this a disk with a finite radius.

    enter image description here

  2. ContourPlot3D in spherical coordinates, by converting x+y+z==1 into spherical

    ContourPlot3D[{r*Sin[θ]*Cos[ϕ] + r*Sin[θ]*Sin[ϕ] 
         + r*Cos[θ] == 1},
    {r, 0, 1}, {θ, 0, Pi}, {ϕ, 0, 2*Pi}, AxesLabel -> Automatic]
    

    This uses {r,$\theta$,$\phi$} as the plot coordinates, rather than plotting in proper cartesian space.

    enter image description here

  3. ParametricPlot3D to make a disk, then rotate it

    ParametricPlot3D[{r*Sin[Pi/2]*Cos[ϕ],r*Sin[Pi/2]*Sin[ϕ], r*Cos[Pi/2]},
      {r, 0, 1}, {ϕ, 0, 2*Pi}, 
     PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, AxesLabel -> {x, y, z}]
    

    This can produce a disk, but I can't figure out how to angle it. Here I set $\theta$=$\pi$/2 to make the disk.

    enter image description here

  4. Use Disk with Graphics3D and Rotate

    This would work if Disk could be used as a 3D object! Argh!


That's all my ideas. If you see how to fix one of these, or have another, better idea, please advise!

$\endgroup$

marked as duplicate by José Antonio Díaz Navas, Coolwater, Henrik Schumacher, LCarvalho, MarcoB Mar 2 '18 at 3:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$

First, define the normal in spherical coordinates:

n[theta_, phi_] := {Sin[theta]*Cos[phi], Sin[theta]*Sin[phi], Cos[theta]}

Then multiply your (syntax-corrected) ParametricPlot3D with RotationMatrix and wrap it in Manipulate:

Manipulate[
  Show[
     ParametricPlot3D[
       RotationMatrix[{{0, 0, 1}, n[theta, phi]}].  
         {r*Sin[Pi/2]*Cos[Phi], r*Sin[Pi/2] Sin[Phi], r*Cos[Pi/2]}
         , {r, 0, 1}, {Phi, 0, 2*Pi}
         , PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}
         , AxesLabel -> {x, y, z}]
      , Graphics3D[{Red, Arrow[{{0, 0, 0}, n[theta, phi]}]}]]
  , {theta, 0, 2 Pi}, {phi, 0, Pi}]

enter image description here

$\endgroup$
  • $\begingroup$ This is beautiful, thank you. RotationMatrix was the missing piece to my idea #3 above. Small note: typically theta goes 0->Pi and phi goes 0->2Pi. $\endgroup$ – Max Feb 17 '18 at 0:04
3
$\begingroup$

Given the normal vector

n={Cos[\[Theta]] Cos[\[CurlyPhi]], Cos[\[Theta]] Sin[\[CurlyPhi]],Sin[\[Theta]]}

the plane orthogonal to n is given by

e={Sin[\[CurlyPhi]], -Cos[\[CurlyPhi]], 0}
f={-Cos[\[CurlyPhi]] Sin[\[Theta]], -Sin[\[Theta]] Sin[\[CurlyPhi]],Cos[\[Theta]]}

The 3D-disk can be plotted using

Block[{\[Theta] = 50 \[Degree], \[CurlyPhi] = 10 \[Degree] },
Show[{Graphics3D[{Point[{0, 0, 0}], Opacity[.2], Sphere[]}], 
ParametricPlot3D [r (Cos[t] e + Sin[t] f), {r, 0, 1}, {t, 0, 2 Pi}]}, Boxed-> False]
]

enter image description here

$\endgroup$
  • $\begingroup$ Nothing wrong with you answer, but @anderstood built upon one of my solutions which made it easier for me to work with. Small feedback: aren't your n and e defined the same? $\endgroup$ – Max Feb 17 '18 at 0:10
  • $\begingroup$ Sorry, cut &paste error: I edited my answer. $\endgroup$ – Ulrich Neumann Feb 17 '18 at 14:00
  • $\begingroup$ ... n!=e: By the way I didn't agree, that using a RotationMatrix is easier than the evaluation of two orthogonal vectors... $\endgroup$ – Ulrich Neumann Feb 17 '18 at 14:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.