[pstricks] including PostScript code in pstricks

Herbert Voss LaTeX at zedat.fu-berlin.de
Fri Mar 24 21:46:05 CET 2006


Germi Camps wrote:

> the begining and ending angle, and I also need to calculate theese 
> angles, as follows
> 
> \psarc(!\rad\space 1 \rad\space add div 10 mul 0)%
>    { \radb\space 2 div 1 add }{ \rad\space 1 sub \rad\space 1 add div }{ 
> \rad\space 1 sub \rad\space 1 add div neg }
> 
> but this doesn't work. what do I have to change in the \psarc code?
> finally, in the solution you wrote the radius is interpreted in pt, and 
> I need to write it in cm. In fact I can multilpy the number by 28,45 (pt 
> in a cm) and the output is the same, but maybe there is another way.

\listfiles
\documentclass{minimal}

\usepackage{pstricks}
\SpecialCoor
\makeatletter
\def\psarc at iii(#1)#2#3#4{%
   \begin at OpenObj
     \def\pst at tempa{#3}
     \def\pst at tempb{#4}
     \pst@@getcoor{#1}%
     \def\pst at tempA{#2}%
     \addto at pscode{\psarc at iv \psarc at v}%
     \gdef\psarc at type{0}%
     \showpointsfalse
   \end at OpenObj%
}
\def\psarc at iv{%
   \pst at coor /y ED /x ED
   /r \pst at tempA\space \pst at number\psunit mul def
   /c 57.2957 r \tx at Div def
   /angleA
     \pst at tempa
     \psk at arcsepA c mul 2 div
     \ifcase \psarc at type add \or sub \fi
   def
   /angleB
     \pst at tempb
     \psk at arcsepB c mul 2 div
     \ifcase \psarc at type sub \or add \fi
   def
   \ifshowpoints\psarc at showpoints\fi
   \ifx\psk at arrowA\@empty
     \ifnum\psk at liftpen=2
       r angleA \tx at PtoC
       y add exch x add exch moveto
     \fi
   \fi}
\makeatother

\begin{document}
\def\rad{3}
\def\radb{5}

\psarc(!\rad\space 1 \rad\space add div 10 mul -10)%
	{ \radb\space 2 div 1 add }
	{ \rad\space 1 sub \rad\space 1 add div RadtoDeg }
	{ \rad\space 1 sub \rad\space 1 add div RadtoDeg neg }

\end{document}



Herbert





More information about the PSTricks mailing list