diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pstricks-add')
-rw-r--r-- | Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex | 455 |
1 files changed, 195 insertions, 260 deletions
diff --git a/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex b/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex index 0361b9c16d8..46f2e995eaa 100644 --- a/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex +++ b/Master/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex @@ -1,4 +1,4 @@ -%% $Id: pstricks-add.tex 459 2011-02-02 18:32:36Z herbert $ +%% $Id: pstricks-add.tex 552 2011-08-03 18:43:36Z herbert $ %% %% %% This is file `pstricks-add.tex', @@ -31,8 +31,8 @@ \ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi \ifx\PSTmathLoaded\endinput\else \input pst-math \fi % -\def\fileversion{3.51} -\def\filedate{2011/02/02} +\def\fileversion{3.53} +\def\filedate{2011/08/03} \message{`pstricks-add' v\fileversion, \filedate\space (dr,hv)} % \edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax @@ -469,16 +469,16 @@ \psk@ArrowInsidePos\space 1 gt { /Alpha y2 y1 sub x2 x1 sub Atan def /ArrowPos \psk@ArrowInsideOffset\space def - /Length x2 x1 sub y2 y1 sub Pyth def /dArrowPos \psk@ArrowInsidePos\space abs def - { +% /Length x2 x1 sub y2 y1 sub Pyth def + \psk@ArrowInsideNo\space cvi { /ArrowPos ArrowPos dArrowPos add def - ArrowPos Length gt { exit } if +% ArrowPos Length gt { exit } if x1 Alpha cos ArrowPos mul add y1 Alpha sin ArrowPos mul add ArrowInside pop pop - } loop + } repeat }{ /ArrowPos \psk@ArrowInsideOffset\space def /dArrowPos \psk@ArrowInsideNo 1 gt {% @@ -830,30 +830,41 @@ %#1= root name,#2=pscode (optional),#3=metric function,#4=first tick,#5=tick count % Metric function may be a function of x, y (keyword metricFunction) % or a function of x, y, dx, dy, ds requiring incremental build -\addbefore@par{arrows=-,linewidth=\psk@ytickwidth\pslinewidth}% -\use@par% -\pst@killglue%there's a leak that can occur here with ticksize--fixed in recent pstricks.tex -\pst@cntC=\expandafter\csname #1pointcount\endcsname\relax% -\pst@cntb=\pst@cntC\advance\pst@cntb\m@ne\relax% -\pst@cntd=\pst@cntC\advance\pst@cntd\@ne\relax% -\pst@Verb{ % so we can use definitions from tx@Dict in pstricks.pro - /TDict 20 dict def TDict begin % - /Func (#3) cvx def /sarray \the\pst@cntd\space array def % - #2 - \ifPST@metricFunction - 0 1 #1.X length 1 sub { /j ED sarray j % - #1.X j get /x ED #1.Y j get /y ED Func put } for % - \else %build by increments - sarray 0 \PST@metricInitValue\space put % - 1 1 #1.X length 1 sub { /j ED sarray j % - #1.X j 1 sub get /x ED #1.Y j 1 sub get /y ED #1Delta.X j get /dx ED #1Delta.Y j get /dy ED /ds dx dup mul dy dup mul add sqrt def % - Func sarray j 1 sub get add put } for % - \fi %\ifPSTfunctionMetric - /str 10 string def /tmpar [(Metric range: [) () (, ) () (])] def % - tmpar 1 sarray 0 get str cvs put - /str 10 string def - tmpar 3 sarray \the\pst@cntC\space get str cvs put tmpar - tx@NodeDict begin concatstringarray = end % + \addbefore@par{arrows=-,linewidth=\psk@ytickwidth\pslinewidth}% + \use@par% + \pst@killglue%there's a leak that can occur here with ticksize--fixed in recent pstricks.tex + \pst@cntC=\expandafter\csname #1pointcount\endcsname\relax% + \pst@cntb=\pst@cntC\advance\pst@cntb\m@ne\relax% + \pst@cntd=\pst@cntC\advance\pst@cntd\@ne\relax% + \pst@Verb{ % so we can use definitions from tx@Dict in pstricks.pro + /TDict 20 dict def TDict begin % + /Func (#3) cvx def /sarray \the\pst@cntd\space array def % + #2 + \ifPST@metricFunction + 0 1 #1.X length 1 sub { + /j ED sarray j % + #1.X j get /x ED #1.Y j get /y ED Func put + } for % + \else %build by increments + sarray 0 \PST@metricInitValue\space put % + 1 1 #1.X length 1 sub { + /j ED sarray j % + #1.X j 1 sub get + /x ED #1.Y j 1 sub get + /y ED #1Delta.X j get + /dx ED #1Delta.Y j get + /dy ED /ds dx dup mul dy dup mul add sqrt def % + Func sarray j 1 sub get add put + } for % + \fi %\ifPSTfunctionMetric + \ifnum\Pst@Debug>0 + /str 10 string def + /tmpar [(Metric range: [) () (, ) () (])] def % + tmpar 1 sarray 0 get str cvs put + /str 10 string def + tmpar 3 sarray \the\pst@cntC\space get str cvs put tmpar + tx@NodeDict begin concatstringarray = end % + \fi % end debug %compute ticks /nl 0 def /nu \the\pst@cntC\space def /smin sarray 0 get def @@ -863,25 +874,30 @@ /scount smax Os sub Ds div cvi def % /tarray scount 1 add array def % /#1Tick.X scount 1 add array def % -/#1Tick.Y scount 1 add array def % -/#1TickN.X scount 1 add array def % -/#1TickN.Y scount 1 add array def % -0 1 scount { dup Ds mul Os add tarray 3 1 roll put } for %tick positions in tarray -% find the corresponding s values using binary search -0 1 scount { dup tarray exch get /s exch def /j exch def %sought metric value,index -/m nl def /n nu def /k nl nu add 2 div cvi def 20 { s sarray k get lt { % -/n k def /k k m add 2 div cvi def }{ /m k def /nl k def /k k n add 2 div cvi def } ifelse % -n 1 sub m le { /nl m def exit } if } repeat % -sarray n get sarray m get dup 3 1 roll % sm sn sm -sub dup 0 le { pop pop 0 }{%sm sn-sm -exch %sn-sm sm -s sub neg exch div } ifelse % s->(s-sm)/(sn-sm) -dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on stack -#1Delta.Y m 1 add get mul #1.Y m get add #1Tick.Y j 3 -1 roll put % -#1TickN.X j #1Normal.X m 1 add get put #1TickN.Y j #1Normal.Y m 1 add get put % - } for % -/tmpar 2 array def /str 4 string def tmpar 0 (Created data for points #1Tick0..#1Tick) put tmpar 1 scount str cvs put tmpar tx@NodeDict begin concatstringarray = % - end end }% end pst@Verb + /#1Tick.Y scount 1 add array def % + /#1TickN.X scount 1 add array def % + /#1TickN.Y scount 1 add array def % + 0 1 scount { dup Ds mul Os add tarray 3 1 roll put } for %tick positions in tarray + % find the corresponding s values using binary search + 0 1 scount { + dup tarray exch get /s exch def /j exch def %sought metric value,index + /m nl def /n nu def /k nl nu add 2 div cvi def 20 { s sarray k get lt { % + /n k def /k k m add 2 div cvi def }{ /m k def /nl k def /k k n add 2 div cvi def } ifelse % + n 1 sub m le { /nl m def exit } if } repeat % + sarray n get sarray m get dup 3 1 roll % sm sn sm + sub dup 0 le { pop pop 0 }{%sm sn-sm + exch %sn-sm sm + s sub neg exch div } ifelse % s->(s-sm)/(sn-sm) + dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on stack + #1Delta.Y m 1 add get mul #1.Y m get add #1Tick.Y j 3 -1 roll put % + #1TickN.X j #1Normal.X m 1 add get put #1TickN.Y j #1Normal.Y m 1 add get put % + } for % + \ifnum\Pst@Debug>0 + /tmpar 2 array def + /str 4 string def tmpar 0 (Created data for points #1Tick0..#1Tick) put + tmpar 1 scount str cvs put tmpar tx@NodeDict begin concatstringarray = end + \fi + end }% end pst@Verb %Draw ticks \multido{\iA=#4+1}{#5}{% \pnode(! TDict begin \iA\space scount gt @@ -1712,7 +1728,7 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta % \define@key[psset]{pstricks-add}{chartColor}{\pst@expandafter\psk@@chartColor{#1}\@nil} \def\psk@@chartColor#1#2\@nil{% - \ifx#1r\def\psk@chartColor{2}\else + \ifx#1r\def\psk@chartColor{2}\else% \ifx#1c\def\psk@chartColor{380}\else\def\psk@chartColor{0}\fi\fi} \psset[pstricks-add]{chartColor=gray}% gray, color, randomColor % @@ -1721,21 +1737,21 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \define@key[psset]{pstricks-add}{chartStackDepth}{\pssetylength\pst@chartStackDepth{#1}} \define@key[psset]{pstricks-add}{chartStackWidth}{\pssetxlength\pst@chartStackWidth{#1}} \define@key[psset]{pstricks-add}{chartHeight}{\pssetylength\pst@chartHeight{#1}} -\psset[pstricks-add]{chartSep=10pt,chartStack=0,chartStackDepth=2cm,chartStackWidth=2cm, +\psset[pstricks-add]{chartSep=10pt,chartStack=0,chartStackDepth=2cm,chartStackWidth=2cm,% chartHeight=5mm} % \define@key[psset]{pstricks-add}{userColor}{% - \chart@Toggle=0 - \def\chart@option{#1} - \ifx\chart@option\@empty\@chartUserColorfalse - \else - \@chartUserColortrue - \expandafter\psk@@chartUserColor#1,,\@nil + \chart@Toggle=0\relax% + \def\chart@option{#1}% + \ifx\chart@option\@empty\@chartUserColorfalse% + \else% + \@chartUserColortrue% + \expandafter\psk@@chartUserColor#1,,\@nil% \fi} \def\psk@@chartUserColor#1,#2,#3\@nil{% \advance\chart@Toggle by \@ne% \xglobal\colorlet{chartFillColor\the\chart@Toggle}{#1}% - \def\chart@option{#2} + \def\chart@option{#2}% \ifx\chart@option\@empty\else\psk@@chartUserColor#2,#3,\@nil\fi}% \psset[pstricks-add]{userColor={}} @@ -1743,7 +1759,7 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \define@key[psset]{pstricks-add}{chartNodeO}{\def\psk@chartNodeO{#1}} \psset[pstricks-add]{chartNodeI=0.75,chartNodeO=1.5} % -\def\psChart{\def\pst@par{}\pst@object{psChart}} +\def\psChart{\pst@object{psChart}} \def\psChart@i#1#2#3{% % #1:values #2:separated charts % #3 radius->pie; max height->histogram @@ -1753,18 +1769,18 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \begingroup% \def\psk@chartValues{#1}% \def\psk@chartSepValues{#2}% only valid for a pie chart - \pst@dimm=\z@ % sum of all entries (for a pie) - \pst@cnta=1 % number of entries - \pst@dimn=\z@ % greatest entry + \pst@dimm=\z@% sum of all entries (for a pie) + \pst@cnta=1\relax% number of entries + \pst@dimn=\z@% greatest entry \psforeach{\chart@tempA}{#1}{% - \global\advance\pst@cnta by \@ne % % no of entries - \global\advance\pst@dimm by \chart@tempA\p@ % % sum of all entries + \global\advance\pst@cnta by \@ne% % no of entries + \global\advance\pst@dimm by \chart@tempA\p@% % sum of all entries \pst@dima=\chart@tempA\p@% - \ifdim\pst@dima>\pst@dimn \global\pst@dimn=\pst@dima\fi% + \ifdim\pst@dima>\pst@dimn\global\pst@dimn=\pst@dima\fi% }% \addbefore@par{dimen=outer}% \begin@SpecialObj% - \ifnum\psk@chartColor>0\relax + \ifnum\psk@chartColor>0\relax% \chart@ColorStep=400\p@\else\chart@ColorStep=\p@\fi % the "numerical color" \divide\chart@ColorStep by \pst@cnta% % step =1/no or 400/no \chart@ColorIndex=\psk@chartColor\p@% % the start color (gray or wave) @@ -1777,8 +1793,8 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \def\pscs@pie{% \degrees[\pst@number\pst@dimm]% % instead of 360 degrees \def\chart@alpha{0}% - \pst@dimm=\z@\pst@dimn=\z@\pst@dimo=\z@\pst@cnta=0\relax - \global\chart@Toggle=1\relax + \pst@dimm=\z@\pst@dimn=\z@\pst@dimo=\z@\pst@cnta=0\relax% + \global\chart@Toggle=1\relax% \ifpsshadow% create shadow first \psforeach{\chart@tempA}{\psk@chartValues}{% \global\advance\pst@dimm by \chart@tempA\p@% @@ -1786,9 +1802,9 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \global\advance\pst@cnta by \@ne% \pst@dimo=0.5\pst@dimn\advance\pst@dimo by 0.5\pst@dimm% half angle of the chart \global\@chartSepfalse% - \if$\psk@chartSepValues$\else - \psforeach{\chart@tempC}{\psk@chartSepValues}{\ifnum\chart@tempC=\the\pst@cnta\relax \global\@chartSeptrue\fi}% - \fi + \if$\psk@chartSepValues$\else% + \psforeach{\chart@tempC}{\psk@chartSepValues}{\ifnum\chart@tempC=\the\pst@cnta\relax\global\@chartSeptrue\fi}% + \fi% \if@chartSep% \pswedge(\psk@chartSep\p@;\pst@number\pst@dimo){\pst@chartRadius}{\pst@number\pst@dimn}{\pst@number\pst@dimm}% \else% @@ -1804,7 +1820,7 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \global\advance\pst@dimm by \chart@tempA\p@% \global\advance\pst@dimn by \chart@alpha\p@% \def\pst@tempB{\pst@number\chart@ColorIndex}% - \psDEBUG[psChart:wave:color]{\pst@tempB}% +% \psDEBUG[psChart:wave:color]{\pst@tempB}% \global\advance\pst@cnta by \@ne% \if@chartUserColor\else% \def\chart@FillColor{chartFillColor\the\pst@cnta}% @@ -1813,10 +1829,10 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \else\xglobal\definecolor{\chart@FillColor}{gray}{\pst@tempB}\fi% \fi% \pst@dimo=0.5\pst@dimn\advance\pst@dimo by 0.5\pst@dimm% half angle of the chart - \global\@chartSepfalse - \if$\psk@chartSepValues$\else - \psForeach{\chart@tempC}{\psk@chartSepValues}{\ifnum\chart@tempC=\the\pst@cnta\relax \global\@chartSeptrue\fi}% - \fi + \global\@chartSepfalse% + \if$\psk@chartSepValues$\else% + \psForeach{\chart@tempC}{\psk@chartSepValues}{\ifnum\chart@tempC=\the\pst@cnta\relax\global\@chartSeptrue\fi}% + \fi% \if@chartSep% \pswedge[linecolor={chartFillColor\the\pst@cnta},fillstyle=solid,fillcolor={chartFillColor\the\pst@cnta}]% (\psk@chartSep\p@;\pst@number\pst@dimo){\pst@chartRadius}{\pst@number\pst@dimn}{\pst@number\pst@dimm}% @@ -1838,13 +1854,14 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \fi% \global\let\chart@alpha\chart@tempA% \global\advance\chart@Toggle by \@ne% - \ifnum\chart@Toggle<3\relax + \ifnum\chart@Toggle<3\relax% \global\advance\chart@ColorIndex by 2\chart@ColorStep% \else% \global\chart@Toggle=0% \global\advance\chart@ColorIndex by -\chart@ColorStep% \fi% }% end foreach + \ignorespaces% } % \def\pscs@histogram{% @@ -1987,9 +2004,17 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \global\advance\chart@ColorIndex by 1pt } % +\define@key[psset]{pstricks-add}{cancelType}{\pst@expandafter\psk@@cancelType{#1xx}\@nil} +\def\psk@@cancelType#1#2\@nil{% + \ifx\relax#1\relax\def\psk@cancelType{2}\else% x + \ifx#1b\def\psk@cancelType{2}\else% \ + \ifx#1s\def\psk@cancelType{1}\else% / + \def\psk@cancelType{0}\fi\fi\fi}% x every other + +\psset[pstricks-add]{cancelType=}% x, crossing \def\psCancel{\def\pst@par{}\pst@object{psCancel}}% by Stefano Baroni 2008-06-21 -\def\psCancel@i{\pst@makebox\psCancel@ii} -\def\psCancel@ii{% +\def\psCancel@i{\pst@makebox\psCancel@iii} +\def\psCancel@iii{% \begingroup \solid@star \use@par @@ -2017,10 +2042,14 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta a sub /x2 ED a add /x1 ED pop pop % delete arc values - x1 y1 moveto - x2 y2 lineto - x2 y1 moveto - x1 y2 lineto + \ifnum\psk@cancelType<\tw@ % / or x + x1 y1 moveto + x2 y2 lineto + \fi% + \ifnum\psk@cancelType=\@ne\else % \ or x + x2 y1 moveto + x1 y2 lineto + \fi \fi }% \def\pst@linetype{2}% @@ -2037,6 +2066,7 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \newcount\psVectorCtr \define@boolkey[psset]{pstricks-add}[Pst@]{markAngle}[true]{} \psset[pstricks-add]{markAngle=false} +% \newpsstyle{psMarkAngleStyle}{arrows=->,arrowsize=4pt} \newpsstyle{psMarkAngleLineStyle}{linestyle=dotted,arrows=-} % @@ -2054,8 +2084,8 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \def\psVector{\pst@object{psVector}} \def\psVector@i(#1){% \pst@killglue% - \pst@getcoor{#1}\pst@tempCoor% \addbefore@par{arrows=->,arrowsize=6pt}% + \pst@getcoor{#1}\pst@tempCoor% \begingroup \use@par% \rput(! cp.X cp.Y ){% @@ -2073,191 +2103,96 @@ dup #1Delta.X m 1 add get mul #1.X m get add #1Tick.X j 3 -1 roll put % s on sta \pst@number\psyunit div cp.Y add /cp.Y exch def \pst@number\psxunit div cp.X add /cp.X exch def %end }% - \ignorespaces% -} + \ignorespaces} % -\def\psCircleTangents(#1){\@ifnextchar({\psCircleTangents@i(#1)}{\psCircleTangents@ii(#1)}} -\def\psCircleTangents@i(#1)(#2)#3{% point circle radius - \pst@killglue% - \begingroup% - \pst@getcoor{#1}\pst@CoorA% point - \pst@getcoor{#2}\pst@CoorB% circle - \pst@getlength{#3}\pst@LengthA% radius - \pst@Verb{ - 50 dict begin - \pst@CoorA \pst@number\psyunit div /Y1 ED % point - \pst@number\psxunit div /X1 ED - \pst@CoorB \pst@number\psyunit div /Y2 ED % circle - \pst@number\psxunit div /X2 ED - Y2 Y1 sub X2 X1 sub atan /Alpha ED - X1 Y1 X2 Y2 Pyth2 /distance ED - /m Alpha tan def - \pst@LengthA \pst@number\psrunit div /r1 ED -% we have the intersectionpoint of the inner tangents - /tangentAngle r1 distance div asin def - /negAngle Alpha tangentAngle sub def - /m2 negAngle tan def - /b Y1 m2 X1 mul sub def -% - /Z Y1 m2 X1 mul sub Y2 sub def - /k1 2 X2 mul 2 m2 mul Z mul sub 1 m2 dup mul add div neg def - k1 neg 2 div /x1 ED - /y1 m2 x1 mul b add def - /xS m X1 mul Y1 sub x1 m div add y1 add m 1 m div add div def - /yS m xS X1 sub mul Y1 add def - /x2 x1 2 xS x1 sub mul add def - /y2 y1 2 yS y1 sub mul add def -% - tx@NodeDict begin - { x1 \pst@number\psxunit mul y1 \pst@number\psyunit mul } false - /N@CircleT1 10 { InitPnode } NewNode - { x2 \pst@number\psxunit mul y2 \pst@number\psyunit mul } false - /N@CircleT2 10 { InitPnode } NewNode - end - end - }% - \endgroup% +\define@key[psset]{pstricks-add}{basename}{\def\psk@basename{#1}}% +\psset[pstricks-add]{basename=}% +% +\def\psCircleTangents{\pst@object{psCircleTangents}} +\def\psCircleTangents@i(#1){\@ifnextchar({\psCircleTangents@ii(#1)}{\psCircleTangents@iii(#1)}}% +\def\psCircleTangents@ii(#1)(#2)#3{% (viewpoint) (circle) {radius} + \pst@killglue% + \begingroup% + \pst@getlength{#3}\pst@LengthA% + \addbefore@par{basename=CircleT}% + \use@par% + \edef\@cmd{\noexpand\psEllipseTangentsN(#2)(! \pst@LengthA dup % + \pst@number\psxunit div exch \pst@number\psyunit div )(#1){\psk@basename}}% + \@cmd% + \endgroup% \ignorespaces% -} -\def\psCircleTangents@ii(#1)#2(#3)#4{% two circles +}% +\def\psCircleTangents@iii(#1)#2(#3)#4{% two circles--- (Cntr1){radius1}(Cntr2){radius2} \pst@killglue% \begingroup% - \pst@getcoor{#1}\pst@CoorA% - \pst@getlength{#2}\pst@LengthA% - \pst@getcoor{#3}\pst@CoorB% - \pst@getlength{#4}\pst@LengthB% - \pst@Verb{ - 50 dict begin - \pst@CoorA \pst@number\psyunit div /Y1 ED - \pst@number\psxunit div /X1 ED - \pst@CoorB \pst@number\psyunit div /Y2 ED - \pst@number\psxunit div /X2 ED - Y2 Y1 sub X2 X1 sub atan /Alpha ED - X1 Y1 X2 Y2 Pyth2 /distance ED - /m Alpha tan def - \pst@LengthA \pst@number\psrunit div /r1 ED - \pst@LengthB \pst@number\psrunit div /r2 ED - distance r1 r1 r2 add div mul /d1 ED - d1 Alpha sin mul Y1 add /YQI ED - d1 Alpha cos mul X1 add /XQI ED - tx@NodeDict begin - { XQI \pst@number\psxunit mul YQI \pst@number\psyunit mul } false - /N@CircleTC1 10 { InitPnode } NewNode - end - /d2 distance d1 sub def -% we have the intersectionpoint of the inner tangents - /tangentAngle r2 d2 div asin def - /negAngle Alpha tangentAngle sub def - /m2 negAngle tan def - /b YQI m2 XQI mul sub def -% - /Z YQI m2 XQI mul sub Y2 sub def - /k1 2 X2 mul 2 m2 mul Z mul sub 1 m2 dup mul add div neg def - k1 neg 2 div /x1I ED - /y1I m2 x1I mul b add def - /xS m XQI mul YQI sub x1I m div add y1I add m 1 m div add div def - /yS m xS XQI sub mul YQI add def - /x2I x1I 2 xS x1I sub mul add def - /y2I y1I 2 yS y1I sub mul add def -% - /Z YQI m2 XQI mul sub Y1 sub def - /k1 2 X1 mul 2 m2 mul Z mul sub 1 m2 dup mul add div neg def - k1 neg 2 div /x1aI ED - /y1aI m2 x1aI mul b add def - /xS m XQI mul YQI sub x1aI m div add y1aI add m 1 m div add div def - /yS m xS XQI sub mul YQI add def - /x2aI x1aI 2 xS x1aI sub mul add def - /y2aI y1aI 2 yS y1aI sub mul add def - tx@NodeDict begin - { x1aI \pst@number\psxunit mul y1aI \pst@number\psyunit mul } false - /N@CircleTI1 10 { InitPnode } NewNode - { x1I \pst@number\psxunit mul y1I \pst@number\psyunit mul } false - /N@CircleTI2 10 { InitPnode } NewNode - { x2aI \pst@number\psxunit mul y2aI \pst@number\psyunit mul } false - /N@CircleTI3 10 { InitPnode } NewNode - { x2I \pst@number\psxunit mul y2I \pst@number\psyunit mul } false - /N@CircleTI4 10 { InitPnode } NewNode - end -% - /d1 distance r2 r1 div 1 sub div def - /tangentAngle r1 d1 div asin def - /negAngle Alpha tangentAngle sub def - /m2 negAngle tan def - /YQO Y1 d1 Alpha sin mul sub def - /XQO X1 d1 Alpha cos mul sub def - tx@NodeDict begin - { XQO \pst@number\psxunit mul YQO \pst@number\psyunit mul } false - /N@CircleTC2 10 { InitPnode } NewNode - end - % we have the new central point - /b YQO m2 XQO mul sub def - /Z YQO m2 XQO mul sub Y1 sub def - /k1 2 X1 mul 2 m2 mul Z mul sub 1 m2 dup mul add div neg def - k1 neg 2 div /x1O ED - /y1O m2 x1O mul b add def - /xS m XQO mul YQO sub x1O m div add y1O add m 1 m div add div def - /yS m xS XQO sub mul YQO add def - /x2O x1O 2 xS x1O sub mul add def - /y2O y1O 2 yS y1O sub mul add def -% - /Z YQO m2 XQO mul sub Y2 sub def - /k1 2 X2 mul 2 m2 mul Z mul sub 1 m2 dup mul add div neg def - k1 neg 2 div /x1aO ED - /y1aO m2 x1aO mul b add def - /xS m XQO mul YQO sub x1aO m div add y1aO add m 1 m div add div def - /yS m xS XQO sub mul YQO add def - /x2aO x1aO 2 xS x1aO sub mul add def - /y2aO y1aO 2 yS y1aO sub mul add def -% - tx@NodeDict begin - { x1aO \pst@number\psxunit mul y1aO \pst@number\psyunit mul } false - /N@CircleTO1 10 { InitPnode } NewNode - { x1O \pst@number\psxunit mul y1O \pst@number\psyunit mul } false - /N@CircleTO2 10 { InitPnode } NewNode - { x2aO \pst@number\psxunit mul y2aO \pst@number\psyunit mul } false - /N@CircleTO3 10 { InitPnode } NewNode - { x2O \pst@number\psxunit mul y2O \pst@number\psyunit mul } false - /N@CircleTO4 10 { InitPnode } NewNode - end - end - }% + \pst@getlength{#2}\pst@LengthA% radius1 + \pst@getlength{#4}\pst@LengthB% radius2 + \addbefore@par{basename=CircleT}% + \use@par% + \psLCNodeVar(#1)(#3)(! \pst@LengthA \pst@number\psrunit div dup \pst@LengthB % + \pst@number\psrunit div % r1 r1 r2 on stack + 3 copy add div /tti ED sub dup 0 eq % r1 r1-r2 on stack + { pop pop /ttx 1000 def }{ div dup abs 1000 gt % r1/(r1-r2) on stack + { 0 gt { ttx 1000 def }{ ttx -1000 def } ifelse}{ /ttx ED } ifelse } ifelse % + 1 tti sub tti )% 1-tti tti on stack + {\psk@basename C1}% + % tti=r1/(r1+r2), ttx=r1/(r1-r2) + \psLCNodeVar(#1)(#3)(! 1 ttx sub ttx ){\psk@basename C2}% outside crossing pt + \expandafter\psCircleTangents@ii\expandafter(\psk@basename C1)(#1){#2}% + \pnode(CircleT1){\psk@basename I1}\pnode(CircleT2){\psk@basename I3}% + \expandafter\psCircleTangents@ii\expandafter(\psk@basename C1)(#3){#4}% + \pnode(CircleT1){\psk@basename I2}\pnode(CircleT2){\psk@basename I4}% + % external tangents + \expandafter\psCircleTangents@ii\expandafter(\psk@basename C2)(#1){#2}% + \pnode(CircleT1){\psk@basename O2}\pnode(CircleT2){\psk@basename O4}% + \expandafter\psCircleTangents@ii\expandafter(\psk@basename C2)(#3){#4}% + \pnode(CircleT1){\psk@basename O1}\pnode(CircleT2){\psk@basename O3}% \endgroup% \ignorespaces% -} +}% % -\def\psEllipseTangents(#1,#2)(#3,#4)(#5,#6){% (xe,ye)(a,b)(xP,yP) % no optional arguments +\def\psEllipseTangents{\pst@object{psEllipseTangents}} +\def\psEllipseTangents@i(#1)(#2)(#3){% (Center)(axes)(viewpoint) + \pst@killglue{% + \use@par% only one parameter matters---psk@basename + \ifx\psk@basename\@empty \def\psk@basename{EllipseT}\fi % + \edef\@cmd{\noexpand\psEllipseTangentsN(#1)(#2)(#3){\psk@basename}}% + \@cmd}\ignorespaces}% +% +\def\psEllipseTangentsN(#1)(#2)(#3)#4{% (xe,ye)(a,b)(xP,yP){basename} % no optional arguments \pst@killglue% + \pnode(#1){E@Cntr}% center of ellipse + \pnode(#2){@@TMP}% semimajor, semiminor + \pnode(#3){@@@TMP}% viewpt + \pst@getcoor{#3}\my@tempC% external viewpoint + \AtoB(E@Cntr)(@@@TMP){@TMP}% center to viewpoint + \ifnum\Pst@Debug>0 + \shownode(E@Cntr)% + \shownode(@TMP)% + \shownode(@@@TMP)% + \fi% \pnode(! - /A #3 def - /B #4 def - /A2 A dup mul def /B2 B dup mul def - #5 #1 sub /Xp ED - #6 #2 sub /Yp ED - A2 B2 mul Xp mul - Yp 4 exp A 6 exp mul - B2 Yp dup mul mul A 6 exp mul sub - B2 Xp dup mul mul Yp dup mul mul A 4 exp mul add sqrt add - Yp dup mul A2 mul B2 Xp dup mul mul add div /Xt ED % the x3 value - Xt dup mul A2 div neg 1 add sqrt B mul /Yt ED - Yt Yp sub Xt Xp sub mul 0 gt { % P is in 1st or 3rd quadrant - Xt dup mul A2 div neg 1 add sqrt neg B mul /Yt ED } if - Xt #1 add Yt #2 add ) {EllipseT1}% - \pnode(! - /A #3 def - /B #4 def + \psGetNodeCenter{@@TMP}\space + /B @@TMP.y def% semiminor + /A @@TMP.x def% semimajor /A2 A dup mul def /B2 B dup mul def - #5 #1 sub /Xp ED - #6 #2 sub /Yp ED - A2 B2 mul Xp mul - Yp 4 exp A 6 exp mul - B2 Yp dup mul mul A 6 exp mul sub - B2 Xp dup mul mul Yp dup mul mul A 4 exp mul add sqrt sub - Yp dup mul A2 mul B2 Xp dup mul mul add div /Xt ED % the x3 value - Xt dup mul A2 div neg 1 add sqrt B mul /Yt ED - Yt Yp sub Xt Xp sub mul 0 lt { % P is in 2nd or 4th quadrant - Xt dup mul A2 div neg 1 add sqrt neg B mul /Yt ED } if - Xt #1 add Yt #2 add ) {EllipseT2}% - \ignorespaces}% + /C2 B A div dup mul def + \psGetNodeCenter{@TMP}\space + /Xp @TMP.x def /Yp @TMP.y def % center to viewpoint + /Xp2 Xp dup mul def /Yp2 Yp dup mul def + \psGetNodeCenter{E@Cntr}\space + /Xc E@Cntr.x def /Yc E@Cntr.y def + /R Xp2 A2 sub C2 mul Yp2 add Sqrt def % R=Sqrt{(Xp2-A2) C2 + Yp2} + /Q C2 Xp2 mul Yp2 add def % C2 Xp2 + Yp2 + /Xta B2 Xp mul A Yp R mul mul sub Q div def + /Yta Yp Xp R mul A div add B2 mul Q div def + /Xtb B2 Xp mul A Yp R mul mul add Q div def + /Ytb Yp Xp R mul A div sub B2 mul Q div def + 0 Xta Yp mul Yta Xp mul sub gt % swap a, b + { /A Xta def /B Yta def /Xta Xtb def /Yta Ytb def /Xtb A def /Ytb B def } if + Xta Xc add Yta Yc add ) {#42}% + \pnode(! Xtb Xc add Ytb Yc add ) {#41}% + \ignorespaces}% % \define@key[psset]{pstricks-add}{rotate}{\def\psk@rotate{#1 }} \psset[pstricks-add]{rotate=0} |