2

I am to draw a 3D function, using PSTricks' \parametricplotThreeD. Coordinate Z in two parameters is so awkward, in terms of controlling boundary values and formulation that I decided to break it into the affordable functions.

For the mathematical function (as an example),

f(t, u) = (1-u)cos(t) + uSin(t/3),

I used some of the tex.stackexchange questions and defined my function as, e.g.,

\documentclass{minimal}

\usepackage{pstricks}

\usepackage{pst-solides3d}%Drawing
\usepackage{pst-3dplot}%

\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp


\begin{document}

\newcommand{\fMathFunction}[2]
{\FPeval\result{(1-#2)(cos(#1)) + (#2)(sin((#1)/3))}\result}.

\parametricplotThreeD[algebraic, xPlotpoints=20,
linecolor=blue,%
linewidth=0.5pt,plotstyle=curve](0, 1)(0, 1){%
t|\fMathFunction{t}{u}|2+sqrt(\fMathFunction{t}{u})}%

\end{pspicture}
\end{document}

I get alot af errors.

I would like to know if defining a function in two variables is possible and how it can be utilised. If I moved, then, additionally I like to define another function, say,

g(t, u) = 2 + sqrt (f(g, u)),

and use it in place of Z.

Edit 1: My goal in this question is not drawing. I like to know if it is possible to define a custom mathematical function in two variables. We already know how to define a custom f(x). I like to define a custom f(x,y).

1 Answers1

4

I do not see how g(t,u) = 2 + sqrt(f(t,u)) should work with 0..1. f(t,u) can be negative. However, no need for the parametric function:

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

\psset{viewpoint=30 -50 30 rtp2xyz,Decran=50,lightsrc=viewpoint}
\begin{pspicture}(-1,-1)(3,7.5)
\psSolid[object=grille,base=0 3 0 3,action=draw]
\psSurface[ngrid=.1 .1,incolor=yellow,axesboxed,Zmin=-2,Zmax=4,
    linewidth=0.5\pslinewidth,
    algebraic,hue=0 1](0,0)(3,3){(1-y)*cos(x)+y*sin(x/3)}
\end{pspicture}

\end{document}

enter image description here

or with a defined function:

\def\myFunction(#1,#2){(1-#2)*cos(#1)+#2*sin(#1/3)}
\psset{viewpoint=30 -50 30 rtp2xyz,Decran=50,lightsrc=viewpoint}
\begin{pspicture}(-1,-1)(3,7.5)
    \psSolid[object=grille,base=0 3 0 3,action=draw]
    \psSurface[ngrid=.1 .1,incolor=yellow,axesboxed,Zmin=-2,Zmax=4,
    linewidth=0.5\pslinewidth,
    algebraic,hue=0 1](0,0)(3,3){\myFunction(x,y)}
\end{pspicture}
  • I am honoured getting answer directly from Herbert. Nevertheless my question is to put a function myFunction(x,y) defined at the top and then plugged into as (0,0)(3,3){myFunction(x,y)} instead of explicit expression (0,0)(3,3){(1-y)cos(x)+ysin(x/3)}. – Peter Jones Jan 14 '16 at 11:33
  • 1
    \def\myFunction(#1,#2){(1-#2)*cos(#1)+#2*sin(#1/3)} See edited answer –  Jan 14 '16 at 11:40