I’m trying to create a 3D plot in cyclindrical coordiates using ParametricPlot3d.
I’d just like to know if I’m getting it right. Can someone check to see if this looks right?
The function in cylindrical coordinates is z = (1-2r) * Sin[t] / r^2, where r is the radius, t is the polar angle theta, and z is the z coordinate.
(Edit): I know the rsin[t] and rcos[t] in the x and y arguments of the plot look reversed, but this plot actually represents a vertical cross section through the center of a sphere with charge density given by z. The r and t variables are the radius and polar angle in spherical coordinates of the spherical charge density, but here that vertical cross section has been rotated to be located in the horizontal x-y plane of the plot.
It is correct, but the choice of parameters makes it misleading as to the behaviour of the function. I would do it like this:
ParametricPlot3D[{r*Cos[t], r*Sin[t], (1 - 2 r)*Sin[t]/r^2},
{r, 0, 3}, {t, 0, 2 Pi},
PlotRange -> {3 {-1, 1}, 3 {-1, 1}, 3/2 {-1, 1}},
BoxRatios -> 1]
You’re right, your way of doing it does show a lot more features. The problem I was solving included a constant R term as a value of r, and since I can’t plot a function with an undefined constant, I just set R=1. Since the function in the problem doesn’t extend past R, I just decided not to plot past r=R=1. I like what you did with the PlotRange, though, so I’ll keep that in mind going forward.
Fixed some stuff. Due to the t variable being a polar angle in spherical coordinates, I’ve changed the range to only {t,0,Pi}.