[pstricks] pst-vue3d

Poul Riis Poul.Riis at skolekom.dk
Fri Oct 29 14:22:21 CEST 2010


The code below shows what I want (a sketch of a classical experiment with
two colliding steel balls, one rolling down a track, colliding with the
other ball, initially at rest).
I'm sorry that it's not minimal because I've embedded some raw postscript
code in pst-vue3d. Of course it would be more convenient if there were
some pst-vue3d commands for the semicircles and  the trajectories and the
track.

Two other minor questions:
1) Is there a way to make psPrintValue align things better automatically?
2) The CylindreThreeD command seems to be very slow. Is it possible to
adjust the number of grid lines?

Poul Riis



\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[dvips,svgnames,x11names]{xcolor}
\usepackage{multido}
\usepackage{pst-grad,pst-func}
\usepackage{pst-vue3d}
\usepackage{pstricks-add}
\usepackage[caption=false]{subfig}
\usepackage{graphicx}
\parindent=0pt
\pagestyle{empty}

\newrgbcolor{braun}{0.6 0.1 0.2}

\begin{document}
\psset{unit=1cm, THETA=80, PHI=25, Dobs=750, Decran=25}%
\begin{pspicture}(-5, -5)(5,5)%
\psset{linewidth=0.5pt,CubeColorFaceOne=0.6 0.6 0.6,CubeColorFaceTwo=0.3
0.3 0.3,CubeColorFaceThree=0.3 0.3 0.3,CubeColorFaceFour=0.3 0.3
0.3,CubeColorFaceFive=0.3 0.3 0.3,CubeColorFaceSix=0.3 0.3 0.3}%
%The floor:
\FrameThreeD[normaleLongitude=0,normaleLatitude=90,fillstyle=solid,
fillcolor=Tan2](0,0,0)(-200,-200)(200,200)%
%The legs of the table:
\CubeThreeD[A=1,B=1,C=49](-145,-25,49)%
\CubeThreeD[A=1,B=1,C=49](-145,25,49)%
\CubeThreeD[A=1,B=1,C=49](-5,-25,49)%
\CubeThreeD[A=1,B=1,C=49](-5,25,49)%
%The table:
\CubeThreeD[A=75,B=30,C=2](-75,0,98)%
\AxesThreeD{->}(200)%
%Initializing:
\pstVerb{80 25 750 25 /decran exch def /dobs exch def /PHI exch def /THETA
exch def /costheta THETA cos def /sintheta THETA sin def /cosphi PHI cos
def /sinphi PHI sin def /projfact dobs decran div def 
/moveto3d {/zz exch def /yy exch def /xx exch def xx costheta mul yy
sintheta mul add /qq exch def qq cosphi mul zz sinphi mul add dobs div 1
sub neg projfact mul /nn exch def yy costheta mul xx sintheta mul sub nn
div zz cosphi mul qq sinphi mul sub nn div moveto} def
/lineto3d {/zz exch def /yy exch def /xx exch def xx costheta mul yy
sintheta mul add /qq exch def qq cosphi mul zz sinphi mul add dobs div 1
sub neg projfact mul /nn exch def yy costheta mul xx sintheta mul sub nn
div zz cosphi mul qq sinphi mul sub nn div lineto} def
/hh 100 def /gg 982 def /u1 300 def /hrul 30 def /Lrul 75 def /rk1 0.04
def /rk2 0.03 def /kk hh 2 mul gg div sqrt def /x01 u1 kk mul def /m1 100
def /m2 75 def /R1 m2 m1 m2 add div x01 mul def /R2 m1 m1 m2 add div x01
mul def /rksum rk1 rk2 add def }
\pscustom{\code{%
%/Times-Roman findfont 1 scalefont setfont
%/Helvetica findfont dup %finding the Helvetica font
/Helvetica-ISOLatin1 findfont 0.25 scalefont setfont
/cminpt 72.27 2.54 div def
cminpt cminpt scale
/tekst 15 string def
0.02 setlinewidth
0 0 0 moveto3d 0 200 neg 0 lineto3d stroke
0.4 0.3 0.35 setrgbcolor
%The track:
0.05 setlinewidth
0 0 hh moveto3d  0 0.1 1 {/tt exch def tt Lrul mul neg 0 tt dup mul hrul
mul hh add lineto3d} for stroke
0 1 hh moveto3d  0 0.1 1 {/tt exch def tt Lrul mul neg 1 tt dup mul hrul
mul hh add lineto3d} for stroke
0 1 neg hh moveto3d  0 0.1 1 {/tt exch def tt Lrul mul neg 1 neg tt dup
mul hrul mul hh add lineto3d} for stroke
0.02 setlinewidth
0.9 0.2 0.75 setrgbcolor
%The semicircles:
R2 R1 sub 0 0 moveto3d 5 5 180 {/tt exch def tt cos R1 mul R2 sub neg tt
sin R1 mul neg 0 lineto3d} for stroke 
R2 R2 add 0 0 moveto3d 5 5 180 {/tt exch def tt cos R2 mul R2 add tt sin
R2 mul 0 lineto3d} for stroke
%The trajectories:
1 1 8 {/ipsi exch def ipsi 10 mul /psi exch def /VCM m1 m1 m2 add div u1
mul def /v1x VCM u1 sub psi 2 mul cos mul VCM add def /v1y VCM u1 sub psi
2 mul sin mul def /v2x psi 2 mul cos 1 add VCM mul psi cos rksum mul add
def /v2y psi 2 mul sin VCM mul psi sin rksum mul add def /x1 v1x kk mul
def /y1 v1y kk mul def /x20 psi cos rksum mul def /y20 psi sin rksum mul
def /x2 v2x kk mul x20 add def /y2 v2y kk mul y20 add def 
0.1 ipsi mul 0.99 1 0.1 ipsi mul sub setrgbcolor 0 0 hh moveto3d 1 1 10
{0.1 mul /tt exch def tt x1 mul tt y1 mul tt dup mul 1 sub neg hh mul
lineto3d} for stroke x1 y1 5 neg moveto3d ipsi tekst cvs show 
 0 0 hh moveto3d 1 1 10 {0.1 mul /tt exch def tt x2 mul tt y2 mul tt dup
mul 1 sub neg hh mul lineto3d} for stroke x2 y2 5 neg moveto3d ipsi tekst
cvs show
%Connecting landing points with dashed lines:
[.1 .1] 0 setdash 0.5 0 0 setrgbcolor x1 y1 0 moveto3d x2 y2 0 lineto3d
stroke [] 0 setdash
} for
}}%
\uput{2pt}[0]{0}(5,6){$m_1=$\psPrintValue[valuewidth=4]{m1}\hspace{1.75em}g}
\uput{2pt}[0]{0}(5,5.5){$m_2=$\psPrintValue[valuewidth=4,xShift=4]{m2}\hspace{1.75em}g}
\uput{2pt}[0]{0}(5,5.0){$u_1=$\psPrintValue[valuewidth=4,xShift=4]{u1}\hspace{2em}cm/s}
\uput{2pt}[0]{0}(5,4.5){$h=$\psPrintValue[valuewidth=4,xShift=4]{hh}\hspace{2em}cm}
\end{pspicture}
\end{document}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20101029/49b1417f/attachment-0001.html>


More information about the PSTricks mailing list