[pstricks] help for writing a macro

Germain Boyer germain.boyer at laposte.net
Fri Oct 28 19:41:53 CEST 2016


Hello
One day Herbert helps me to write this macro :

\makeatletter
\def\psdotsx{\@ifnextchar[{\psdotsx at i}{\psdotsx at i[]}}
\def\psdotsx at i[#1](#2){%
\def\psdotsx at para{#1}
    \begingroup%
    \psset{#1}\psdotsx at ii(#2)%
}% end of  \def\psdotsx at i
    \def\psdotsx at ii(#1){%
    \pnode(#1){thenode}\psdotsx at iii%
    \@ifnextchar({\psdotsx at ii}{\endgroup}
}% end of  \def\psdotsx at ii
\def\psdotsx at iii{%
    \pnode([nodesep=1.5mm,angle=45,\psdotsx at para]thenode){thenodea}%
   \multido{\ia=0+90 , \ib=1+1}{4}{%
   \psRelNode[angle=\ia](thenode)(thenodea){1}{thenode\ib}
   \psline(thenode)(thenode\ib)%
}% end of \multido
}% end of  \def\psdotsx at iii
\makeatother
%----------------------------------------------------------------------------------------------------------------------------
% exemples :
%
%    \SpecialCoor
%     \psdotsx[nodesep=2mm,angle=45](P)
%      \psdotsx[nodesep=2mm](1,3)
%       \psdotsx[angle=30](2;45)
%----------------------------------------------------------------------------------------------------------------------------

There is a little problem when xunit and yunit are different.
The solution is changing the unit in the argument and changing the  
coordinates of the point like in this example :

\def\xmin{-9.6} \def\xmax{150.6} \def\ymin{-9.6} \def\ymax{200.6}
\psset{xunit=0.1cm,yunit=0.05cm,arrowinset=0,arrowscale=1.25}
\begin{pspicture}(-9.6,-9.6)(150.6,200.6)
\psset{xunit=1cm,yunit=0.5cm}
\psset{gridlabels=0pt , gridwidth=0.4pt , gridcolor=gray , subgriddiv=1}
\psgrid(0,0)(0,0)(15,20)
\psset{xunit=0.1cm,yunit=0.05cm}
%
\psaxes[linewidth=1pt,tickwidth=0.75pt,Dx=10,Dy=10]{->}(0,0)(0,0)(150.6,200.6)
\psaxes[linewidth=1pt,ticks=none,labels=none](0,0)(-0.75pt,-0.75pt)(0,0)
%
\uput[-90](150.6,0){$v_i$}
\uput[180](0,200.6){$d_i$}
%
%
%\psdotsx[yunit=\psxunit,angle=45,linewidth=0.75pt]%
\psdotsx[yunit=2\psyunit,angle=45,linewidth=0.75pt]%  yunit=2\psyunit   to  
have    yunit=\psxunit
(! 20 \space 3.5 2 div)%
(! 43\space 20.5 2 div)%
(! 62 \space 35.9 2 div)%
(! 80 \space 67.8 2 div)%
(! 98 \space 101.2 2 div)%
(! 115 \space 135.8 2 div)%
(! 130 \space 168.5 2 div)%
%
\psdotsx[angle=45,linewidth=0.75pt,linecolor=red](20,20)
\psdotsx[yunit=\psxunit,angle=45,linewidth=0.75pt](! 20 \space 30 2 div)
\psdotsx[angle=0,linewidth=0.75pt,linecolor=red](20,40)
%
\psplot[algebraic=true,linewidth=0.5pt]{0}{140}{(257/30000)*x^2+(43/200)*x-(317/75)}
%
%
\end{pspicture}
%----------------------------------------------------------------------------------------------------------------------------
My question is : It is possible to correct this problem inside the macro  
to be able to write

\psdotsx[angle=45,linewidth=0.75pt](20,3.5)(43,20.5)(62,35.9)

and have the correct cross ?

Thanks for your answers.

Germain


More information about the PSTricks mailing list