[pstricks] 3D surface on non rectangular domain

Manuel Luque mluque5130 at aol.com
Thu Mar 2 08:19:42 CET 2017


 >Working with your example, the range seems to have no effect on the plot  

 That's right
 >Are there some extra parameters that control the center of the ball?
No.
The command must be modified to introduce the possibility of moving the center. Thus with the translate option and the command thus modified (
I attach the file as well.)





\documentclass{article}
\usepackage{pst-solides3d}
\makeatletter
\define at key[psset]{pst-solides3d}{translation}{\def\pst at solides@translation{#1 }}
\psset[pst-solides3d]{translation=0 0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% la macro \psSurface
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\psSurface{\@ifnextchar*{\@startrue\psSurface at i}{\@starfalse\psSurface at i*}}
\def\psSurface at i*{\@ifnextchar[{\psSurface at ii}{\psSurface at ii[]}}
\def\psSurface at ii[#1](#2,#3)(#4,#5)#6{%
  \pst at killglue%
  \begingroup%
  \psset{axisemph=\small,planmarks,#1}%
  \init at pscode%
  \addto at pscode{
    1 setlinejoin
    /TRANSLATE {\pst at solides@translation} def
    \tx at optionssolides
    SolidesDict begin
    /CX 0 def /CY 0 def /CZ 0 def
    TRANSLATE /tY exch def /tX exch def
    /base [ #2 #4 #3 #5 ] def
    \ifPst at algebraic
      /fonction (#6) tx at AlgToPs begin AlgToPs end cvx def
    \else
      /fonction  { #6 } def
    \fi
    /f {2 dict begin
      /y exch def
      /x exch def
      fonction end
    } def
/newSURFACE* {
7 dict begin
   /f_surface exch def
   [[/nx /ny] [6 6] [6 8] [10 8] [16 12] [16 36]] gestionsolidmode
   nx isinteger not {
       %% alors nx est un dx
       /nx xmax xmin sub nx div cvi store
   } if
   ny isinteger not {
       %% alors ny est un dy
       /ny ymax ymin sub ny div cvi store
   } if
   /dy ymax ymin sub ny div def %% le pas sur y
   /dx xmax xmin sub nx div def %% le pas sur x
   %% ny = nb de meridiens
   %% nx = nb d horizontales
   /r exch def
   /F [
       %% 1er etage
       1 1 ny {
           /i exch def
           [0 i i ny mod 1 add]
       } for
       %% etages suivants
       0 1 nx 2 sub {
           /j exch def
           1 1 ny {
               /i exch def
               [i      j ny mul add
               i ny add j ny mul add
               i ny mod ny add 1 add j ny mul add
               i ny mod 1 add j ny mul add]
           } for
      } for
   ] def
   %% tableau des sommets
   /S [
       0 0 0 0 f_surface
       1 1 nx {
           /j exch def
           1 1 ny {
             /i exch def
             /theta i 360 mul ny div def
             theta cos r j mul nx div mul tX add
             theta sin r j mul nx div mul tY add
             2 copy f_surface
          } for
       } for
   ] def
   S F generesolid
end
} def
/pst-surface* {
   r
   ngrid length 2 ge {
      [ngrid 0 get ngrid 1 get]
   } {
      ngrid length 1 eq {
         [ngrid 0 get dup]
      } ifelse
   } ifelse
   {f} newSURFACE*
   solidbiface { dup videsolid } if
   gere_pstricks_opt
} def
    pst-surface*
    end
  }% fin du code ps
  \@starfalse
  \ifPst at axesboxed\gridIIID(#2,#4)(#3,#5)\fi
  \ifPst at solidmemory\else%
    \ifpsshadow \pst at closedshadow \fi
    \ifdim\psk at border\p@>\z@ \pst at addborder \fi
    \psk at fillstyle
    \pst at stroke
    \ifpsdoubleline \pst at doublestroke \fi
    \ifshowpoints\pst at OpenShowPoints\fi
    \use at pscode%
  \fi%
  \endgroup%
  \ignorespaces}
\makeatother
\begin{document}
\begin{center}
\begin{pspicture}(-5,-4)(6,10)
\psframe(-5,-4)(6,10)
\psset{viewpoint=50 30 30 rtp2xyz,Decran=200,lightsrc=viewpoint}
\psSolid[object=grille,base=-1 1 -1 1,action=draw]%
\axesIIID(0,0,0)(2,2,1)
\psSurface*[
   fillcolor=cyan,
   r=1,
   ngrid=.25 .25,incolor=yellow,grid](-1,-1)(1,1){%
   Euler x y mul exp }
\psSolid[object=cylindre,r=1,h=2,action=draw,ngrid=1 18]
\psPoint(0,0,1){O}
\psPoint(0,0,3){Z}
\psline{->}(O)(Z)
\uput[r](Z){$z$}
\end{pspicture}
\end{center}

\begin{center}
\begin{pspicture}(-5,-4)(6,10)
\psset{viewpoint=50 -30 30 rtp2xyz,Decran=100,lightsrc=viewpoint}
\psSolid[object=grille,base=-2 2 -2 2,action=draw]%
\axesIIID(0,0,0)(2,2,1)
\psSurface*[
   fillcolor=cyan,
   r=1,
   ngrid=.25 .25,incolor=yellow,grid,translation=0.4 0.4](-1,-1)(1,1){%
   Euler x y mul exp }
\psSolid[object=cylindre,r=1,h=4,action=draw,ngrid=1 18](0.4,0.4,0)
\psPoint(0,0,1){O}
\psPoint(0,0,5){Z}
\psline{->}(O)(Z)
\uput[r](Z){$z$}
\psPoint(0.4,0.4,0){C}
\psdot(C)
\end{pspicture}
\end{center}
\end{document}



Manuel Luque


 

-----E-mail d'origine-----
De : leon.free <leon.free at free.fr>
A: Graphics with PSTricks <pstricks at tug.org>
Envoyé le : Me, 1 Mar 2017 21:35
Sujet : Re: [pstricks] 3D surface on non rectangular domain

Thank you Manuel. Yes, this is close to what I'd like to do. I did not know about the r parameter for \psSurface* (I could not find it in the pst-solides3d doc). It seems it controls the radius of the domain (ball) on which the surface is drawn. Are there some extra parameters that control the center of the ball? Moreover, when using r=1 how does this interact with the plotting range (xmin,ymin)(xmax,ymax)? Working with your example, the range seems to have no effect on the plot (I even used (0,0)(0,0) instead of (-1,-1)(1,1)).elef----- Mail original -----De: "Manuel Luque" <mluque5130 at aol.com>À: pstricks at tug.orgEnvoyé: Mercredi 1 Mars 2017 20:35:25Objet: Re: [pstricks] 3D surface on non rectangular domainI do not know if I understood your question correctly. Here, the domain is restricted to R (x, y) <1 \documentclass{article} \usepackage{pst-solides3d} \begin{document} \begin{center} \begin{pspicture}(-5,-4)(6,10) \psframe(-5,-4)(6,10) \psset{viewpoint=50 30 30 rtp2xyz,Decran=200,lightsrc=viewpoint} \psSolid[object=grille,base=-1 1 -1 1,action=draw]% \axesIIID(0,0,0)(2,2,1) \psSurface*[ fillcolor=cyan, r=1, ngrid=.5 .5,incolor=yellow,grid](-1,-1)(1,1){% Euler x y mul exp } \psSolid[object=cylindre,r=1,h=2,action=draw,ngrid=1 18] \psPoint(0,0,1){O} \psPoint(0,0,3){Z} \psline{->}(O)(Z) \uput[r](Z){$z$} \end{pspicture} \end{center} \end{document} EXPxy.pngManuel Luque -----E-mail d'origine----- De : leon.free <leon.free at free.fr> A: pstricks <pstricks at tug.org> Envoyé le : Me, 1 Mar 2017 15:08 Sujet : [pstricks] 3D surface on non rectangular domain Hi, I'd like to plot the surface of a function such as exp(x*y) only for the (x,y)'s in the unit ball B = \{(x,y) \in \mathbb{R}^2 : x^2+y^2 \le 1\}. I do not want to set the value of the function outside B to some particular value (e.g. 0). Do you know if there exists some pstricks package that can make this ? Thanks, elef _______________________________________________ PSTricks mailing list PSTricks at tug.org http://tug.org/mailman/listinfo/pstricks archive: http://www.tug.org/pipermail/pstricks/ _______________________________________________PSTricks mailing listPSTricks at tug.orghttp://tug.org/mailman/listinfo/pstricksarchive: http://www.tug.org/pipermail/pstricks/_______________________________________________PSTricks mailing listPSTricks at tug.orghttp://tug.org/mailman/listinfo/pstricksarchive: http://www.tug.org/pipermail/pstricks/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/5b471571/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-2.png
Type: image/png
Size: 34646 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/5b471571/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-2.png
Type: image/png
Size: 34646 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/5b471571/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leon.tex
Type: application/octet-stream
Size: 4024 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/5b471571/attachment-0001.obj>


More information about the PSTricks mailing list