3

first post here, I'm a Tikz starter. I'm currently preparing a presentation, and I'd like to be able to draw colored spheres, like in page 5 of this article.

enter image description here

Basically, I have to color a sphere by dividing it into three equal pieces (along the meridians), except for two antipodal tips of the sphere (see figure for a better explanation), that I draw differently.

Understanding how to describe this coloration through a function of polar angles is straightforward enough, just some basic algebra. Basically, I'd define a function of the polar angles that is defined piecewise (no smooth fading of a color into another, let's keep it simple) and use it to color the sphere.

I've searched in the documentation about how to implement this, but so far no luck, so I've come to ask you.

Next, I'd like to draw graphics like in page 15 of this other article, by drawing many balls with different orientations.

enter image description here

It would be very useful to then have a function that draws a colored sphere at a given center, that also takes some angles as input for rotating it.

  • 1
    Why do you want to use a 2D drawing package to draw 3D stuff? You cannot rotate a 3D object in the way you want. You can fake 3D, but if you rotate it, you have to start the fakery from scratch because there is no 3D object but at most the illusion of one. Solution: don't insist on a 2D solution to a 3D problem. – cfr Oct 1 '16 at 21:46
  • I've seen people doing crazy things (yes, also 3d things!) by using Tikz. As I've understood, there is a package like 3d-tikz (or such) that should help in doing 3d drawings, but I can't find documentation for it. If you have any suggestion for an alternative, I'd be glad to hear it. – Salvatore Baldino Oct 1 '16 at 21:54
  • I've used the package myself. It does the calculations required to fake 3D for you. It is a nice package. But it is not going to give you 3D in the sense of constructing a 3D object which you can rotate. If you rotate it (if you change perspective), you have to recode because things are now drawn in the wrong order. tikz-3dplot I think you mean. I don't know much about 3D. Asymptote definitely does understand 3D but there are plenty of other options. – cfr Oct 1 '16 at 22:03
  • You would be better of with either PSTricks or Asymptote or Metapost for this. TikZ doesn't understand 3D view. – percusse Oct 1 '16 at 22:47
6

Since @cfr mentioned tikz-3dplot, this is a quick example.

\documentclass[border=9,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{}
\begin{document}

\tdplotsetmaincoords{40}{0}
\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,fill opacity=1]
    \tdplotsphericalsurfaceplot[parametricfill]{72}{36}{2}{black}{
        120*floor(\tdplotphi/120)
    }{}{}{}
\end{tikzpicture}

\end{document}
  • I'll select this as the answer, even if I've followed previous advices and found an alternative program. Thank you all. – Salvatore Baldino Oct 7 '16 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.