[pstricks] pst-3dplot

Richard Hensh henshric at msu.edu
Tue Mar 15 23:01:23 CET 2005


I've been trying to create several objects that can accept calculated
coordinates (in 3d) similar to their 2-dimensional counterparts. For
example, something along the lines of

\pstLine(!0 0 0)(! 1 1 2 dup mul) --> \pstThreeDLine(0,0,0)(1,1,4)

\pstDot(! 1 1 2 dup mul)  --> \pstThreeDDot(1,1,4)

etc.

I don't understand the code well enough to devise anything better than the
code at the bottom of this message but the subsequent syntax is not
consistent with the 2-dimensional counterparts (and is, in fact, awkward).
In addition, the code must be recreated with each new (old) object that I
would like to use in this way. Can anyone suggest anything better?

Regards
Ricky

%%The following works but is not ideal.

\def\pstLine{\pst at object{pstLine}}
\def\pstLine at i(#1,#2,#3)(#4,#5,#6){%
    \pst at killglue
    \begingroup
    \psset{linecolor=orange,linewidth=1.5pt,arrowscale=1.25}%
    \use at par
    \pstLine at ii(#1,#2,#3)(#4,#5,#6)
    \endgroup
}
\def\pstLine at ii(#1,#2,#3)(#4,#5,#6){%
    \addto at pscode{/xA@ {#1} def /yA@ {#2} def /zA@ {#3} def %
    /xB@ {#4} def /yB@ {#5} def /zB@ {#6} def %
    /p {dup 1 sub neg Div} bind def %
    /Alpha \psk at ThreeDplot@Alpha def %
    /Beta \psk at ThreeDplot@Beta def
    }
    \psline[linecolor=orange,linewidth=1.5pt]{->}%
    (!xA@ neg Alpha cos mul yA@ Alpha sin mul add %
    xA@ Alpha sin mul yA@ Alpha cos mul add neg Beta sin %
    mul zA@ Beta cos mul add)(!xB@ neg Alpha cos mul yB@ Alpha sin mul add %
    xB@ Alpha sin mul yB@ Alpha cos mul add neg Beta sin %
    mul zB@ Beta cos mul add)
}






More information about the PSTricks mailing list