diff options
Diffstat (limited to 'Master/texmf-dist/dvips/pstricks/pstricks.pro')
-rw-r--r-- | Master/texmf-dist/dvips/pstricks/pstricks.pro | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/Master/texmf-dist/dvips/pstricks/pstricks.pro b/Master/texmf-dist/dvips/pstricks/pstricks.pro index 8c67d1cb7da..3418879b649 100644 --- a/Master/texmf-dist/dvips/pstricks/pstricks.pro +++ b/Master/texmf-dist/dvips/pstricks/pstricks.pro @@ -1,6 +1,6 @@ %! % PostScript prologue for pstricks.tex. -% Version 1.00, 2005/09/18 +% Version 1.01, 2006/01/11 % For distribution, see pstricks.tex. % /tx@Dict 200 dict def tx@Dict begin @@ -14,7 +14,8 @@ /T /translate load def /TMatrix { } def /RAngle { 0 } def -/Atan { /atan load stopped { pop pop 0 } if } def +/Sqrt { dup 0 lt { pop 0 } { sqrt } ifelse } def% return 0 for negative arguments +/Atan { /atan load stopped { pop pop 0 } if } def% return 0 if atan not known /ATAN1 {neg -1 atan 180 sub } def % atan(x) (only one parameter) /Div { dup 0 eq { pop } { div } ifelse } def % control the division /NET { neg exch neg exch T } def % change coordinate system to the negative one @@ -24,8 +25,8 @@ /Pi 3.14159265359 def /TwoPi 6.28318530718 def /Euler 2.71828182846 def -/RadtoDeg { 180 mul Pi div } def % convert from radian to degrees -/DegtoRad { Pi mul 180 div } def % viceversa +/RadtoDeg { 180 mul Pi div } bind def % convert from radian to degrees +/DegtoRad { Pi mul 180 div } bind def % viceversa %----------------- hv end--------------------------- /PathLength@ { /z z y y1 sub x x1 sub Pyth add def /y1 y def /x1 x def } def /PathLength { flattenpath /z 0 def @@ -291,10 +292,11 @@ exch r a PtoC y add exch x add exch b pop pop pop pop a e d CLW 8 div c mul neg d } def /Ellipse { /mtrx CM def T scale 0 0 1 5 3 roll arc mtrx setmatrix } def % -/ArcAdjust { +/ArcAdjust { %%%% Vincent Guirardel % given a target length (targetLength) and an initial angle (angle0) [in the stack], % let M(angle0)=(rx*cos(angle0),ry*sin(angle0))=(x0,y0). -% This computes an angle t such that (x0,y0) is at distance targetLength from the point M(t)=(rx*cos(t),ry*sin(t)). +% This computes an angle t such that (x0,y0) is at distance +% targetLength from the point M(t)=(rx*cos(t),ry*sin(t)). % NOTE: this an absolute angle, it does not have to be added or substracted to angle0 % contrary to TvZ's code. % To achieve, this, one iterates the following process: start with some angle t, @@ -309,46 +311,54 @@ mul neg d } def % Input stack: 1: target length 2: initial angle % variables used : rx, ry, d (=add/sub) % - /targetLength ED /angle0 ED - /x0 rx angle0 cos mul def - /y0 ry angle0 sin mul def -% we are looking for an angle t such that (x0,y0) is at distance targetLength from the point M(t)=(rx*cos(t),ry*sin(t))) + /targetLength ED /angle0 ED + /x0 rx angle0 cos mul def + /y0 ry angle0 sin mul def +% we are looking for an angle t such that (x0,y0) is at distance targetLength +% from the point M(t)=(rx*cos(t),ry*sin(t))) %initialisation of angle (using 1st order approx = TvZ's code) - targetLength 57.2958 mul - angle0 sin rx mul dup mul - angle0 cos ry mul dup mul - add sqrt div + targetLength 57.2958 mul + angle0 sin rx mul dup mul + angle0 cos ry mul dup mul + add sqrt div % if initialisation angle is two large (more than 90 degrees) set it to 90 degrees -% (if the ellipse is very curved at the point where we draw the arrow, the value can be much more than 360 degrees !) +% (if the ellipse is very curved at the point where we draw the arrow, % +% the value can be much more than 360 degrees !) % this should avoid going on the wrong side (more than 180 degrees) or go near % a bad attractive point (at 180 degrees) - dup 90 ge { pop 90 } if - angle0 exch d + dup 90 ge { pop 90 } if + angle0 exch d % add or sub % maximum number of times to iterate the iterative procedure: - 30 -% iterative procedure: takes an angle t on top of stack, computes a better angle (an put it on top of stack) - { dup +% iterative procedure: takes an angle t on top of stack, computes a +% better angle (and put it on top of stack) + 30 { dup % compute distance D between (x0,y0) and M(t) - dup cos rx mul x0 sub dup mul exch sin ry mul y0 sub dup mul add sqrt + dup cos rx mul x0 sub dup mul exch sin ry mul y0 sub dup mul add sqrt % if D almost equals targetLength, we stop - dup targetLength sub abs 1e-5 le { pop exit } if + dup targetLength sub abs 1e-5 le { pop exit } if % stack now contains D t % compute the point M(t') at distance targetLength of (x0,y0) on the semi-line [(x0,y0) M(t)]: % M(t')= ( (x(t)-x0)*targetLength/d+x0 , (y(t)-y0)*targetLength/d+y0 ) - exch dup cos rx mul x0 sub exch sin ry mul y0 sub + exch dup cos rx mul x0 sub exch sin ry mul y0 sub % stack contains: y(t)-y0, x(t)-x0, d - 2 index Div targetLength mul y0 add ry Div exch - 2 index Div targetLength mul x0 add rx Div + 2 index Div targetLength mul y0 add ry Div exch + 2 index Div targetLength mul x0 add rx Div % stack contains x(t')/rx , y(t')/ry , d % now compute t', and remove D from stack - atan exch pop - } repeat -% we don't look at what happened... in particular, if targetLength is greater than the diameter of the ellipse... + atan exch pop + } repeat +% we don't look at what happened... in particular, if targetLength is greater +% than the diameter of the ellipse... % the final angle will be around /angle0 + 180. maybe we should treat this pathological case... -%after iteration, stack contains an angle t such that M(t) is the tail of the arrow +% after iteration, stack contains an angle t such that M(t) is the tail of the arrow % to give back the result as a an angle relative to angle0 we could add the following line: % angle0 sub 0 exch d % +% begin bug fix 2006-01-11 +% we want to adjust the new angle t' by a multiple of 360 so that | t'-angle0 | <= 180 +%(we don't want to make the ellipse turn more or less than it should)... +dup angle0 sub dup abs 180 gt { 180 add 360 div floor 360 mul sub } { pop } ifelse +% end bug fix } def % /EllipticArcArrow { |