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.

I'm trying to draw a graph with pst-solides3D with the option psSurface :

The problem is as follows :

I want to draw z = +/- (y^2-y^2), which should give a saddle-point graph with the lines x=y and x=-y that are equal to 0. Visually it's nice.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}

\usepackage[english]{babel} %change language if necessary
\usepackage[english,verbose]{layout}%change language if necessary
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xspace}
\usepackage{pstricks}
\usepackage{pst-solides3d}
\usepackage{epstopdf}

\psset{unit=0.35} 
\psset{lightsrc=30 -10 10} 
\psset{viewpoint=50 20 30 rtp2xyz,Decran=70} 
\begin{pspicture}(-11,-8)(7,8) 
%+ Saddle graph z= (y^2-x^2)
\psSurface[ngrid=.2 .2,algebraic,Zmin=-1,Zmax=1, 
linewidth=0.5\pslinewidth,spotX=r,spotY=d, 
spotZ=l, 
hue=0 1](-5,-5)(5,5){% 
(x^2-y^2)/3 } 
%- Saddle graph z = (x^2-y^2)
\psSurface[ngrid=.2 .2,algebraic,Zmin=-1,Zmax=1, 
linewidth=0.5\pslinewidth,spotX=r,spotY=d, 
spotZ=l,
hue=0 1](-5,-5)(5,5){% 
(-x^2+y^2)/3 } 
\end{pspicture} 

However as you can see this is not satisfactory. The second plot is plotted over the first one, and covers parts of the first graph it shouldn't cover. Is there any transparency command I could use, or make pstricks understand what is in front of what ?

The rendering I'm looking for would be something like this

enter image description here

It knows what should be in front and what should not.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

It makes no sense to draw more than one 3d function without using hidden lines and surfaces.

\documentclass{article}
\usepackage{pst-solides3d}

\begin{document}
\psset{unit=0.35,lightsrc=30 -10 10,viewpoint=50 20 30 rtp2xyz,Decran=70,solidmemory} 
\begin{pspicture}(-11,-8)(7,8) 
\defFunction[algebraic]{F1}(x,y){}{}{ (x^2-y^2)/3 }
\psSolid[object=surface,function=F1,ngrid=.2 .2,linewidth=0.5\pslinewidth,
  hue=0 1,base=-5 5 -5 5,action=none,name=Func1]
\defFunction[algebraic]{F2}(x,y){}{}{ (-x^2+y^2)/3 } 
\psSolid[object=surface,function=F2,ngrid=.2 .2,linewidth=0.5\pslinewidth, 
  hue=0 1,base=-5 5 -5 5,action=none,name=Func2]
\psSolid[object=fusion,base=Func1 Func2,opacity=0.6]
\end{pspicture} 

\end{document}

enter image description here

and the same without setting opacity (real hidden surfaces)

enter image description here

and if you want the color depending to the z value use

\psSolid[object=surface,function=F1,ngrid=.2 .2,
         linewidth=0.5\pslinewidth,
  
         tablez=-5 0.2 5 {} for, zcolor=0.66 0,
         base=-5 5 -5 5,action=none,name=Func1]

share|improve this answer
    
Thank you very much, I didn't know the use of fusion. A second question of mine would be : how to adjust the hue as a normal function intensity colouring : the bigger the function value, the closer to red, the smaller the function value, the closer to blue ? –  Mathusalem Dec 17 '12 at 20:25
    
see my edit: -5 0.2 5 {} for iterates with a step of 0.2 and for each step one color from the range 0.66 0 is used. –  Herbert Dec 17 '12 at 20:41
    
Thanks a lot for the details, it's perfect. –  Mathusalem Dec 17 '12 at 21:34
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.