[pstricks] tangent to \psellipse or \pscircle

Patrick Drechsler patrick at pdrechsler.de
Thu Nov 1 20:09:59 CET 2007


Juergen Gilg <gilg at acrotex.net> writes:
> here a more PS-tricky solution
>
> \documentclass{article}
> \usepackage{pstricks,pst-plot,pstricks-add}
> \begin{document}
> \begin{pspicture}(-4.5,-4.5)(4.5,4.5)
> \psaxes{->}(0,0)(-4.5,-4.5)(4.5,4.5)
> \psplot[algebraic,plotpoints=500]{-4}{4}{(16-x^2)^(0.5)}
> \psplot[algebraic,plotpoints=500]{-4}{4}{-(16-x^2)^(0.5)}
> \psplotTangent[algebraic,linecolor=blue]{3}{1}{(16-x^2)^(0.5)}
> \end{pspicture}
>
> alternative
>
> \begin{pspicture}(-4.5,-4.5)(4.5,4.5)
> \psaxes{->}(0,0)(-4.5,-4.5)(4.5,4.5)
> \psplot[polarplot,algebraic,plotpoints=500]{0}{TwoPi}{4}
> \psplotTangent[polarplot,algebraic,linecolor=blue]{Pi}{1}{4}
> \end{pspicture}
> \end{document}

Thank you Juergen!

This approach is pretty neat. I adopted it like accordingly for
ellipsis:

--8<---------------cut here---------------start------------->8---
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot,pstricks-add}
\makeatletter
\def\pstEllipse{\pst at object{pstEllipse}}%
\def\pstEllipse at i(#1)#2#3{{%
    \pst at killglue%
    \addbefore at par{linewidth=1pt}%
    \use at par%
    \rput(#1){%
      \psset{unit=1,algebraic,plotpoints=100}%
      \psplot{-#2}{#2}{sqrt((1-(x^2/#2^2))*#3^2)}
      \psplot{-#2}{#2}{-sqrt((1-(x^2/#2^2))*#3^2)}
    }
}}
\def\pstETangent{\pst at object{pstETangent}}%
\def\pstETangent at i(#1)#2#3#4{{%
    \pst at killglue%
    \addbefore at par{linewidth=1pt}%
    \use at par%
    \rput(#1){%
      \psset{unit=1,algebraic,plotpoints=100}%
      \psplot{-#2}{#2}{sqrt((1-(x^2/#2^2))*#3^2)}
      \psplot{-#2}{#2}{-sqrt((1-(x^2/#2^2))*#3^2)}
      \psplotTangent[linecolor=blue]{#4}{1}{sqrt((1-(x^2/#2^2))*#3^2)}
    }
}}
\def\pstEllipseTangent{\pst at object{pstEllipseTangent}}%
\def\pstEllipseTangent at i(#1)#2#3#4{{%
    \pst at killglue%
    \addbefore at par{linewidth=1pt}%
    \use at par%
    \pstEllipse(#1){#2}{#3}
    \pstETangent(#1){#2}{#3}{#4}
}}
\makeatother
\begin{document}
\begin{pspicture}[showgrid=true](-5,-5)(5,5)
%%\pstEllipseTangent(<center>){<ellipsisRadiusA>}{<ellipsisRadiusB>}{<TangentYLocation>}
\pstEllipseTangent(0,0){4}{3}{-3}
\end{pspicture}
\end{document}
--8<---------------cut here---------------end--------------->8---

Thanks,

Patrick
-- 
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.



More information about the PSTricks mailing list