\documentclass{article}
\usepackage{pst-solides3d,pst-node,multido}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\makeatletter

\def\psPoint{\def\pst@par{}\pst@object{psPoint}}
\def\psPoint@i(#1)#2{{% coordonnées cartésiennes
  \begin@ClosedObj
\pnode(!
    \tx@optionssolides
    SolidesDict begin
    #1
   3dto2d cm_1 exch cm_1 exch
   end){#2}%
   \end@ClosedObj
  }\ignorespaces%
}

\makeatother
\def\grille{% quadrillage du plan Oxy
\multido{\ix=-5+1}{11}{%
    \psPoint(\ix\space -5 0){A}
    \psPoint(\ix\space 5 0){B}
    \psline(A)(B)}
\multido{\iy=-5+1}{11}{%
    \psPoint(-5 \iy\space 0){A}
    \psPoint(5 \iy\space 0){B}
    \psline(A)(B)}
    \psPoint(0 0 0){O}
    \psPoint(5 0 0){X}
    \psPoint(0 5 0){Y}
    \psPoint(0 0 8){Z}
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(X)
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Y)
    \psline[arrowsize=0.3,arrowinset=0.2,linecolor=blue]{->}(O)(Z)
    \uput[r](X){\textcolor{blue}{$x$}}\uput[u](Y){\textcolor{blue}{$y$}}%
    \uput[r](Z){\textcolor{blue}{$z$}}\uput[u](O){\textcolor{blue}{$O$}}}
\pagestyle{empty}
\date{8 octobre 2\,006}
\author{JPV \& ML}
\title{tests}

\begin{document}
\maketitle


\begin{center}

\psset{lightsrc=1e3 5 20,SphericalCoor=true,viewpoint=50 20 10,Decran=50}
\begin{pspicture}(-6,-2)(6,8)
\psframe(-6,-2)(6,8)
\grille
\codejps{
% solide 1
    0 1.5 6 newcylindre
    dup (jaune) outputcolors
% solide 2
    4 3 2 newcylindricalring
   {0 0 1 translatepoint3d} solidtransform
    dup (orange) outputcolors
% fusion
    solidfuz
    drawsolid**}
\psSolid[object=cube,a=1,color=cyan](0,3.5,2.5)
\end{pspicture}
\end{center}

\begin{center}

\psset{lightsrc=1e3 5 20,SphericalCoor=true,viewpoint=50 20 30,Decran=50}
\begin{pspicture}(-6,-2)(6,8)
\psframe(-6,-2)(6,8)
\renewcommand\Section{
   /m {90 4 div} bind def
   /Scos {m cos 2 m mul cos add 3 m mul cos add} bind def
   /Z0 {h 4 div} bind def
   /c {Z0 Scos div} bind def
   /Z1 {Z0 c m cos mul add} bind def
   /Z2 {Z1 c m 2 mul cos mul add} bind def
%  /Z3 {Z2 c m 3 mul cos mul add} bind def Z3= h/2
   /R1 {R c m sin mul sub} bind def
   /R2 {R1 c m 2 mul sin mul sub} bind def
   /R3 {R2 c m 3 mul sin mul sub} bind def
   0 R h 4 div neg % 1
   0 R h 4 div % 2
   0 R1 Z1 % 3
   0 R2 Z2 % 4
   0 R3 h 2 div % 5
   0 r h 2 div  % 6
   0 r h 2 div neg  % 7
   0 R3 h 2 div neg % 8
   0 R2 Z2 neg % 9
   0 R1 Z1 neg % 10
   }
\grille
\codejps{
/roue12 {
% solide 1
    2 1 1 newcylindricalring
     {90 0 90 rotateOpoint3d} solidtransform
     {3 4 2 translatepoint3d} solidtransform
     dup (Gray) outputcolors
% solide 2
    2 1 1 newcylindricalring
    {90 0 90 rotateOpoint3d} solidtransform
   {-3 4 2 translatepoint3d} solidtransform
    dup (Gray) outputcolors
% fusion
    solidfuz } def
/roue34 {
% solide 3
    1.5 1 1 newcylindricalring
    {90 0 100 rotateOpoint3d} solidtransform
   {3 -4 1.5 translatepoint3d} solidtransform
    dup (orange) outputcolors
% solide 4
    1.5 1 1 newcylindricalring
   {90 0 100 rotateOpoint3d} solidtransform
   {-3 -4 1.5 translatepoint3d} solidtransform
    dup (orange) outputcolors
% fusion
    solidfuz } def
roue12 roue34 solidfuz
    drawsolid**}
\end{pspicture}
\end{center}
\newpage
\begin{center}
\psset{lightsrc=100 50 20,SphericalCoor=true,viewpoint=25 20 30,Decran=25,unit=0.5}
\begin{pspicture}(-6,-2)(6,8)
%\psframe(-6,-2)(6,8)
\renewcommand\Section{
   /m {90 4 div} bind def
   /Scos {m cos 2 m mul cos add 3 m mul cos add} bind def
   /Z0 {h 4 div} bind def
   /c {Z0 Scos div} bind def
   /Z1 {Z0 c m cos mul add} bind def
   /Z2 {Z1 c m 2 mul cos mul add} bind def
%  /Z3 {Z2 c m 3 mul cos mul add} bind def Z3= h/2
   /R1 {R c m sin mul sub} bind def
   /R2 {R1 c m 2 mul sin mul sub} bind def
   /R3 {R2 c m 3 mul sin mul sub} bind def
   0 R h 4 div neg % 1
   0 R h 4 div % 2
   0 R1 Z1 % 3
   0 R2 Z2 % 4
   0 R3 h 2 div % 5
   0 r h 2 div  % 6
   0 r h 2 div neg  % 7
   0 R3 h 2 div neg % 8
   0 R2 Z2 neg % 9
   0 R1 Z1 neg % 10
   }
\grille
\codejps{
/roue12 {
% solide 1
    2 1 1 newcylindricalring
     {90 0 90 rotateOpoint3d} solidtransform
     {3 4 2 translatepoint3d} solidtransform
     dup (White) outputcolors
% solide 2
    2 1 1 newcylindricalring
    {90 0 90 rotateOpoint3d} solidtransform
   {-3 4 2 translatepoint3d} solidtransform
    dup (White) outputcolors
% fusion
    solidfuz } def
/axe12{
0 0.1 6  newcylindre
{90 0 90 rotateOpoint3d} solidtransform
{-3 4 2  translatepoint3d} solidtransform
dup (White) outputcolors
} def
/roue12axes {
roue12 axe12 solidfuz } def
/roue34 {
% solide 3
    1.5 1 1 newcylindricalring
    {90 0 110 rotateOpoint3d} solidtransform
   {3 -4 1.5 translatepoint3d} solidtransform
    dup (White) outputcolors
% solide 4
    1.5 1 1 newcylindricalring
   {90 0 110 rotateOpoint3d} solidtransform
   {-3 -4 1.5 translatepoint3d} solidtransform
    dup (White) outputcolors
% fusion
    solidfuz } def
/axe34{
0 0.1 6  newcylindre
{90 0 90 rotateOpoint3d} solidtransform
{-3 -4 1.5  translatepoint3d} solidtransform
dup (White) outputcolors
} def
/roue34axes34 {
roue34 axe34 solidfuz } def
/roues {roue34axes34 roue12axes solidfuz} def
/chassis {
0 1 8  newcylindre
{100 0 0 rotateOpoint3d} solidtransform
{0 4 2.5  translatepoint3d} solidtransform
dup (White) outputcolors
} def
roues chassis solidfuz
    drawsolid**}
\end{pspicture}
\end{center}
\end{document}
