1
$\begingroup$

I am trying to generate a polar plot within a ParametricPlot.

I have a region of interest that is rectangular and I want to plot in angular space to be consistent with how my lab measurements are displayed (a polar plot with $r = \theta$ and the $azimuth = \phi$, restricted to only $\theta <90$).

The closest I have come to doing this is to convert theta,phi to x,y and plot in Cartesian but I haven't been able to limit the r value such that the plot is restricted to theta instead of the rectangular x,y limits.

First define a plane of interest that includes $(0,0,0)$

tilt = 6 Degree;
rotation = 0 Degree;
nxplane = Sin[tilt]*Sin[rotation];
nyplane = Sin[tilt]*Cos[rotation];
nzplane = Cos[tilt];
planehat = {nxplane, nyplane, nzplane};

Then define a region of interest

z = -4;
nx0 = x/Sqrt[x^2 + y^2 + z^2];
ny0 = y/Sqrt[x^2 + y^2 + z^2];
nz0 = z/Sqrt[x^2 + y^2 + z^2];
roihat = {nx0, ny0, nz0};

Find the angle wrt z-axis (theta) and in-plane rotational angle (phi)

zhat = {0, 0, 1};
zcrossplane = Cross[zhat, planehat];
zhatdotplanehat = Dot[zhat, planehat];
xhat = {Part[zcrossplane, 1]/Sqrt[(1 - zhatdotplanehat^2)], 
   Part[zcrossplane, 2]/Sqrt[(1 - zhatdotplanehat^2)], 
   Part[zcrossplane, 3]/Sqrt[(1 - zhatdotplanehat^2)]};
Part[1 - zhatdotplanehat^2];
planehatcrossxhat = Cross[planehat, xhat];
roihatdotxhat = Dot[roihat, xhat];
roihatdotplanehatcrossxhat = Dot[roihat, planehatcrossxhat];
theta = VectorAngle[roihat, planehat];
phi = ArcTan[roihatdotxhat, roihatdotplanehatcrossxhat];

Cartesian coordinates to plot

xplot = theta*Cos[phi];
yplot = theta*Sin[phi];

Plot results

ParametricPlot[{xplot, yplot}, {x, -100, 100}, {y, 10, 100}, 
 Frame -> True, Axes -> False, PlotRange -> {-Pi/2, Pi/2}, 
 Epilog -> 
  PolarPlot[Pi/2, {\[Theta], 0, 2 Pi}, PolarAxes -> Automatic, 
    PolarGridLines -> {Drop[Table[i, {i, 0, 2 Pi, Pi/4}], -1], {0, 
       Pi/6, Pi/3, Pi/2}}, PolarTicks -> {"Degrees", Automatic}][[1]]]

Ideally the values of $\theta > 90$ would not be plotted but I have not been able to find a way to limit the theta value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.