%&"rotationsolide"
% !TEX encoding = UTF-8
% !TeX program = pdflatex
% !TeX spellcheck = fr_FR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Template for animation production
%%------------------------------------------------
\PassOptionsToPackage{svgnames}{xcolor}
%\documentclass[12pt]{article}
\documentclass[tikz
%12pt,border=2mm,varwidth=true,class=article,float=false%
%,convert={ghostscritikz,pt,gsexe={mgs.exe},gsdevice=png256,outext=.png,density=300},%
]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[all]{utf8ext}
\usepackage{etoolbox}
%\usepackage{filecontents}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=25mm,verbose=false]{geometry}
\usepackage{xcolor}
\usepackage{graphicx}
%\usepackage{currfile}
%\usepackage{calc}
\usepackage{amsmath,amssymb}
\usepackage[e]{esvect}
\definecolor{myGreen}{rgb}{0,0.5,0}
%--- tikz
\usepackage{pgf,tikz}
\usetikzlibrary{calc,patterns,spy,matrix,arrows,decorations.pathmorphing,positioning,intersections,3d}
\tikzset{>=stealth}
\tikzset{isometric/.style={x={(-0.87cm,-0.5cm)},y={(0.87cm,-0.5cm)},z={(0cm,1cm)}}}
\tikzset{partial ellipse/.style args={#1:#2:#3}{ insert path={+ (#1:#3) arc (#1:#2:#3)} } }%
\newcommand{\pnt}[4][black]{% use \pnt[red]{(cx,xy)}{rad}{node...}
\begin{scope}[shift={#2}];
\fill[color=#1,shift only,radius=#3] (0,0)#4 circle;
\end{scope}}

%\usepackage{hyperref}
%------------
\csname endofdump\endcsname
%-------------
%\immediate\write18{
%	(tasklist|find "AcroRd32.exe">nul)&&
%	(taskkill /f /im acrord32.exe>nul)}
%\immediate\write18{PDFXCview.exe /close \jobname.pdf}
\immediate\write18{taskkill /FI "WINDOWTITLE eq \jobname*" /IM Acrobat.exe}

%% ====== setup animation
% build timeline  text file
\newcounter{framecnt}
\newwrite\timelinefile 
\immediate\openout\timelinefile=\jobname-tl.txt

%%%%%%%%% Tex file do build standalone anmation   %%%%%%%%%%%%%%%%%%%%

%\begin{filecontents*}{\jobname-anim.tex}
%\documentclass[varwidth,border=2pt]{standalone}
%\usepackage[utf8]{inputenc}
%\usepackage{graphicx}
%\usepackage[svgnames]{xcolor}
%\usepackage[e]{esvect}
%\usepackage{animate}
%\definecolor{myGreen}{rgb}{0,0.5,0}
%\standaloneenv{myenv}
%%\newenvironment{myenv}{\begin{group}}{\end{group}}
%%-------------
%\immediate\write18{taskkill /FI "WINDOWTITLE eq \jobname*" /IM Acrobat.exe}
%%-------------
%\begin{document}
%\begin{myenv}\centering
%\begin{minipage}{\textwidth}
%\centering
%\animategraphics[controls,loop, autoplay,timeline=rot-sol-tl.txt,width=\linewidth]{20}{rot-sol}{}{}
%\end{minipage}
%
%%\vspace*{2\baselineskip}
%\begin{minipage}{0.8\textwidth}
%Champ des vitesses d'un solide en rotation : en bleu le vecteur rotation {\color{blue} $\vv{\omega}$}, en rouge les vecteurs position de {\color{red} $\vv*{OB}{1}$} et {\color{red} $\vv*{OB}{2}$} liés au solide, et en vert les vitesses {\color{myGreen} $\vv*{v}{1}$} et {\color{myGreen} $\vv*{v}{2}$}, à chaque instant orthogonales au vecteur rotation et au vecteur position correspondant.
%\end{minipage}
%\end{myenv}
%\end{document}
%
%\end{filecontents*}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%parameters for 2 arrows
\def\om{0.6}
\def\lone{1}
\def\latone{60}
\def\phione{210}
\pgfmathsetmacro\thone{90-\latone}
\pgfmathsetmacro{\rone}{\lone*sin(\thone)}
\pgfmathsetmacro{\hone}{\lone*cos(\thone)}
\def\ltwo{1.5}
\def\lattwo{-40}
\pgfmathsetmacro\thtwo{90-\lattwo}
\def\phitwo{90}
\pgfmathsetmacro{\rtwo}{\ltwo*sin(\thtwo)}
\pgfmathsetmacro{\htwo}{\ltwo*cos(\thtwo)}

\immediate\write\timelinefile{::0x0}
%% Background picture isometric with 3D library 
\begin{tikzpicture}[scale=3,isometric]
%%repere
\useasboundingbox (-2cm,-2cm) rectangle (2cm,1.7cm);
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (0,0,1) node[anchor=west]{$z$};
\draw[blue,very thick] (O) -- (0,0,\hone);
%%% Disks
\begin{scope}[canvas is xy plane at z=\hone]
\coordinate (C1) at (0,0);
\pnt[red]{(C1)}{2pt}{};
\filldraw[thick, dotted, draw=red,fill=white,top color=MistyRose,fill opacity=0.5] (0,0) circle (\rone);
\end{scope}
\begin{scope}[canvas is xy plane at z=\htwo]
\coordinate (C2) at (0,0);
\pnt[blue]{(C2)}{2pt}{};
\filldraw[thick,dotted, draw=red,fill=white,top color=MistyRose,fill opacity=0.5] (C2) circle (\rtwo);
\end{scope}
\draw[thick,->] (O) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (O) node[left=3pt]{$A$} -- (1,0,0) node[anchor=north east]{$x$};
\draw[blue,very thick,->]  (0,0,\hone) -- (0,0,1.5) node[right=3pt]{$\vv{ω}$};
\end{tikzpicture}
%%% Rotating vectors
\foreach \philoop in {0,-5,..., -355} {%,..., 360
	\stepcounter{framecnt}
	\immediate\write\timelinefile{::\theframecnt}
	\begin{tikzpicture}[scale=3,isometric]
		\useasboundingbox (-2cm,-2cm) rectangle (2cm,1.7cm);
		\pgfmathsetmacro\phicur{\phione+\philoop}
		\pgfmathsetmacro\phicurvec{\phicur-90}
		\coordinate (C1) at (0,0);
		\coordinate (P1\philoop) at (xyz spherical cs:radius=\lone,longitude=\phicur,latitude=\latone);
		\draw[very thick,->,red] (O)--(P1\philoop);
		\coordinate (vec1\philoop) at (xyz spherical cs:radius=\om*\rone,longitude=\phicurvec,latitude=0);
		\coordinate (V1\philoop) at ($(P1\philoop)+(vec1\philoop)$);
		\draw[very thick,->,myGreen] (P1\philoop)--(V1\philoop);
		%
		\pgfmathsetmacro\phicur{\phitwo+\philoop}
		\pgfmathsetmacro\phicurvec{\phicur-90}
		\coordinate (P2\philoop) at (xyz spherical cs:radius=\ltwo,longitude=\phicur,latitude=\lattwo);
		\draw[very thick,->,red] (O)--(P2\philoop);
		\coordinate (vec2\philoop) at 
(xyz spherical cs:radius=\om*\rtwo,longitude=\phicurvec,latitude=0);
		\coordinate (V2\philoop) at ($(P2\philoop)+(vec2\philoop)$);
		\draw[very thick,->,myGreen] (P2\philoop)--(V2\philoop);
	\end{tikzpicture}
}
\immediate\closeout\timelinefile%

\end{document}