[pstricks] Fwd: Bezier curve

MLuque5130 at aol.com MLuque5130 at aol.com
Tue Aug 16 20:39:39 CEST 2005


Ravi Gautam wrote:

>I need to draw Bezier curves in three dimension. Please let me know if 
>any body know the commands for it. Also is there any command similar 
>to parametric plot for 3D.  

One can also easily draw 3D curves: parametric, bezier or other with the the 
package pst-3D. In this package, there is a macro (tx at ProjThreeD), writen by 
Timothy Van Zandt (the author),  which, as far i can see, have been never used. 
This macro allows to  put a point in 3 coordinates. To increase the 
possibility, i have use it in association with  pst-node in the aim to make a command 
simpler to use.
 
Let me give three basic examples :

\documentclass[12pt,a4paper]{article}
\usepackage{pst-plot,pst-3d,pst-node}%
% Manuel Luque
% mluque5130 at aol.com
\SpecialCoor
\makeatletter
\let\ProjThreeD\tx at ProjThreeD
\makeatother

\makeatletter
\def\pnodeThreeD(#1,#2,#3)#4{%
      \pst at Verb{%
          \psk at embedangle
          \psk at viewpoint
          \psk at viewangle
          \tx at SetMatrixThreeD}
  \pnode(!#1 #2 #3 \ProjThreeD){#4}}
\makeatother
\psset{plotpoints=720}
\pagestyle{empty}
\begin{document}
\begin{pspicture}(-5,-8)(5,10)
\def\vx{1}\def\vy{0.5}\def\vz{0.5}
\psset{viewpoint={\vx} {\vy} {\vz}}%
\pnodeThreeD(0,0,12){Z}
\pstVerb{%
    /vX \vx\space def
    /vY \vy\space def
    /vZ \vz\space def
    /Start vX neg vY atan def
     Start 270 ge {/Start Start 360 sub def} if
    /Stop 180 Start add def
    /Radius 3 def
    /H 9 def}
\parametricplot{Start}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    0
    \ProjThreeD}
\pnodeThreeD(Start cos Radius mul,Start sin Radius mul,0){A1}
\pnodeThreeD(Stop cos Radius mul,Stop sin Radius mul,0){A2}
\pnodeThreeD(Start cos Radius mul,Start sin Radius mul,H){B1}
\pnodeThreeD(Stop cos Radius mul,Stop sin Radius mul,H){B2}
\parametricplot[fillstyle=hlines,hatchcolor=green]{0}{360}{%
    Radius t cos mul
    Radius t sin mul
    H
    \ProjThreeD}
\parametricplot[linecolor=cyan,linestyle=dashed]{0}{1440}{%
    Radius t cos mul
    Radius t sin mul
    t 7 mul 1440 div
    \ProjThreeD}
\parametricplot[linecolor=blue]{0}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    t 7 mul 1440 div
    \ProjThreeD}
\multido{\iA=360+360}{4}{%
\parametricplot[linecolor=blue]{Start}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    t \iA\space add 7 mul 1440 div
    \ProjThreeD}}
\psline(A1)(B1)
\psline(A2)(B2)
\pnodeThreeD(0,0,H){H}
\uput[180](Z){$z$}
\psline[linecolor=red]{->}(H)(Z)
\psdot[linecolor=red](H)
\end{pspicture}

\begin{pspicture}(-5,-8)(5,10)
\def\vx{1}\def\vy{0.5}\def\vz{0.5}
\psset{viewpoint={\vx} {\vy} {\vz}}%
\pnodeThreeD(0,0,0){O}
\pnodeThreeD(0,0,10){Z}
\pnodeThreeD(7,0,0){X}
\pnodeThreeD(0,7,0){Y}
\psline{->}(O)(X)
\psline{->}(O)(Z)
\psline{->}(O)(Y)
\uput[180](Z){$z$}
\uput[0](X){$x$}
\uput[0](Y){$y$}
\pnodeThreeD(4,0,0){A}
\pnodeThreeD(4,4,0){B}
\pnodeThreeD(4,4,4){C}
\pnodeThreeD(0,0,4){D}
\psbezier[linewidth=1mm,linecolor=red,showpoints=true]{|->}(A)(B)(C)(D)
\end{pspicture}


\begin{pspicture}(-5,-8)(5,10)
\def\vx{1}\def\vy{0.5}\def\vz{0.5}
\psset{viewpoint={\vx} {\vy} {\vz}}%
\pnodeThreeD(0,0,10){Z}
\uput[180](Z){$z$}
\pstVerb{%
    /vX \vx\space def
    /vY \vy\space def
    /vZ \vz\space def
    /Start vX neg vY atan def
     Start 270 ge {/Start Start 360 sub def} if
    /Stop 180 Start add def
    /Radius 3 def
    /H 9 def}
\parametricplot{Start}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    0
    \ProjThreeD}
\pnodeThreeD(Start cos Radius mul,Start sin Radius mul,0){A1}
\pnodeThreeD(Stop cos Radius mul,Stop sin Radius mul,0){A2}
\pnodeThreeD(Start cos Radius mul,Start sin Radius mul,H){B1}
\pnodeThreeD(Stop cos Radius mul,Stop sin Radius mul,H){B2}
\parametricplot{0}{360}{%
    Radius t cos mul
    Radius t sin mul
    H
    \ProjThreeD}
\parametricplot[linecolor=red]{0}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    t 7 mul 720 div
    \ProjThreeD}
\multido{\iA=0+360}{5}{%
\pscustom[linecolor=blue]{%
\parametricplot{Start}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    t \iA\space add 7 mul 1440 div
    \ProjThreeD}%
\parametricplot{Stop}{Start}{%
    Radius t cos mul
    Radius t sin mul
    t \iA\space add 7 mul 1440 div 1 add
    \ProjThreeD}
\fill[fillstyle=solid,fillcolor=yellow]}}%
%
\multido{\iA=0+360}{5}{%
\parametricplot[linecolor=red]{Start}{Stop}{%
    Radius t cos mul
    Radius t sin mul
    t \iA\space add 7 mul 1440 div
    \ProjThreeD}}%
\psline(A1)(B1)
\psline(A2)(B2)
\pnodeThreeD(0,0,H){H}
\pnodeThreeD(0,0,10){Z}
\uput[180](Z){$z$}
\psline[linecolor=red]{->}(H)(Z)
\psdot[linecolor=red](H)
\end{pspicture}
\end{document}

Manuel




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20050816/f4fb7bfd/attachment.html 


More information about the PSTricks mailing list