3

I would like do draw some sphericals using the package 3dplot. Does anybody know how to draw spericals with different diameter and postition in a coordinate system like that one?

\documentclass[a4paper, 12pt,]{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}

\usepackage{graphicx}
\usepackage{epstopdf}

\usepackage{tikz, tikz-3dplot}

\begin{document}

  \tdplotsetmaincoords{60}{130}

  \begin{tikzpicture}[scale=4,tdplot_main_coords]

    \coordinate  (O)  at  (0,0,0);

    \draw[thick,->]  (0,0,0)  --  (1,0,0)  node[anchor=north  east]{$x$};
    \draw[thick,->]  (0,0,0)  --  (0,1,0)  node[anchor=north  west]{$y$};
    \draw[thick,->]  (0,0,0)  --  (0,0,1)  node[anchor=south]{$z$};

  \end{tikzpicture}

\end{document}

Edit:

Here is some more code I wrote. I would like to put a sphere at each corner to draw a crystal lattice.

\documentclass[a4paper, 12pt,]{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}

\usepackage{graphicx}
\usepackage{epstopdf}

\usepackage{tikz, tikz-3dplot}

\begin{document}

  \tdplotsetmaincoords{60}{130}

  \begin{tikzpicture}[scale=4,tdplot_main_coords]

    \coordinate  (O)  at  (0,0,0);

    \draw[thick,->]  (0,0,0)  --  (1,0,0)  node[anchor=north  east]{$x$};
    \draw[thick,->]  (0,0,0)  --  (0,1,0)  node[anchor=north  west]{$y$};
    \draw[thick,->]  (0,0,0)  --  (0,0,1)  node[anchor=south]{$z$};

    \tdplotsetcoord{P1}{.8}{30}{90}
    \tdplotsetcoord{P2}{.8}{30}{30}
    \tdplotsetcoord{P3}{.8}{30}{330}
    \tdplotsetcoord{P4}{.8}{30}{270}
    \tdplotsetcoord{P5}{.8}{30}{210}
    \tdplotsetcoord{P6}{.8}{30}{150}

    \draw[color=blue] (P1)--(P2)--(P3)--(P4)--(P5)--(P6)--cycle;
    \draw[color=blue] (P1xy)--(P2xy)--(P3xy)--(P4xy)--(P5xy)--(P6xy)--cycle;
    \draw[color=blue] (P1xy)--(P1);
    \draw[color=blue] (P2xy)--(P2);
    \draw[color=blue] (P3xy)--(P3);
    \draw[color=blue] (P4xy)--(P4);
    \draw[color=blue] (P5xy)--(P5);
    \draw[color=blue] (P6xy)--(P6);

  \end{tikzpicture}

\end{document}
3
  • 1
    Can you make your question clearer, how you want the shapes arranged, etc? Maybe you could post some more code you already have? What 'sphericals' are you referring to?
    – Count Zero
    Apr 18, 2013 at 9:59
  • By "sphericals", do you mean "spheres"?
    – jub0bs
    Apr 18, 2013 at 12:00
  • I have revised my question a little bit and added more code.
    – Froop
    Apr 19, 2013 at 8:49

2 Answers 2

4

One way to do it is to use \pgfdeclareradialshading{sphere}:

\pgfdeclareradialshading{sphere}{\pgfpoint{0.5cm}{0.5cm}}
{   
    rgb(0cm)=(1,1,1);
    rgb(0.7cm)=(0.8,0.8,0.8); 
    rgb(1cm)=(0.6,0.6,0.6); 
    rgb(1.05cm)=(0.6,0.6,0.6)
 }
\pgfuseshading{sphere}

which can create something like this:

enter image description here

To read more, have a look at pgf manual 83.2.2.

Another way to this is to create a second tikzpicture and use some 2d-shadings:

\begin{tikzpicture}
    \begin{scope}
        \fill[black] (0,0) circle (0.5);
        \clip (0,0) circle (0.5);
        \shade[outer color=black, inner color=black!30] (-0.15,0.5) circle (0.7);
    \end{scope}
\end{tikzpicture}

Something like this:

enter image description here

Credits for second suggestion. Useful link.

1
  • Thank you for your answer. Your suggestions have, unfortunately not quite worked, but they have given me an idea. Now I used the command \pgfpointcylindrical{<degree>}{<radius>}{<height>}.
    – Froop
    Apr 22, 2013 at 7:27
2

The solution to the problem was the command \pgfpointcylindrical{<degree>}{<radius>}{<height>}. Maybe thats not the easiest way but it works.

\tdplotsetmaincoords{60}{130}

\begin{tikzpicture}[scale=4,tdplot_main_coords, curve/.style={red,densely dotted,thick}]

\coordinate  (O)  at  (0,0,0);

\draw[thick,->]  (0,0,0)  --  (1,0,0)  node[anchor=north  east]{$x$};
\draw[thick,->]  (0,0,0)  --  (0,1,0)  node[anchor=north  west]{$y$};
\draw[thick,->]  (0,0,0)  --  (0,0,1)  node[anchor=south]{$z$};

\tdplotsetcoord{P1}{.8}{30}{90}
\tdplotsetcoord{P2}{.8}{30}{30}
\tdplotsetcoord{P3}{.8}{30}{330}
\tdplotsetcoord{P4}{.8}{30}{270}
\tdplotsetcoord{P5}{.8}{30}{210}
\tdplotsetcoord{P6}{.8}{30}{150}

\draw[color=blue] (P1)--(P2)--(P3)--(P4)--(P5)--(P6)--cycle;
\draw[color=blue] (P1xy)--(P2xy)--(P3xy)--(P4xy)--(P5xy)--(P6xy)--cycle;
\draw[color=blue] (P1xy)--(P1);
\draw[color=blue] (P2xy)--(P2);
\draw[color=blue] (P3xy)--(P3);
\draw[color=blue] (P4xy)--(P4);
\draw[color=blue] (P5xy)--(P5);
\draw[color=blue] (P6xy)--(P6);

\pgfpathcircle{\pgfpointcylindrical{30}{0.4}{.7}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{90}{0.4}{.7}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{150}{0.4}{.7}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{210}{0.4}{.7}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{270}{0.4}{.7}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{330}{0.4}{.7}}{1pt}

\pgfpathcircle{\pgfpointcylindrical{30}{0.4}{0}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{90}{0.4}{0}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{150}{0.4}{0}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{210}{0.4}{0}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{270}{0.4}{0}}{1pt}
\pgfpathcircle{\pgfpointcylindrical{330}{0.4}{0}}{1pt}

\pgfsetfillcolor{red}
\pgfusepath{fill}

\end{tikzpicture}

enter image description here

You must log in to answer this question.

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