[pstricks] more on computed coordinates
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Sat Aug 9 12:03:20 CEST 2008
Zbigniew Nitecki schrieb:
> Thanks, Juergen and Michael. I don't know what was going on, but
> somehow things seemed to work in the end. But now trying a more
> complicated but analogous version of this, I run into trouble. I now
> want to draw arrows from the plane tangent at (0,1,1) to z=x^2+y^2,
> which has the
> equation z=2y-1, to the graph. Here is my code, including some function
> definitions (I will comment on the comments (:-) below):
it is a bit diffucult to understand the differenve between TeX code
and PostScript code.
- after a TeX variable #? there is no need for a \space command
- after a TeX macro it is!
- pst-3dplot - coordinates are passed to PostScript as is, the
comma is the separator,
the reason why (5 sqrt, 3 4 mul /x 3 def, x 3 mul) will work
I insert an abs (see %%%%).
Herbert
\documentclass{article}
\usepackage{pst-3dplot}
\begin{document}
\begin{pspicture}(-2.5,-3)(2.5,3.5)
\psset{Alpha=30}
\psset{xunit=2cm, yunit=2cm}
\pstThreeDCoor[xMax=2,yMax=2,zMax=3]
\psplotThreeD[linecolor=gray,
drawStyle=xyLines,xPlotpoints=50,yPlotpoints=50]%
(-1.5,1.5)(0,1.5){x 2 exp y 2 exp add}
\newcommand\zgraph[2]{ #1 dup mul #2 dup mul add }
\newcommand\zplane[2]{ #2 2 mul 1 sub }
\newcommand\thit[2]{
#2 2.5 #2 mul 0.0625 add #1 dup mul sub 1 sub abs %%%%%
0.5 exp sub 0.5 mul 0.125 add }
\newcommand\yhit[2]{#2 \thit{#1}{#2}\space 2 mul sub }
\newcommand\zhit[2]{\zgraph{#1}\space \yhit{#1}{#2} }
%
\multido{\rx=-0.9+0.4}{6}{%
\multido{\ry=0.1+0.5}{3}{%
\pstThreeDDot(\rx,\ry,\zplane{\rs}{\ry})
\pstThreeDDot(\rx,\yhit{\rx}{\ry},\zhit{\rx}{\ry})
\pstThreeDLine[linestyle=dashed, arrows=->]%
(\rx,\ry,\zplane{\rs}{\ry})%
(\rx,\yhit{\rx}{\ry},\zhit{\rx}{\ry})
}
}
\pstThreeDDot(1,\yhit{1}{1},\zhit{1}{1})
\pstThreeDLine[arrows=->](0.8,1,1)(0.8,0.62,1.18)
\pstThreeDLine[arrows=->](1,1.5,2)(1,1.1,2.2)
\pstThreeDLine[arrows=->](1,1.3,1.6)(1,0.9,1.8)
\pstThreeDLine[arrows=->](1,1,1)(1,0.5,1.25)
%
\psplotThreeD[linewidth=0.1pt,linecolor=lightgray,
drawStyle=xyLines](-1,1)(0,2){y 2 mul 1 sub}
\pstThreeDDot(0,1,1)
\end{pspicture}
\end{document}
More information about the PSTricks
mailing list