diff options
author | Karl Berry <karl@freefriends.org> | 2007-08-20 00:09:19 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-08-20 00:09:19 +0000 |
commit | 5d15743e4114b97824c00eaa61eab488ba52b233 (patch) | |
tree | 96349eb65512f2fefd8a6d78c33462fa24834d0f /Master/texmf-dist/dvips/pst-3dplot | |
parent | 56c0da12a9fba35882b8b7073eb809804ebf1ee8 (diff) |
pst-3dplot 1.75 (18aug07)
git-svn-id: svn://tug.org/texlive/trunk@4766 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/dvips/pst-3dplot')
-rw-r--r-- | Master/texmf-dist/dvips/pst-3dplot/pst-3dplot.pro | 322 |
1 files changed, 300 insertions, 22 deletions
diff --git a/Master/texmf-dist/dvips/pst-3dplot/pst-3dplot.pro b/Master/texmf-dist/dvips/pst-3dplot/pst-3dplot.pro index 30b2d62eece..12f52ad1443 100644 --- a/Master/texmf-dist/dvips/pst-3dplot/pst-3dplot.pro +++ b/Master/texmf-dist/dvips/pst-3dplot/pst-3dplot.pro @@ -15,7 +15,7 @@ %% `pst-3dplot' is a PSTricks package to draw 3d curves and graphical objects %% %% -%% version 0.23 / 2006-01-18 Herbert Voss <voss _at_ PSTricks.de> +%% version 0.23 / 2007-08-18 Herbert Voss <voss _at_ PSTricks.de> % /tx@3DPlotDict 50 dict def tx@3DPlotDict begin @@ -30,10 +30,20 @@ tx@3DPlotDict begin % /ConvertTo2D { RotatePoint -% /x2D y x Alpha sin mul sub def % |/_ co system -% /y2D z x Alpha cos mul sub def - /x2D x leftHanded not { neg } if Alpha cos mul y Alpha sin mul add def - /y2D x leftHanded { neg } if Alpha sin mul y Alpha cos mul add neg Beta sin mul z Beta cos mul add def + 1 { % dummy loop, will run only 1 time + coorType 0 le { % the default | + /x2D x leftHanded not { neg } if Alpha cos mul y Alpha sin mul add def % /\ co system + /y2D x leftHanded { neg } if Alpha sin mul y Alpha cos mul add neg Beta sin mul z Beta cos mul add def + exit } if + coorType 1 le { + /x2D y x Alpha 90 sub sin mul sub def % |/_ co system, no shortened x axis + /y2D z x Alpha 90 sub cos mul sub def + exit } if + coorType 2 le { % coorType |/_ with a 1/sqrt(2) shortend x-axis and 135 degrees + /x2D y x 0.5 mul sub def + /y2D z x 0.5 mul sub def + exit } if + } repeat } def % /Conv3D2D { /z ED /y ED /x ED ConvertTo2D x2D y2D } def @@ -46,10 +56,11 @@ tx@3DPlotDict begin /x { Radius longitude cos mul latitude cos mul } def /y { Radius longitude sin mul latitude cos mul } def } def +% /ConvCylToCartesian { % r phi h -> x y z - 3 1 roll % r phi h + 3 1 roll % h r phi /Phi ED - /Radius ED % h->z + /Radius ED % h->z on stack Radius Phi cos mul exch % x z Radius Phi sin mul exch % x y z } def @@ -74,19 +85,18 @@ tx@3DPlotDict begin } repeat } def % +% /CalcCoordinates {% from pst-vue3d formulesTroisD Xi 28.45 mul Yi 28.45 mul } def % pour la 3D conventionnelle -/DScreen 1 def -/Dobs 0 def /formulesTroisD{% /xObservateur x Sin1 mul neg y Cos1 mul add def /yObservateur x Cos1Sin2 mul neg y Sin1Sin2 mul sub z Cos2 mul add def /zObservateur x neg Cos1Cos2 mul y Sin1Cos2 mul sub z Sin2 mul sub def - /Xi xObservateur mul zObservateur Div def - /Yi yObservateur mul zObservateur Div def + /Xi xObservateur zObservateur Div def + /Yi yObservateur zObservateur Div def } def % /RotatePointXYZ{% Mxx are defined in the TeX file @@ -123,9 +133,11 @@ tx@3DPlotDict begin /RotatePoint { RotSequence cvx exec } def % /VecNorm { 0 exch { dup mul add } forall sqrt } def +% /UnitVec { % on stack is [a]; returns a vector with [a][a]/|a|=1 dup VecNorm /norm ED { norm div } forall 3 array astore } def +% /AxB { % on the stack are the two vectors [a][b] aload pop /b3 ED /b2 ED /b1 ED aload pop /a3 ED /a2 ED /a1 ED @@ -133,11 +145,13 @@ tx@3DPlotDict begin a3 b1 mul a1 b3 mul sub a1 b2 mul a2 b1 mul sub 3 array astore } def +% /AaddB { % on the stack are the two vectors [a][b] aload pop /b3 ED /b2 ED /b1 ED aload pop /a3 ED /a2 ED /a1 ED a1 b1 add a2 b2 add a3 b3 add 3 array astore } def +% /AmulC { % on stack is [a] and c; returns [a] mul c /factor ED { factor mul } forall 3 array astore } def % @@ -149,22 +163,18 @@ tx@3DPlotDict begin z mul exch y mul add exch x mul add 4 1 roll z mul exch y mul add exch x mul add - exch} def + exch } def % /setColorLight { % expects 7 values on stack C M Y K xL yL zL % les rayons de lumière - /zLight exch def - /yLight exch def - /xLight exch def + xLight dup mul yLight dup mul zLight dup mul add add sqrt /NormeLight ED % the color values /K exch def /Yellow exch def /Magenta exch def /Cyan exch def -% - /NormeLight {xLight dup mul yLight dup mul zLight dup mul add add - sqrt} bind def } def +% /facetteSphere { newpath /Xpoint Rsphere theta cos mul phi cos mul CX add def @@ -202,10 +212,8 @@ tx@3DPlotDict begin closepath } def % -/condition { PSfacette 0 ge } def /MaillageSphere { -% on stack must be -% x y z Radius increment C M Y K x y zLIGHT +% on stack must be x y z Radius increment C M Y K setColorLight /increment exch def /Rsphere exch def @@ -213,6 +221,7 @@ tx@3DPlotDict begin /CY exch def /CX exch def /StartTheta 0 def + /condition { PSfacetteSphere 0 ge } def -90 increment 90 increment sub {% /phi exch def StartTheta increment 360 StartTheta add increment sub {% @@ -226,7 +235,8 @@ tx@3DPlotDict begin /nYfacette Ypoint CY sub def /nZfacette Zpoint CZ sub def % test de visibilité - /PSfacette vX nXfacette mul + /PSfacetteSphere + vX nXfacette mul vY nYfacette mul add vZ nZfacette mul add def @@ -252,6 +262,78 @@ tx@3DPlotDict begin } for } def % +%---------------------- Cylinder --------------------------- +% +/PlanCoupeCylinder { % + /TableauxPoints [ + 0 1 359 { + /phi exch def + [ Radius phi Height ConvCyl2d ] % on décrit le cercle + } for + ] def + newpath + TableauxPoints 0 get aload pop moveto + 1 1 359 { TableauxPoints exch get aload pop lineto } for + closepath +} def +% +/facetteCylinder { % + newpath + Radius phi currentHeight ConvCyl2d moveto + phi 1 phi dAngle add { % loop variable on stack + Radius exch currentHeight ConvCyl2d lineto + } for + phi dAngle add -1 phi { % fill dHeight + Radius exch currentHeight dHeight add ConvCyl2d lineto + } for + closepath + } def % facette +% +/MaillageCylinder { % on stack true or false for saving values + { setColorLight % expects 4 values on stack C M Y K + /dHeight ED /dAngle ED /Height ED /Radius ED + /CZ ED /CY ED /CX ED } if +% + 0 dHeight Height dHeight sub { + /currentHeight ED + 0 dAngle 360 dAngle sub { + /phi ED +% Normal vector of the center + /nXfacetteCylinder Radius phi dAngle 2 div add cos mul CX add def + /nYfacetteCylinder Radius phi dAngle 2 div add sin mul CY add def + /nZfacetteCylinder currentHeight dHeight 2 div add CZ add def + /NormeN + nXfacetteCylinder dup mul + nYfacetteCylinder dup mul + nZfacetteCylinder dup mul + add add sqrt def + NormeN 0 eq { /NormeN 1e-10 def } if +% test de visibilité + /PSfacetteCylinder + vX nXfacetteCylinder mul + vY nYfacetteCylinder mul add + vZ nZfacetteCylinder mul add def + condition { + facetteCylinder + /cosV + 1 xLight nXfacetteCylinder mul + yLight nYfacetteCylinder mul + zLight nZfacetteCylinder mul + add add + NormeLight NormeN mul div sub def + Cyan Magenta Yellow K + cosV mul 4 1 roll cosV mul 4 1 roll + cosV dup mul mul 4 1 roll cosV dup mul mul 4 1 roll + setcmykcolor fill + 0 setgray + facetteCylinder % drawing the segments + stroke + } if + } for + } for +} def +% +%------------------------ Cylinder type II ----------------------- % /MoveTo { Conv3D2D moveto } def /LineTo { Conv3D2D lineto } def @@ -299,4 +381,200 @@ tx@3DPlotDict begin stroke } def % +%---------------------- Box --------------------------- +% +/PlanCoupeBox { % x y z + /TableauxPoints [ + [ CX CY CZ Height add ConvBox2d ] % top or bottom + [ CX CY Depth add CZ Height add ConvBox2d ] + [ CX Width add CY Depth add CZ Height add ConvBox2d ] + [ CX Width add CY CZ Height add ConvBox2d ] + [ CX CY CZ Height add ConvBox2d ] % bottom + ] def + newpath + TableauxPoints 0 get aload pop moveto + 0 1 3 { + TableauxPoints exch get aload pop + lineto } for + closepath +} def +% +/facetteBox { % + newpath + dup + 1 eq { % back + CX CY CZ ConvBox2d moveto + CX CY CZ Height add ConvBox2d lineto + CX Width add CY CZ Height add ConvBox2d lineto + CX Width add CY CZ ConvBox2d lineto + CX CY CZ ConvBox2d lineto + } if + dup + 2 eq { % right + CX CY CZ ConvBox2d moveto + CX CY CZ Height add ConvBox2d lineto + CX CY Depth add CZ Height add ConvBox2d lineto + CX CY Depth add CZ ConvBox2d lineto + CX CY CZ ConvBox2d lineto + } if + dup + 3 eq { % left + CX Width add CY CZ ConvBox2d moveto + CX Width add CY Depth add CZ ConvBox2d lineto + CX Width add CY Depth add CZ Height add ConvBox2d lineto + CX Width add CY CZ Height add ConvBox2d lineto + CX Width add CY CZ ConvBox2d lineto + } if + 4 eq { % front + CX CY Depth add CZ ConvBox2d moveto + CX CY Depth add CZ Height add ConvBox2d lineto + CX Width add CY Depth add CZ Height add ConvBox2d lineto + CX Width add CY Depth add CZ ConvBox2d lineto + CX CY Depth add CZ ConvBox2d lineto + } if + closepath + } def % facette +% +/TestPlane { % on stack x y z of the plane center and # of plane + /nZfacetteBox ED /nYfacetteBox ED /nXfacetteBox ED + /Plane ED + /NormeN + nXfacetteBox dup mul + nYfacetteBox dup mul + nZfacetteBox dup mul + add add sqrt def + NormeN 0 eq { /NormeN 1e-10 def } if +% test de visibilité + /PSfacetteBox + vX nXfacetteBox mul + vY nYfacetteBox mul add + vZ nZfacetteBox mul add def + condition { + Plane facetteBox + /cosV + 1 xLight nXfacetteBox mul + yLight nYfacetteBox mul + zLight nZfacetteBox mul + add add + NormeLight NormeN mul div sub def + Cyan Magenta Yellow K + cosV mul 4 1 roll cosV mul 4 1 roll + cosV dup mul mul 4 1 roll cosV dup mul mul 4 1 roll + setcmykcolor fill + 0 setgray + Plane facetteBox % drawing the segments + stroke + } if +} def +% +/MaillageBox { % on stack true or false for saving values + { setColorLight % expects 4 values on stack C M Y K + /Depth ED /Height ED /Width ED + /CZ ED /CY ED /CX ED } if +% +% Normal vector of the center + /PlaneSet [ + [ Width 2 div CX add CY Height 2 div CZ add ] % normal back + [ CX Depth 2 div CY add Height 2 div CZ add ] % normal right + [ Width CX add Depth 2 div CY add Height 2 div CZ add ] % normal left + [ Width 2 div CX add Depth CY add Height 2 div CZ add ] % normal front + ] def + PlaneSequence length 0 eq { % user defined? + Alpha abs cvi 360 mod /iAlpha ED + iAlpha 90 lt { [ 1 2 3 4 ] + }{ iAlpha 180 lt { [ 2 4 1 3 ] + }{ iAlpha 270 lt { [ 3 4 1 2 ] }{ [ 3 1 4 2] } ifelse } ifelse } ifelse + }{ PlaneSequence } ifelse + { dup 1 sub PlaneSet exch get aload pop TestPlane } forall +} def +% +%--------------------------- Paraboloid ----------------------------- +/PlanCoupeParaboloid { + /Z height store + /V {Z sqrt} bind def + /TableauxPoints [ + 0 1 359 { + /U exch def [ U U Z V calculate2DPoint ] % on décrit le cercle + } for + ] def + newpath + TableauxPoints 0 get aload pop moveto + 0 1 359 { + /compteur exch def + TableauxPoints compteur get aload pop + lineto } for + closepath +} def +% +/facetteParaboloid{ + newpath + U U Z V calculate2DPoint moveto + U 1 U increment add {% + /U1 exch def + U1 U1 Z V calculate2DPoint lineto + } for + Z pas10 Z pas add pas10 add{ + /Z1 exch def + /V {Z1 sqrt} bind def + U1 U1 Z1 V calculate2DPoint lineto + } for + U increment add -1 U {% + /U2 exch def + U2 U2 Z pas add V calculate2DPoint lineto + } for + Z pas add pas10 sub pas10 neg Z pas10 sub { + /Z2 exch def + /V Z2 abs sqrt def + U U Z2 V calculate2DPoint lineto + } for + closepath +} def % facette +% +/MaillageParaboloid { + % on stack true or false for saving values + { setColorLight % expects 7 values on stack C M Y K xL yL zL +% /CZ ED /CY ED /CX ED + } if + 0 pas height pas sub {% + /Z ED + /V Z sqrt def + 0 increment 360 increment sub {% + /U exch def +% Centre de la facette + /Ucentre U increment 2 div add def + /Vcentre Z pas 2 div add sqrt def +% normale à la facette + /nXfacetteParaboloid 2 Vcentre dup mul mul Ucentre cos mul radius mul def + /nYfacetteParaboloid 2 Vcentre dup mul mul Ucentre sin mul radius mul def + /nZfacetteParaboloid Vcentre neg radius dup mul mul def + /NormeN { + nXfacetteParaboloid dup mul + nYfacetteParaboloid dup mul + nZfacetteParaboloid dup mul + add add sqrt} bind def + NormeN 0 eq {/NormeN 1e-10 def} if +% test de visibilité + /PSfacetteParaboloid vX nXfacetteParaboloid mul + vY nYfacetteParaboloid mul add + vZ nZfacetteParaboloid mul add def + condition { + facetteParaboloid + /cosV 1 xLight nXfacetteParaboloid mul + yLight nYfacetteParaboloid mul + zLight nZfacetteParaboloid mul + add add + NormeLight + NormeN mul div sub def + Cyan Magenta Yellow K + cosV mul 4 1 roll cosV mul 4 1 roll cosV dup mul mul 4 1 roll cosV dup mul mul 4 1 roll + setcmykcolor fill + 0 setgray + facetteParaboloid + stroke + } if + } for + } for +} def +% +% end |