1

I have been using pst-solides3d to generate surfaces and then importing them to Adobe Illustrator to turn them into a gradient mesh. The procedure can be time consuming if I want to be very precise, and even there are only 4 vertices, I would have to manually adjusting their positions and all 8 handles, and then pick up the color from the original surface, quite laborious. See my post here

My question is: Is it possible for pst-solides3d to implement an automation of the above procedure?

1 Answer 1

1

This is not really an answer to your question, so you may want to wait for other answers which your questions about pst-solides3d.

This answer is to build up the knowledge base and to address your last sentence in the linked question https://graphicdesign.stackexchange.com/questions/42022/transforming-3rd-party-discrete-gradient-mesh-to-ais-smooth-gradient-mesh, namely

Alternatively, if there is a better way to do this, I would also like to know it. Thank you.

From what I understand, you want

  • a smooth gradient (=smooth shading)
  • quadrilateral patches
  • vector graphics

This specific problem can be solved by means of pgfplots. I have used a Möbius strip since I have neither your data files nor the parametrization of your surface:

  1. bilinear patches. First-order resolution of the patch boundary, bilinear color interpolation:

enter image description here

\documentclass{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=1.9}

\usepgfplotslibrary{patchplots}

\begin{document}

\begin{tikzpicture}
    \begin{axis}
    \addplot3[
        surf, 
        samples=25, samples y=25,
        variable=r,   domain=-1:1,
        variable y=a, domain y=0:2*pi,
        trig format plots=rad,
        shader=faceted interp, 
        patch type=bilinear,
    ]
        ({cos(a) * (1+r/2 * cos(a/2))},
         {sin(a) * (1+r/2 * cos(a/2))},
         {r/2 * sin(a/2)});
    \end{axis}
\end{tikzpicture}
\end{document}
  1. bicubic patches. Third order resolution of the patch boundary (and less patches), bilinear color gradient:

enter image description here

\documentclass{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=1.9}

\usepgfplotslibrary{patchplots}

\begin{document}

\begin{tikzpicture}
    \begin{axis}
    \addplot3[
        surf, 
        samples=10, samples y=10,
        variable=r,   domain=-1:1,
        variable y=a, domain y=0:2*pi,
        trig format plots=rad,
        shader=faceted interp, 
        patch type sampling, 
        patch type=bicubic,
    ]
        ({cos(a) * (1+r/2 * cos(a/2))},
         {sin(a) * (1+r/2 * cos(a/2))},
         {r/2 * sin(a/2)});
    \end{axis}
\end{tikzpicture}
\end{document}

Both examples need the patchplots library, and both have a parameterized surface depending on r and a. The parameterization is from wikipedia. Note that trig format plots=rad switches the default config from degrees to radians.

Bicubic patches are quite difficult to generate: they have 16 points for each patch. The key patch type sampling simplifies this considerably -- if the input data is sampled from a function anyway. If you have table input, you will have to provide the patches on your own.

The colors are taken from a colormap: the smallest z coordinate is mapped to the first color of the colormap, the largest z coordinate is mapped to the last color of the colormap. Everything in-between is mapped linearly into the colormap. Further reading: keys point meta (choose which scalar value to use) and colormap (which colormap), also related are "Surface plots with explicit color".

Related question: Creating Bezier surfaces using procedural graphics

4
  • Thanks for your comprehensive answer. Im wondering if I could use a different colormap (other than the height function)?
    – Troy Woo
    Nov 16, 2014 at 14:00
  • Sure. In this case, the simplest case would be some math expression using point meta=<expression>. The actual colors can be configured using colormap (details in the manual pgfplots.sourceforge.net) Nov 16, 2014 at 14:05
  • Thank you. I have also another question, is it possible to remove the internal lines and only leave the boundary line of the surface? I fear not, since it involves Boolean operations.
    – Troy Woo
    Nov 16, 2014 at 14:09
  • This is impossible by means of pgfplots. You may consider using mesh/interior colormap which allows to choose a different colormap for the "other side" of the patches Nov 16, 2014 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .