[pstricks] including PostScript code in pstricks

Germi Camps gcampsbarjau at gmail.com
Fri Mar 24 21:29:25 CET 2006


En/na Herbert Voss ha escrit:
> Germi Camps wrote:
>> I have to draw a serie of arcs, but first I have to calculate the 
>> center point, the radius and the beginning and ending angle depending 
>> on a parameter
>> I do not have any problem when calculating the center, because it is 
>> delimited by ( ). but for the other arguments, delimited by { }, 
>> pstricks doesn't accepts PostScript code... how can I do it?
>>
>> \def\rad{3}
>> \def\radb{5}
>>
>> \psarc(!\rad\space 1 \rad\space add div 10 mul 0){! \radb\space 2 div 
>> 1 add}{0}{360}
>>
>> ! \radb\space 2 div 1 add -->> this doesn't work inside { }
>
> this needs a redefinition of the \psarc macro
>
> Herbert
>
> \listfiles
> \documentclass{minimal}
>
> \usepackage{pstricks}
> \SpecialCoor
> \makeatletter
> \def\psarc at iii(#1)#2#3#4{%
>   \begin at OpenObj
>     \pst at getangle{#3}\pst at tempa
>     \pst at getangle{#4}\pst at tempb
>     \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 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 0)%
>     { \radb\space 2 div 1 add }{0}{360}
>
> \end{document}
>
>
>
> _______________________________________________
> pstricks mailing list
> pstricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
>
perfect, now it works, but in the example I sent I put {0} and {360} as 
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.

thanks again

Germinal



More information about the PSTricks mailing list