[pstricks] 3D clipping - again

MLuque5130 at aol.com MLuque5130 at aol.com
Fri Nov 4 13:37:21 CET 2005


>Now for a more tricky example, if the
>cutting plane is not at  the middle of the paraboloid? 

>Hum, probably is not possible to draw  it. 
 
It is a very imperfect solution.
The paraboloid has for equation :  x*x+y*y=z
The plan which cuts the paraboloïd has for equation x=1
 
I cannot make more at present, sorry.
 
\documentclass{article}
\usepackage{pst-3d,pst-node,pst-plot}%
\usepackage{pst-xkey}%
\SpecialCoor
\makeatletter
\pst at addfams{pst-paraboloid}
\newif\ifPstParaboloid at Inside
\define at key[psset]{pst-paraboloid}{inside}[true]{\@nameuse{PstParaboloid at Insid
e#1}}
\psset{inside=false}
%
\def\ParaboloidIIID{\pst at object{ParaboloidIIID}}
\def\ParaboloidIIID at i{\@ifnextchar[{\ParaboloidIIID at do}{\ParaboloidIIID at do[]}}
\def\ParaboloidIIID at do[#1]#2#3{{%
\pst at Verb{%
\psk at embedangle
\psk at viewpoint
\psk at viewangle
\tx at SetMatrixThreeD}
\psset{#1}%
\def\parameters{%
\psk at embedangle
\psk at viewpoint
\psk at viewangle
\tx at SetMatrixThreeD
% Vecteur  ViewPoint
\psk at viewpoint
/vZ  ED
/vY  ED
/vX  ED}%
\begin at SpecialObj
\addto at pscode{%
1  setlinejoin
\parameters
% Les couleurs
/Cyan 0.5 def
/Magenta 0.5  def
/Yellow 1 def
% /K 0.5 def
% les rayons de lumière
/xLight 1  def
/yLight 0.5 def
/zLight 1 def
% précision du tracé
/pas 0.5  def
/pas10 {pas 10 div} bind def
%
/NormeLight {xLight dup mul yLight  dup mul zLight dup mul add  add
sqrt}  bind def
%
/facette {
newpath
/Xpoint U cos V mul  AR mul \pst at number\psunit mul def
/Ypoint U sin V mul AR  mul \pst at number\psunit mul def
/Zpoint Z  \pst at number\psunit mul def
Xpoint Ypoint Zpoint  \tx at ProjThreeD
moveto
U 1 U increment add   {%
/U1 exch def
/Xpoint U1 cos V mul  AR mul \pst at number\psunit mul def
/Ypoint U1 sin V mul AR  mul \pst at number\psunit mul def
%    /Zpoint Z  \pst at number\psunit mul def
Xpoint Ypoint Zpoint  \tx at ProjThreeD
lineto
} for
Z  pas10 Z pas add {
/Z1 exch def
/V  {Z1 sqrt} bind def
/Xpoint U1 cos V mul AR mul  \pst at number\psunit mul def
/Ypoint U1 sin V mul AR mul  \pst at number\psunit mul def
/Zpoint Z1 \pst at number\psunit  mul def
Xpoint Ypoint Zpoint  \tx at ProjThreeD
lineto
} for
U  increment add -1 U {%
/U2 exch def
/Xpoint U2 cos V mul AR mul \pst at number\psunit mul def
/Ypoint U2 sin V mul AR mul \pst at number\psunit mul def
/Zpoint Z pas add \pst at number\psunit mul def
Xpoint Ypoint  Zpoint \tx at ProjThreeD
lineto
}  for
Z pas add pas10 neg Z pas10 sub{
/Z2 exch  def
/V {Z2 abs sqrt} bind def
/Xpoint U cos V mul AR mul \pst at number\psunit mul def
/Ypoint U sin V mul AR mul \pst at number\psunit mul def
/Zpoint Z2 \pst at number\psunit mul def
Xpoint Ypoint Zpoint  \tx at ProjThreeD
lineto
} for
closepath}  def
%
/MaillageParaboloid {
0 pas Hauteur pas  sub{%
/Z ED
/V {Z sqrt} bind  def
0 increment 360 increment sub {%
/U exch def
%  Centre de la facette
/Ucentre {U increment 2 div add} bind  def
/Vcentre {Z pas 2 div add sqrt} bind def
% normale  à la facette
/nXfacette {2 Vcentre dup mul mul Ucentre cos  mul} bind def
/nYfacette {2 Vcentre dup mul mul Ucentre  sin mul} bind def
/nZfacette Vcentre  def
/NormeN {nXfacette dup  mul
nYfacette dup  mul
nZfacette dup  mul
add  add sqrt} bind def
NormeN 0 eq {/NormeN 1e-10 def} if
% test de  visibilité
/PSfacette vX nXfacette  mul
vY nYfacette  mul add
vZ  nZfacette mul add
def
condition {
facette
/cosV  {1 xLight nXfacette mul
yLight nYfacette  mul
zLight nZfacette  mul
add  add
NormeLight
NormeN mul div sub} bind  def
% Cyan cosV dup mul mul Magenta cosV dup mul mul Yellow cosV mul K cosV  mul 
setcmykcolor
Cyan cosV mul dup mul Magenta cosV mul Yellow cosV mul 0  setcmykcolor
fill
0 setgray
facette
stroke
} if
} for
}  for
} def
/Hauteur #2 def
/AR #3  def
/increment 10 def
/conditionGE {PSfacette 0 ge}  def
/conditionLE {PSfacette 0 le}  def}%
%
\ifPstParaboloid at Inside{%
\addto at pscode{%
/condition  {conditionLE}  def
MaillageParaboloid}}%
\else%
{%
\addto at pscode{%
/condition  {conditionLE} def
MaillageParaboloid
/condition {conditionGE}  def
MaillageParaboloid}%
}\fi%
% fin du code  ps
\showpointsfalse%
\end at SpecialObj}}
\makeatother
%
\makeatletter
\let\ProjThreeD\tx at ProjThreeD
\def\pnodeThreeD(#1,#2,#3)#4{%
\pst at Verb{%
\psk at embedangle
\psk at viewpoint
\psk at viewangle
\tx at SetMatrixThreeD}
\pnode(!#1 #2 #3  \ProjThreeD){#4}}
\makeatother
\begin{document}
\[
\left\{
\begin{array}{rcl}
x&=&AR\sqrt{z}\cos\alpha\\
y&=&AR\sqrt{z}\sin\alpha
\end{array}
\right.
\]
\[\textrm{Plan  de coupe : } x=1\]
\begin{pspicture}(-5,-2)(5,10)
\psset{viewpoint=1 1  0.5}
\pnodeThreeD(0,0,0){O}
\pnodeThreeD(0,0,10){Z}
\pnodeThreeD(10,0,0){X}
\pnodeThreeD(0,10,0){Y}
\psline{->}(O)(X)
\psline{->}(O)(Y)
\psline{->}(O)(Z)
\uput[180](Z){$z$}
\uput[0](X){$x$}
\uput[0](Y){$y$}
%  x=AR*sqrt(z)*cos(alpha)
% y=AR*sqrt(z)*sin(alpha)
%  x^2+y^2=z*AR^2
\ParaboloidIIID{7}{1}% hauteur, coefficient x et y
% x=1 et  y=0
% zMini=sqrt(1)/AR=1/AR
% AR =  1
\psclip{%
\pscustom[linewidth=1mm]{%
\parametricplot[plotpoints=200]{7}{1}{%
/AR 1 def
/xPt 1 def
/zPt t  def
/yPt zPt AR dup mul mul xPt dup mul sub sqrt neg  def
xPt yPt zPt  \ProjThreeD}%
\parametricplot[plotpoints=200]{1}{7}{%
/AR 1 def
/xPt 1 def
/zPt t  def
/yPt zPt AR dup mul mul xPt dup mul sub sqrt  def
xPt yPt zPt  \ProjThreeD}}}%
\ParaboloidIIID[inside=true]{7}{1}%
\endpsclip%
\pnodeThreeD(0,0,7){U}
\psdot[dotsize=1mm,linecolor=red](U)
\psline{->}(U)(Z)
\end{pspicture}
\end{document}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20051104/af4be60a/attachment.html 


More information about the PSTricks mailing list