0

I am beginner with tikz-3dplot, I want to draw this figure enter image description here

I used the explanation given in John Kormylo,

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{patterns}% comme shading pour remplir une surface
\begin{document}

%\pgfmathsetmacro{\iAngle}{0}
\tdplotsetmaincoords{70}{110}
\foreach \iAngle in {1,10,...,360}
{
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (1.5,0,0) node[anchor=north]{$x$};
\draw[thick,->] (O) -- (0,1,0) node[anchor=west]{$y$};
\draw[thick,->] (O) -- (0,0,1) node[anchor=south]{$z$};
\draw[thick, opacity=0.3]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle;
\fill[pattern=dots,opacity=0.5]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle; 

  \fill[red,thick] (0,0,0.3) circle (0.3pt) node[left] {$O_1$};

\tdplotsetrotatedcoords{\iAngle}{0}{0}
\begin{scope}[tdplot_rotated_coords]
\draw[red,thick, ->]
 (0.6,0,0.3) -- (1.5,0,0.3) node[above] {$x_1$};
\draw[red,thick, ->]
 (0,0,0.3) -- (0,1,0.3) node[above] {$y_1$};
 \draw[thick, dashed, opacity=1]
  (0,0,0) -- (1.5,0,0);
   \fill[blue,thick] (0.6,0,0.3) circle (0.3pt) node[above] {$A_1$};
    \fill[blue,thick] (1.2,0,0.3) circle (0.3pt) node[above] {$A_2$};
    \draw[pattern=north west lines, pattern color=blue, opacity=0.5 ] (0.6,0,0.3) circle (0.7); 
     \draw[pattern=north west lines, pattern color=green, opacity=0.5 ] (1.2,0,0.3) circle (0.7);
      \draw[thick, dashed, opacity=1]
  (0,0,0.3) -- (0.6,0,0.3);
  \draw[thick, line, opacity=1]
  (0.6,0,0.3) -- (1.2,0,0.3);
\end{scope}
\end{tikzpicture}
}
\end{document}

I got the following figure, but is not complete,

enter image description here

how can i fix the main coordinates in the animation?

how to add unit vectors related to disks?

what angle can give me a funny view?

can anyone help me, to achieve this work

moradov
  • 427
  • 2
  • 1
    Since circles are drawn in the x-y plane, you will need to create a rotated coordinates system to draw the circles in other planes. See https://tex.stackexchange.com/questions/254820/tikz-pair-of-compasse-rendering-contest/254866?s=1|41.9891#254866 – John Kormylo Feb 10 '18 at 17:18
  • You may also want to rethink how you generally deal with answers. I guess people here will then be much more eager to help you. –  Feb 10 '18 at 19:34
  • @ John Kormylo, thank you i used your explanation to get the figure below, – moradov Feb 12 '18 at 10:37
  • thank you, @marmot, i used your reply marmot to get the animation below, but the main coordinate still in rotation, how can i fix it to get amazing views in the x-y plane? – moradov Feb 12 '18 at 10:42

1 Answers1

3

I removed the faulty line argument, made a bouding box such that the picture does not jump, and, most importantly, made the circles orthogonal to the rotating axes.

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{patterns}% comme shading pour remplir une surface
\begin{document}

\pgfmathsetmacro{\RelativeSpeed}{0.3}
\tdplotsetmaincoords{70}{110}
\foreach \iAngle in {1,5,...,360}
{
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\useasboundingbox[tdplot_screen_coords] (-1.8,-1) rectangle (1.4,1.4);
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (1.5,0,0) node[anchor=north]{$x$};
\draw[thick,->] (O) -- (0,1,0) node[anchor=west]{$y$};
\draw[thick,->] (O) -- (0,0,1) node[anchor=south]{$z$};
\draw[thick, opacity=0.3]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle;
\fill[pattern=dots,opacity=0.5]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle; 

  \fill[red,thick] (0,0,0.3) circle (0.3pt) node[left] {$O_1$};

\tdplotsetrotatedcoords{\iAngle}{00}{0}
\begin{scope}[tdplot_rotated_coords]
\draw[red,thick, ->]
 (0.6,0,0.3) -- (1.5,0,0.3) node[above] {$x_1$};
\draw[red,thick, ->]
 (0,0,0.3) -- (0,1,0.3) node[above] {$y_1$};
 \draw[thick, dashed, opacity=1]
  (0,0,0) -- (1.5,0,0);
   \coordinate[label=above:$A_1$] (A1) at (0.6,0,0.3);
   \coordinate[label=above:$A_2$] (A2) at (1.2,0,0.3);
   \fill[blue,thick] (A1) circle (0.3pt);
   \fill[blue,thick] (A2) circle (0.3pt);
\end{scope}
\tdplotsetrotatedcoords{\iAngle}{90}{0}
\begin{scope}[tdplot_rotated_coords]
    \draw[pattern=north west lines, pattern color=blue, opacity=0.5 ] (A1) circle (0.7); 
    \draw[pattern=north west lines, pattern color=green, opacity=0.5 ] (A2) circle (0.7);
    \pgfmathsetmacro{\jAngle}{\RelativeSpeed*\iAngle}
    \draw[-latex,blue] (A1) -- ++({-0.7*cos(\jAngle)},{0.7*sin(\jAngle)},0)node[right]{$y_1'$}; 
    \draw[-latex,blue] (A1) -- ++({0.7*sin(\jAngle)},{0.7*cos(\jAngle)},0)node[right]{$x_1'$};  
    \draw[-latex,green] (A2) -- ++(-0.7,0,0)node[right]{$y_2'$};    
    \draw[-latex,green] (A2) -- ++(0,0.7,0)node[right]{$x_2'$}; 
\end{scope}
\tdplotsetrotatedcoords{\iAngle}{00}{0}
\begin{scope}[tdplot_rotated_coords]
      \draw[thick, dashed, opacity=1]
  (0,0,0.3) -- (0.6,0,0.3);
  \draw[thick, -, opacity=1]
  (0.6,0,0.3) -- (1.2,0,0.3);
\end{scope}
\end{tikzpicture}
}
\end{document}

UPDATE: I hope to have addressed your requests. In this version, the blue frame rotates with 30% of the speed of the rotation of the big frame. The relative speed is set by the parameter \RelativeSpeed. You may use the same trick to rotate the green frame, or to rotate it with a different speed. Actually, writing the code is rather straightforward, I am however struggling to convert the pdf of to an animated gif. (Why is that so complicated? Why does it take so long?) Therefore, I would be eager to learn a more efficient way of doing this.

enter image description here

  • thank you @Marmot for your quick reply, It only remains for me to add axes of unit vectors related to disks, i don't have any idea, can you redirect me to an example Which seems like it – moradov Feb 12 '18 at 12:24
  • @moradov I am sorry, I do not understand what "axes of unit vectors related to disks" are. Can you describe in more detail what you want, or add a sketch to make this clear? –  Feb 12 '18 at 15:02
  • i want to add the axis ralated to disc, as shown in the picture below (in my description of my question). i had used the following commands, answers \tdplotsetrotatedcoords{\iAngle}{90}{0} \tdplotsetrotatedcoordsorigin{(A2)} \begin{scope}[tdplot_rotated_coords,scale=.8,thick] \draw [->] (0,0,0) -- (0.7,0,0) node [right] {$\hat{r}$}; \draw [->] (0,0,0) -- (0,0,0.7) node [above] {$\hat{\theta}$}; \end{scope}, but I have not got the origin of axis in the A2 – moradov Feb 12 '18 at 15:46
  • 1
    @moradov I will try to solve this in a few hours. –  Feb 12 '18 at 16:22
  • 1
    @moradov Please see the updated answer. Notice that I did not yet replace the animated gif, so please run the code through and tell me if it is what you want, or what should be changed. –  Feb 12 '18 at 19:23
  • thank you very much, that's can solve my problem, but I would like to show the disc rotating around the its axis, i've used the multido package, \multido{\rt=0+5}{\iAngle}{ \draw[thick, color=violet] (A2) -- ++({-0.7*cos(\rt)},{0.7*sin(\rt)},0); \draw[thick, color=violet] (A2) -- ++({0.7*sin(\rt)},{0.7*cos(\rt)},0); } – moradov Feb 13 '18 at 01:30
  • 1
    @moradov Unfortunately, there seems to be language barrier. My current interpretation of your message is that this answers your original question, and you have a new question. If this is the case, accept the answer (and I will put the animated gif for completeness), and ask a new question (which hopefully has an MWE). –  Feb 13 '18 at 01:34
  • how can I slow down the motion of stem (A1A2) in animation and increment the disk rotation around its axis, to separate the two motion i used the following command to get the gif file convert -density 300 -delay 15 -loop 0 -background white -alpha remove file.pdf file.gif – moradov Feb 13 '18 at 01:34
  • 1
    @moradov I hope you're now happy ;-) –  Feb 13 '18 at 04:36