[pstricks] calculating the length of a line

Herbert Voss Herbert.Voss at fu-berlin.de
Sun Aug 28 12:27:37 CEST 2022


Hello all,

an example how you can use any calculation with lualatex:

\documentclass[pstricks]{standalone}5 run with lualatex
\usepackage{pst-plot,pst-node}

\def\myLineY#1{%
        \pcline{->}(0,0)(!4 dup #1 tan mul)
        \ncput*{\directlua{
tex.print(math.floor(4/math.cos(#1*math.pi/180)*10)/10)}}
        \pcline{->}(0,0)(!-4 4 #1 tan mul)}
\def\myLineX#1{%
     \pcline{->}(0,0)(!4 #1 tan div 4)
     \pcline{->}(0,0)(!-4 #1 tan div -4)}

\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psaxes{<->}(0,0)(-4,-4)(4,4)
\multido{\iA=-45+15}{7}{\myLineY{\iA}}
\multido{\iA=45+15}{6}{\myLineX{\iA}}
\end{pspicture}
\end{document}

\end{document}




Herbert


More information about the PSTricks mailing list.