[pstricks] 3D surface on non rectangular domain

Manuel Luque mluque5130 at aol.com
Thu Mar 2 18:28:33 CET 2017


I propose a new command \ psSURFACE to not modify the existing command.

\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{\def\pst at par{}\pst at object{psSURFACE}}
\def\psSURFACE at i#1{%
  \begin at SpecialObj
  \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
    \ifPst at algebraic
      /fonction (#1) tx at AlgToPs begin AlgToPs end cvx def
    \else
      /fonction  { #1 } 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
    \use at pscode%
    \end at SpecialObj
  \ignorespaces}
\makeatother
\begin{document}
\begin{center}
\begin{pspicture}(-5,-4)(6,15)
\psset{viewpoint=50 10 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]{%
   Euler x y mul exp }
\psSurface[
   action=draw,linewidth=0.01,linecolor=gray!70,
   ngrid=.2 .2,incolor=yellow](-1.5,-1.5)(1.5,1.5){%
   Euler x y mul exp }
\psSolid[object=cylindre,r=1,h=2,action=draw,ngrid=1 18,linecolor={[rgb]{0 0.5 0}}]
\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,15)
\psset{viewpoint=50 10 30 rtp2xyz,Decran=100,lightsrc=viewpoint}
\axesIIID(0,0,0)(2,2,1)
\psSURFACE[
   inouthue=1 0.5 0.5 1,
   r=1,
   ngrid=.25 .25,incolor=yellow,grid,translation=0.4 0.4]{%
   Euler x y mul exp }
\psSurface[
   action=draw,linewidth=0.01,linecolor=gray!70,
   ngrid=.2 .2](-1.5,-1.5)(1.5,1.5){%
   Euler x y mul exp }
\psSolid[object=cylindre,r=1,h=4,action=draw,ngrid=1 18,linewidth=0.01](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)
\psSolid[object=grille,base=-2 2 -2 2,action=draw]%
\end{pspicture}
\end{center}
\end{document}









 

 

Manuel Luque
mluque5130 at aol.com

 

 

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

Thank you Herbert and Manuel,

I tried both of your solutions.

Manuel, it seems with your new \psSurface* macro you do not have the usual \psSurface behavior: \psSurface* and \psSurface generate the same figure, whether the r parameter is given or not. For instance, with source the code in your message

\psSurface*[
   fillcolor=cyan,
%   r=1,
   ngrid=.5 .5,incolor=yellow,grid](-1,-1)(1,1){%
   Euler x y mul exp }

is the same as with the r=1 line uncommented. Also

\psSurface[
   fillcolor=cyan,
%   r=1,
   ngrid=.5 .5,incolor=yellow,grid](-1,-1)(1,1){%
   Euler x y mul exp }

is the same as 

\psSurface[
   fillcolor=cyan,
   r=1,
   ngrid=.5 .5,incolor=yellow,grid](-1,-1)(1,1){%
   Euler x y mul exp }

This is fine, but the problem is that the \psSurface (unstarred version without passing the r parameter) draws the surface on a circular domain (and I cannot figure out how is this domain controled)

I then tried Herbert's solution. My objective is to draw a surface of a function f as usual on a rectangular domain (xmin,xmax)X(ymin,ymax), but I also want to draw (on the same figure) the surface of f but only for (x,y) in some spherical domain B (typically a ball with a given radius) using a different color. With Herbert solution, because it translates the origin before drawing the surface for (x,y) \in B, if the surface to be drawn is to coincide exactly with that of f, the function to be plotted after the change of origin (0,0,0) to Neworigin=(ox,oy,0) must be g defined as g(x,y)= f(x+ox,y+oy). Right? If so, here is an example. It seems to me that the surfaces drawn after the change of origin (red and blue) do not exactly overlap with the whole surface of f. Is this the normal behavior? Is there something I do not understand with the change of origin?
elef



----- Mail original -----
De: "Herbert Voss" <Herbert.Voss at FU-Berlin.DE>
À: pstricks at tug.org
Envoyé: Jeudi 2 Mars 2017 09:11:55
Objet: Re: [pstricks] 3D surface on non rectangular domain

Am 01.03.2017 um 21:34 schrieb leon.free at free.fr:
> 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)).

for  \psSurface* (star version) only r is valid and for
\psSurface only the x-y area.
You can change the origin by using \rput:

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{pst-solides3d}
\begin{document}

\psset{viewpoint=50 30 30 rtp2xyz,Decran=100,lightsrc=viewpoint}
\begin{pspicture}(-5,-4)(6,6)
\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,
	algebraic](-1,-1)(1,1){ e^(x*y) }
\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$}
\psPoint(0.5,0.5,0){C}
\psdot[linecolor=red,dotstyle=x,dotscale=2](C)
\end{pspicture}
%
\begin{pspicture}(-5,-4)(6,6)
\psSolid[object=grille,base=-2 2 -2 2,action=draw]%
\axesIIID(0,0,0)(2,2,1)
\psPoint(0.5,0.5,0){Origin}
\rput(Origin){%
	\psSurface*[
	fillcolor=cyan,r=1,
	ngrid=.25 .25,incolor=yellow,grid,
	algebraic](-1,-1)(1,1){ e^(x*y) }}
\psSolid[object=cylindre,r=1,h=2,action=draw,ngrid=1 18](0.5,0.5,0)
\psPoint(0,0,1){O}
\psPoint(0,0,3){Z}
\psline{->}(O)(Z)
\uput[r](Z){$z$}
\psPoint(0.5,0.5,0){C}
\psdot[linecolor=red,dotstyle=x,dotscale=2](C)
\end{pspicture}

\end{document}


Herbert


_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-3.png
Type: image/png
Size: 77254 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-4.png
Type: image/png
Size: 84948 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-3.png
Type: image/png
Size: 77254 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EXPxy-4.png
Type: image/png
Size: 84948 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leon-2.pdf
Type: application/pdf
Size: 571690 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0001.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leon-2.tex
Type: application/octet-stream
Size: 3791 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170302/9d3dc89e/attachment-0001.obj>


More information about the PSTricks mailing list