[pstricks] more confusion

Nitecki, Zbigniew H. Zbigniew.Nitecki at tufts.edu
Sun Jan 1 21:12:16 CET 2012


OK, a related question.  I am trying to draw a hyperbola with a given aspect ratio, given also the desired distance from the origin to the vertices.  If that distance is given as zero, I want to draw the asymptotes.  My ultimate goal is to get this inside a mutlido.  The following code

\newcommand{\fubranch}[4][1.0]{%
\parametricplot[linecolor=#3]{-#4}{#4}{%
t SINH #2 mul t COSH #1 #2 mul mul
}
}%Colored upper branch of hyperbola x^{2}/A^{2}-y^{2}/B^{2}=-C^{2};  arguments are:
%#1=B/A =slope of asymptotes:  default is 1.0
%#2=AC=distance of vertex from origin
%#3=color
%#4=range:
%to fit inside axb box, use
%#5=MIN(sinh^{-1}(a/#2), cosh^{-1}(b/(#2*#1)))

\newcommand{\fdbranch}[4][1.0]{%
\parametricplot[linecolor=#3]{-#4}{#4}{%
t SINH #2 mul t COSH #1 #2 mul mul neg
}
}%Colored lower branch of hyperbola x^{2}/A^{2}-y^{2}/B^{2}=-C^{2};  arguments are:
%#1=B/A =slope of asymptotes:  default is 1.0
%#2=AC=distance of vertex from origin
%#3=color
%#4=range:
%to fit inside axb box, use
%#5=MIN(sinh^{-1}(a/#2), cosh^{-1}(b/(#2*#1)))


\newcommand{\fvhyp}[4][1.0]{%
\ifthenelse{#2=0}{%
\psline[linecolor=#3]%
(! #4 SINH #2 mul neg #4 COSH #2 #1 mul mul neg)%
(! #4 SINH #2 mul #4 COSH #2 #1 mul mul)%
\psline[linecolor=#3]%
(! #4 SINH #2 mul neg #4 COSH #2 #1 mul mul)%
(! #4 SINH #2 mul #4 COSH #2 #1 mul mul neg)%
}
{%
\fubranch[#1]{#2}{#3}{#4} \fdbranch[#1]{#2}{#3}{#4}
}
}%Colored hyperbola x^{2}/A^{2}-y^{2}/B^{2}=-C^{2};  arguments are:
%#1=B/A =slope of asymptotes:  default is 1.0
%#2=AC=distance of vertex from origin
%#3=color
%#4=range:
%to fit inside axb box, use
%#5=MIN(sinh^{-1}(a/#2), cosh^{-1}(b/(#2*#1)))


gives an error message:

./Brief_picture_test2.tex:78: Missing = inserted for \ifnum.

According to TLC2e, this occurs if one forgets the comparison operator is forgotten inside an \ifthenelse.
In my case, the comparison occurs in the first line of the definition of the last new command (\fvhyp).
Here I do have an equal sign, so perhaps I should be handling the value of the argument #2 differently.
The output prints the asymptotes (when #2=0) but also prints the conditional statement.

How should this be handled?

Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/




On Jan 1, 2012, at 14:10, Nitecki, Zbigniew H. wrote:

Of course!  Thanks…I feel like a total idiot.

Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/




On Jan 1, 2012, at 14:05, Michael Sharpe wrote:


On Jan 1, 2012, at 10:07 AM, Nitecki, Zbigniew H. wrote:

Inside a pspicture environment, the code

\parametricplot[linecolor=red]{-1.6}{1.6}{t COSH 2 mul t SINH 1.5 2 mul mul}

(correctly) gives me the right branch of the hyperbola (x^2)/4-(y^2)/9=1, in red.

But the code

\newcommand{\frbranch}[5][1.0]{%
\parametricplot[linecolor=#4]{-#5}{#5}{%
{t COSH #2 mul t SINH #1 #3 mul mul}
}
}%Colored right branch of hyperbola x^{2}/A^{2}-y^{2}/B^{2}=C^{2};  arguments are:
%#1=B/A =slope of asymptotes:  default is 1.0
%#2=AC=distance of vertex from origin
%#3=A
%#4=color
%#5=range:  to fit inside axb box, use
%#5=MIN(cosh^{-1}(a/A), sinh^{-1}(b/B))
\begin{pspicture}(-5,-5)(5,5)
\frbranch[1.5]{2}{2}{red}{1.6}
\end{pspicture}

crashes on execution.

What am I doing wrong? (Ignore my choice of #5=1.6.  It was an arbitrary choice which should affect nothing.)

You have an additional pair of braces around the function, which prevents PostScript from executing the code. You should instead write

\newcommand{\frbranch}[5][1.0]{%
\parametricplot[linecolor=#4]{-#5}{#5}%
{t COSH #2 mul t SINH #1 #3 mul mul}
}

Michael


_______________________________________________
PSTricks mailing list
PSTricks at tug.org<mailto: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/




More information about the PSTricks mailing list