Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any built-in functionality in TiKz/PGF that allows for drawing quadric surfaces, i.e. surfaces given by the equation

Ax^2 + By^2 + Cz^2 + Dz = E?

I'm aware of the raw gnuplot command enabling the use of virtually every gnuplot command (at least to my knowledge).

I tried using the following command:

\begin{tikzpicture}  
\draw[thick] plot[raw gnuplot] function{set urange [0:2*pi]; set vrange [0:pi]; set parametric; set isosample 40; splot cos(u)*sin(v)/3, sin(u)*sin(v), cos(v)};  
\end{tikzpicture}

but the result is less than satisfactory.

share|improve this question
    
welcome to TeX and friends! I hope you enjoy your stay here. Use four spaces inthe begining of a line (or select and click the 10101 button) to create a "code" section and please note that as your badge appears at the end of your entry, there's no need to sign-off. –  Yossi Farjoun Jan 25 '11 at 11:41
    
Thank you for the pointers. –  Marius Jan 25 '11 at 11:44
add comment

2 Answers

up vote 8 down vote accepted

You might be interessted in PGFplots (see: pgfplots.sf.net)

  \begin{tikzpicture}
    \begin{axis}[
         3d box=background,
      % pretty printing, but irrelevant:
   title={3d box=background},
   samples=5,
   domain=-4:4,
   xtick=-4:4,
   ytick=-4:4,
  ]
  \addplot3[surf] {1*x*y};
 \end{axis}
\end{tikzpicture}

In the official documentation of PGFplots, therer's are some options mentioned about parametric ploting:

  • /pgfplots/parametric
  • /pgfplots/parametric/var 1d
  • /pgfplots/parametric/var 2d

With PGFplots you can use GNUplot aswell:

\begin{tikzpicture}
  \begin{axis}
    \addplot3 gnuplot[raw gnuplot] {set parametric;splot[t=0:6*pi] cos(t),sin(t),t/2*pi};
  \end{axis}
\end{tikzpicture}
share|improve this answer
    
Thank you. Looks very nice indeed. –  Marius Jan 25 '11 at 12:17
add comment

with pst-solides3d which allows hidden surfaces. Here is only the code for the first example. Can be run with xelatex if you need a pdf output

\documentclass{minimal}
\usepackage{pst-solides3d,pgfplots}

\begin{document}

\psset{viewpoint=30 90 0 rtp2xyz,lightsrc=viewpoint,Decran=90}
\begin{pspicture}(-3,-3)(3,3)
\defFunction[algebraic]{Func}(u,v){cos(u)*sin(v)/3}{sin(u)*sin(v)}{cos(v)}
\psSolid[object=surfaceparametree,
  base=0 pi dup add 0 pi,
  function=Func,linewidth=0.5\pslinewidth,ngrid=25]
\end{pspicture}

\end{document}

share|improve this answer
    
Thanks. I'll check it out. –  Marius Jan 25 '11 at 12:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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