1

My problem is that I would like to create a surface by rotating the function ![enter image description here in the range -10 < z < 0 around the z axis to create a kind of pouch-shaped surface.

enter image description here

I've been doing research and this solution would be ideal, apart from the fact that my function is cartesian and not parametric. A trawl of the pgfplots manual has not yielded anything helpful in this respect.

My question is are there any ways to rotate a cartesian rather than polar or parametric equation around an axis, as my function is a bit of a pain to turn into a parametric. If anyone could suggest a parametric function that looks about the same, that would also be great!

Any and all help would be appreciated

3

As I understand it, we have a function

f(\z) = \z-pow(\z,3)-2

and two parameters, one for the rotation angle with the range [0,360] (call it x in pgfplots terms) and one for the value of \z with the range [-10,0] (call it y in pgfplots terms). The three coordinates of the plot are the coordinates of a circle in the x-y-plane with radius f(y) centred around the z-axis and y as the z-component, i.e.,

( {f(y)*sin(x)}, {f(y)*cos(x)}, y )

enter image description here

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}%
  [declare function={ f(\z) = \z-pow(\z,3)-2; }
  ]
  \begin{axis}
    \addplot3 [
        surf,
        domain    = 0:360,
        y domain  = -10:0,
        samples   = 50,
        samples y = 20,
      ]
      ( {f(y)*sin(x)}, {f(y)*cos(x)}, y );
  \end{axis}
\end{tikzpicture}  
\end{document}
  • that is almost what I'm looking for, but with the graph plotted with respect to different axis. Sorry for any confusion, I've edited the question to make this more clear (I hope) – Utumno Feb 10 '17 at 8:28
  • @Utumno Second try; I think that the plot now shows what you want. – gernot Feb 10 '17 at 9:42
  • Thanks, that worked! This is my first encounter with 3d parametrics, your answer helped me understand a lot more – Utumno Feb 10 '17 at 10:15

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.