[pstricks] Re: Hyperbolas

Jacques L'helgoualc'h lhh+nospam at free.fr
Tue Feb 8 23:09:23 CET 2005


Herbert Voss a écrit, mardi 8 février 2005, à 20:11 :
> Jacques L'helgoualc'h wrote:
[...]
> >\def\psthyperbola at ii#1#2{% a b
> >  \addto at pscode{%
> >    /a {#1} bind def
> >    /b {#2} bind def
> >    /d {2 1 t dup mul sub div} bind def}% d = 2/(1 - t^2)
> >  \parametricplot{-.99}{.99}{%
> >    a d 1 sub mul % (1 + t^2)/(1 - t^2) = -1 + 2/(1 - t^2)
> >    b t d mul mul}
> >}
> >\makeatother
> >
> >but d depends on t: I feel it should be (re)defined inside the
> >parametricplot loop?
> 
> no, but your binds do not really make sense here

Yes for d,  but I don't like computing twice the  same subformula. For a
and b, I prefer the values:

\documentclass{minimal}
\usepackage{pstricks,pst-plot}
\makeatletter
\def\psthyperbola{\pst at object{psthyperbola}}
\def\psthyperbola at i#1#2{%
  \pst at killglue
  \begingroup
  \use at par
  \psthyperbola at ii{#1}{#2}
  \psthyperbola at ii{#1 neg}{#2}% second branch
  \endgroup
}
\def\psthyperbola at ii#1#2{% a b
  \addto at pscode{%
    /a {#1} bind def
    /b {#2} bind def
  }
  \parametricplot{-.99}{.99}{%
    2 1 t dup mul sub div % d = 2/(1 - t^2)
    dup
    1 sub a mul % x = a * (-1 + 2/(1 - t^2))
    exch
    t mul b mul}% y = b * 2t/(1 - t^2)
}
\makeatother
\parindent=0pt
\begin{document}
\begin{pspicture*}(-6.2,-10.2)(6,10)
  \psaxes[linewidth=.4pt]{->}(0,0)(-6,-10)(6,10)
  \psthyperbola[linecolor=blue]{1}{3 sqrt}% a b
\end{pspicture*}
\end{document}

-- 
Jacques L'helgoualc'h




More information about the PSTricks mailing list