[pstricks] psarc

Poul Riis Poul.Riis at skolekom.dk
Tue Nov 25 15:44:31 CET 2008


After a long fight with arc and arrow I ended up with the solution below.

Poul Riis


\documentclass[a4paper,12pt]{article}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage[danish]{babel}
\usepackage{amsmath}
\usepackage[usenames,dvipsnames,x11names]{xcolor}
\usepackage{ifthen}
\usepackage{geometry}
\usepackage{multido}
\usepackage{pst-func}
%\usepackage{pst-3dplot}
\usepackage{pstricks-add}

\def\getColor#1{\ifcase#1 Red1\or magenta\or Gold1\or Green1\or Orange\or
Blue1\or
Red1\or magenta\or Gold1\or Green1\or Orange\or Blue1\or
Red1\or magenta\or Gold1\or Green1\or Orange\or Blue1\or
Red1\or magenta\or Gold1\or Green1\or Orange\or Blue1\fi}

\begin{document}
\begin{center}
\psset{unit=2mm}
\begin{pspicture}(0,-2.5)(80,20)
\psaxes[Dx=5,Dy=5,ticksize=-3pt]{->}(0,0)(80,20)
\pstVerb{
	/gg 9.82 def
	/v0 20 def
	/w0y 10 neg def
	/theta 60 def
	/v0x v0 theta cos mul def
	/v0z v0 theta sin mul def
	/wang 1 v0x div 150 mul def
	/alpha 0.6 def
	/eps 0.5 def
	/epsz 0.8 def
	/beta eps 1 add alpha 1 add div def
	/alphabeta alpha beta mul def
	/enminusalphabeta 1 alphabeta sub def
	/enminusbeta 1 beta sub def
	/x0 0 def
	/z0 0 def
	/xT v0z v0x mul gg div x0 add def
	/zT v0z dup mul 2 div gg div z0 add def
	/pi 3.141592 def
/arcarrow { %def
gsave
/endang exch def /startang exch def 5.69 mul /rr exch def 5.69 mul /cy
exch def 5.69 mul /cx exch def 5 /ahsize exch def endang startang sub abs
pi mul 180 div rr 1 add mul /smallahsize exch def 5 smallahsize gt
{smallahsize /ahsize exch def} if startang endang lt {/psi rr 1 add ahsize
exch div 57 mul neg def cx cy rr startang endang psi add arc stroke} {/psi
rr 1 add ahsize exch div 57 mul def cx cy rr endang psi add startang arc
stroke} ifelse endang cos rr mul cx add endang sin rr mul cy add moveto 10
10 360 {/ii exch def 3 ii cos 2 mul sub ii 2 mul cos sub 2 mul 9 div /xf
exch def ii sin 2 mul ii 2 mul sin sub 9 div /yf exch def endang psi xf
mul add /actang exch def rr ahsize yf mul add /actrr exch def actang cos
actrr mul cx add actang sin actrr mul cy add lineto} for closepath fill
stroke
grestore
newpath
} bind def
}%
\SpecialCoor
\uput{2mm}[0](!50
20){$\epsilon=$\psPrintValue[valuewidth=6,fontscale=8]{eps}}
\uput{2mm}[0](!50
18){$\epsilon_z=$\psPrintValue[valuewidth=6,fontscale=8]{epsz}}
\uput{2mm}[0](!50 16){$v_0_x=$\psPrintValue[valuewidth=6,fontscale=8]{v0x}}
\uput{2mm}[0](!50 14){$w_0_y=$\psPrintValue[valuewidth=6,fontscale=8]{w0y}}
\multido{\nn=0+1}{8}{%\uput{2mm}[0](!10 2 2 \nn\space mul add
){$xT=$\psPrintValue[valuewidth=12,fontscale=8]{xT}}%
\parabola[linecolor=Blue1](!x0 z0)(!xT x0 add zT)%
%\parabola[arrowscale=2,arrows=->,linecolor=Blue1,linewidth=0.25pt](!x0 xT
2 div add zT 3 mul 4 div)(!xT x0 add zT)%
\parabola[arrowscale=2,arrows=->,linecolor=Blue1,linewidth=0.25pt](!x0 xT
4 div add zT 7 mul 16 div)(!xT x0 add zT)%
\pscircle*[linecolor=red](!xT x0 add zT){0.5}
\pscustom[linewidth=0.25pt]{%
  \code{
         w0y 0 gt
           {1 0.5 0 setrgbcolor}{0.5 1 0 setrgbcolor}
         ifelse
         xT x0 add zT 1.5 90 w0y wang mul add 90 w0y wang mul sub arcarrow}
}
\pstVerb{v0z epsz mul /v0z exch def
 v0x enminusalphabeta mul w0y alphabeta mul add /v1x exch def
 w0y enminusbeta mul v0x beta mul add /w0y exch def
 v1x /v0x exch def
 xT 2 mul x0 add /x0 exch def
 v0z v0x mul gg div /xT exch def
 v0z dup mul 2 div gg div z0 add /zT exch def }%
}
\end{pspicture}
\end{center}
\end{document}



More information about the PSTricks mailing list