[pstricks] Hyperbolas

Richard Hensh hensh at math.msu.edu
Tue Feb 8 04:53:44 CET 2005


Here's a similar idea applied to the reciprocal function (horizontal
transformations are also handled).

	y = a/(x-b)

I'm guessing that this idea could be easily adapted to handle cases such as 

	(x-h)^2/a^2 + (y-k)^2/b^2 = 1

ricky


\documentclass[10pt]{article}
\usepackage{pstricks}
\usepackage{pst-plot,pst-math,pstricks-add}%
\makeatletter
\def\pstrecip{\pst at object{pstrecip}}
\def\pstrecip at i#1#2{%
    \pst at killglue
    \begingroup
    \use at par
    \pstrecip at ii{#1}{#2}{1}
    \pstrecip at ii{#1}{#2}{-1}
    \endgroup
}
\def\pstrecip at ii#1#2#3{%
    \addto at pscode{/a #1 def /b #2 def
    /p {dup 1 sub neg div} bind def % p maps [0,1) --> (b,infty)
    }
    \parametricplot{0.001}{0.999}{%
    t p #3 mul #2 add
    a t p div #3 mul
    }
}
\makeatother
\parindent=0pt
\begin{document}

\def\xmin{-6}\def\xmax{6}
\def\ymin{-6}\def\ymax{6}
\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax)
%\showgrid
    \psaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax)%
    \psclip{\myframe(\xmin,\ymin)(\xmax,\ymax)}
        \psset{linewidth=1.5pt}
        \pstrecip{1}{2}  % y = 1/(x-2)
        \pstrecip[linecolor=red]{-3}{2} % y = -3/(x-2)
        \pstrecip[linecolor=blue]{0.5}{0}
    \endpsclip
\end{pspicture}
\end{document}




More information about the PSTricks mailing list