0
|
22280 Views
|
15 Replies
|
0 Total Likes
View groups...
Share

# Plots in cylindrical coordinates

Posted 9 years ago
 It's a learning curve .... I want to plot simultaneous functions using cylindrical coords, like ContourPlot3D[ r^2 + z^2 - 1 == 0, {r, -5, 5}, {\[Phi] , 0, 2 \[Pi] }, {z, -1, 1}]  looks weird, thinks its still in Cartesian, tried to change to cylindrical without much luck. The real objective is ContourPlot3D[{r^2 + z^2 - 1 == 0}, {r = Sin[\[Phi]]}, {r, -5, 5}, {\[Phi], 0, 2 \[Pi]}, {z, -3, 3}]  Would appreciate the help, thanks.
15 Replies
Sort By:
Posted 9 years ago
 Perhaps something along these lines: With[{r = Sqrt[x^2 + y^2], \[Phi] = ArcTan[x, y]}, Show[ContourPlot3D[ Evaluate[{r^2 + z^2 - 1 == 0, r == Simplify[Sin[\[Phi]]]}], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, ContourStyle -> Opacity[0.3], AxesLabel -> {"x-axis", "y-axis", "z-axis"}, MeshFunctions -> {}, LabelStyle -> Directive[Bold, Medium, Red]], VectorPlot3D[{Grad[r^2 + z^2 - 1, {x, y, z}], Grad[r - Simplify@Sin[\[Phi]], {x, y, z}]}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]]] 
Posted 9 years ago
 Awesome. Sorry if I'm being a nuisance, but do you perhaps know how to add the gradient for each function to this plot?I tried With[{r = Sqrt[x^2 + y^2], [Phi] = ArcTan[x, y]}, ContourPlot3D[{r^2 + z^2 - 1 == 0, r == Sin[[Phi]]}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Grad[{r^2 + z^2 - 1 == 0, r == Sin[[Phi]]}, {x, -1, 1}, {y, -1, 1}], ContourStyle -> Opacity[0.3], AxesLabel -> {"x-axis", "y-axis", "z-axis"}, MeshFunctions -> {}, LabelStyle -> Directive[Bold, Medium, Red]]]ie just adding in the grad function with it's mandatory options ... but I think it swore at me :-)
Posted 9 years ago
 That worked very nicely, thank you. I also added axes - makes it easy to keep track when rotating the image....I also wanted Opacity, but despite being in the documentation, the following failed : With[{r = Sqrt[x^2 + y^2], \[Phi] = ArcTan[x, y]}, ContourPlot3D[{r^2 + z^2 - 1 == 0, r == Sin[\[Phi]]}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, PlotStyle -> Opacity[0.5], AxesLabel -> {"x-axis", "y-axis", "z-axis"}, LabelStyle -> Directive[Bold, Medium, Red]]] 'Unknown option name has been used" - any idas how to make the functions partly opaque? Thanks
Posted 9 years ago
 ContourStyle instead of PlotStyle...should work...
Posted 9 years ago
 Thanks Sander, that is nice. ( Delay because I had lots of hassles upgrading to win 10, eventually had to rebuild my PC)Is there a command to Plot this without the contour lines? I tried replacing with GraphPlot3D but this wont accept some of the options ....
Posted 9 years ago
 add MeshFunctions -> {} as an option.
Posted 9 years ago
 Nice work, but you can try something along these lines: With[{r = Sqrt[x^2 + y^2], \[Phi] = ArcTan[x, y]}, ContourPlot3D[{r^2 + z^2 - 1 == 0, r == Sin[\[Phi]]}, {x, -1, 1}, {y, -1, 1}, {z, -3, 3}]] 
Posted 9 years ago
 Does that just tell me what substitutions to make, or should it allow me to use cylindrical cords directly? Didn't seem to, so I tried ContourPlot3D[ x^2 + y^2 + z^2 - 1 == 0, {x, -2, 2}, {y, -2, 2 }, {z, -1, 1}] but this is not a cylinder ...
Posted 9 years ago
 Hi - one of the 2 eqtns I want to plot is {r = Sin[[Phi]]} But for coords - it's more that the other function I wish to plot simultaneously is a cylinder. So is the conclusion I would have to convert any cylindrical functions into Cartesian to plot them?
Posted 9 years ago
 You can easily from and to coordinate using: Thread[{r, \[Theta], z} -> CoordinateTransformData["Cartesian" -> "Cylindrical", "Mapping", {x, y, z}]] 
Posted 9 years ago
 You want to plot a sphere using cylindrical co-ordinates? $x= r\cos(\phi), y=r \sin(\phi), z = z$, so $x^2+y^2=r^2$ and your equation defines a sphere circle in the plane at height $z$. If that really must be done, then $r$ grows from 0 (at $z=-1$) to 1 (at z = 0) and decreases back to 0 (at $z=1$) and of course this is given by $r=\sqrt(1-z^2)$. So one types (because ParametricPlot3D[] draws into an euclidean orthonormal co-ordiante system) just ParametricPlot3D[{Sqrt[1 - z^2] Cos[\[Phi]], Sqrt[1 - z^2] Sin[\[Phi]], z}, {z, -1, 1}, {\[Phi], 0, 2 \[Pi]}] to see as expected
Posted 9 years ago
 I think the syntax is wrong , I do not know you're trying to get , but I did this and got the following
Posted 9 years ago
 That's more complicated than I expected. Surely Mathematica can directly use cylindrical (or polar) cords? The documentation says to use SetCoordinates[Cylindrical] - but I don't get the expected output from that, which should be Cylindrical[Rr, Ttheta, Zz] - and we should in theory then be able to directly do what I want ...But I tried the above, then ContourPlot3D[ Rr^2 + Zz^2 - 1 == 0, {Rr, -5, 5}, {Ttheta, 0, 2 [Pi]}, {Zz, -1, 1}] - and got the same warped 'thing'. Is there a bug with SetCoordinates perhaps?
Posted 9 years ago
 SetCoordinates will not affect plotting, only some vector analysis functions., and the SetCoordinates-function is now kinda deprecated because all the vector analysis functionality is now built-in to the core.
Posted 9 years ago
 I'm not sure what you're trying to do there but I'd guess that if you have in mind a discrete range of values for Phi eg phi = {0,Pi/6,Pi/4,Pi/3,Pi/2,Pi,2Pi/3,3Pi/4,5Pi/6,Pi,7Pi/6,5Pi/4,4Pi/3,2Pi} then you'd probably be able to apply appropriate transformations to the bounds of the variables inside ContourPlot What I have in mind is something like rLoBound[x_,phi_]:=(appropriate calcs) rHiBound[x_,phi_]:=(appropriate calcs) zLoBound[x_,phi_]:=(appropriate calcs) zHiBound[x_,phi_]:=(appropriate calcs) ContourPlot3D[{r^2 + z^2 - 1 == 0}, {r, rLoBound[-5,#], rHiBound[5,#]}, {z, zLoBound[-3,#], zHiBound[3,#]}]&/@phi