%% $Id: pst-spinner-doc.tex 466 2017-05-23 05:41:09Z herbert $
%
\documentclass[11pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,smallheadings,
    headexclude,footexclude,oneside]{pst-doc}
\listfiles
\usepackage{dtk-logos}
\usepackage[autostyle]{csquotes}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\usepackage[utf8]{inputenc}
\usepackage{pst-spinner,pst-tools,animate}
\let\belowcaptionskip\abovecaptionskip
%
\def\textat{\char064}%
\newdimen\fullWidth
\lstset{explpreset={pos=l,width=-99pt,overhang=0pt,hsep=\columnsep,vsep=\bigskipamount,rframe={}},
    escapechar=§}

\def\bgImage{%
\psset{unit=0.75cm}
\begin{pspicture}(-4,-4)(4,4)
\psFidgetSpinner[colorMask=blue,linewidth=0.05,mask,customize,customizeMask,image=images/spirales-hsb.eps,rotation=-30]
\rput(0,0){\color{white}\textbf{PSTricks}}
\end{pspicture}}


\begin{document}
\title{\texttt{pst-spinner}\\
    \small v.\pstspinnerFV}
%\docauthor{Herbert Vo\ss}
\author{Manuel Luque\\Herbert Voß}
\date{\today}

\maketitle

\fullWidth=\linewidth
\advance\fullWidth by \marginparsep
\advance\fullWidth by \marginparwidth


\begin{abstract}
A fidget spinner is a type of stress-relieving toy. A basic fidget spinner consists of a bearing 
in the center of a design made from any of a variety of materials including brass, 
stainless steel, titanium, copper and plastic. The toy may help people who have trouble 
focusing or fidgeting by acting as a release mechanism for nervous energy or stress.~\parencite{wikipedia}
\vfill
\noindent
Thanks to:  
\end{abstract}

\clearpage
\tableofcontents


\clearpage

%\author{manuel.luque27@gmail.com}

\section{Introduction}
This package aims to propose a model of the fidget spinner gadget. It exists under different
forms, with 2, 3 poles and even more. We chosed the most popular model: the triple Fidget Spinner. The dimensions
of the model are linked to that of the ball bearings: outer diameter 22 mm and inner diameter 8 mm. The composite axis
of a quality ball bearing is in the center of an equilateral triangle at the tops of which are placed bearings
With balls identical to that of the axis but of any quality or colored rings. The contour of the object is
Consisting of perfectly connected circular arcs.

\section{Theory}
For calculations the Fidget Spinner is written in a circle of radius $R$. All other dimensions are deduced.
In the diagram $r_1$ is the outer radius of a ball bearing. A is the distance between a ball bearing and the edge
outside the object. $R_1 + a$ is the radius of the circle tangent to the circle of radius $R$, 
$r_2$ is the radius of the circle arc of
connection to the circles of radius $r_1 + a$ and to the central circle of radius $r_1 + 2a$.

\begin{center}
\psset{dimen=middle}
\begin{pspicture}(-6,-7)(6,5)
\psgrid[subgriddiv=0,griddots=10,gridlabels=0]
\pstVerb{/arctan {
dup 0 ge
   {1 atan}
   {neg 1 atan neg}
ifelse
} def
         /R1 4.5 def
         /r1 1.1 def
         /a1 R1 3 div r1 sub def
         /rho R1 r1 sub a1 sub def
         /r2 2 r1 mul a1 mul 3 a1 dup mul mul add rho dup mul add rho r1 a1 2 mul add mul sub
             rho 2 a1 mul sub div  def
         /rho2 r2 r1 add 2 a1 mul add def
         /alpha1 rho rho2 2 div sub rho2 3 sqrt mul 2 div div arctan def
         /beta1 rho rho2 add neg 3 sqrt rho2 rho sub mul div arctan def
         /alpha2 rho 2 div neg rho2 add 3 sqrt 2 div rho mul neg div arctan def
}%
\pscircle{! R1}
\pscircle{! rho}
\pnode(! 0 R1){A}
\pnode(!R1 3 sqrt mul -2 div R1 -2 div){B}
\pnode(!R1 3 sqrt mul 2 div R1 -2 div){C}
\pnode(! 0 rho){O1}
\pnode(!rho 3 sqrt mul -2 div rho -2 div){O2}
\pnode(!rho 3 sqrt mul 2 div rho -2 div){O3}
\pnode(! rho2 3 sqrt mul 2 div neg  rho2 2 div ){A'}
\pnode(! rho2 3 sqrt mul 2 div    rho2 2 div ){B'}
\pnode(! 0 rho2 neg){C'}
\pspolygon(A')(B')(C')
\pspolygon(O1)(O2)(O3)
\pscircle[linecolor={[rgb]{0 0.5 0}}]{!r1}
\pscircle{!r1 a1 add}
\pscircle{!r1 a1 2 mul add}
\pscircle[linecolor={[rgb]{0 0.5 0}}](O1){!r1}
\pscircle[linecolor={[rgb]{0 0.5 0}}](O2){!r1}
\pscircle[linecolor={[rgb]{0 0.5 0}}](O3){!r1}
\pscircle(O3){!r1 a1 add}
\pscircle(O1){!r1 a1 add}
\pscircle(O2){!r1 a1 add}
\psline(A)(O)
\psline(B)(O)
\psline(C)(O)
\psdots(O1)(O2)(O3)
\pscircle[linecolor=red,linestyle=dashed]{!rho2}
\pscircle[linecolor=red](A'){!r2}
\pscircle[linecolor=red](B'){!r2}
\pscircle[linecolor=red](C'){!r2}
\psdots[linecolor=red](A')(O1)(B')(O3)(C')(O2)
\pspolygon(A')(O1)(B')(O3)(C')(O2)
\psarc[linecolor=blue,linewidth=0.1]{->}(O1){!r1 a1 add}{!alpha1 neg}{!alpha1 180 add}
\psarcn[linecolor=red,linewidth=0.1]{->}(A'){!r2}{!alpha1}{!beta1}
\psarc[linecolor=blue,linewidth=0.1]{->}(O2){!r1 a1 add}{!180 beta1 add}{!alpha2}
\psarcn[linecolor=red,linewidth=0.1]{->}(C'){!r2}{!alpha2 180 sub}{!alpha2 neg}
\psarc[linecolor=blue,linewidth=0.1]{->}(O3){!r1 a1 add}{!alpha2 neg 180 add}{!360 beta1 sub}
\psarcn[linecolor=red,linewidth=0.1]{->}(B'){!r2}{!beta1 180 sub neg}{!alpha1 180 sub neg}
\uput[ul](0,0){$O$}
\uput[ul](O1){$O_1$}
\uput[d](O2){$O_2$}
\uput[d](O3){$O_3$}
\pcline{->}(O1)(!r1 30 cos mul rho r1 30 sin mul add)
\aput{:U}{$r_1$}
\rput(!r1 30 cos mul rho r1 30 sin mul add){\pcline{<->}(0,0)(!a1 30 cos mul a1 30 sin mul)\aput{:U}{$a$}}
\uput[u](A'){$O'_1$}
\uput[u](B'){$O'_3$}
\rput(B'){\pcline{->}(0,0)(! r2 30 cos mul r2 30 sin mul)\aput{:U}{$r_2$}}
\uput[d](C'){$O'_2$}
\end{pspicture}
\end{center}


\section{The Macro}

For calculations, the Fidget Spinner is written in a circle of radius R. All other dimensions are deduced.
The colors of the rings can be chosen as well as the background color of the object. This object can be customized with
a picture.
The command is: 

\begin{BDef}
\Lcs{psFidgetSpinner}\OptArgs\OptArg*{\Largr{$x_0,y_0$}}
\end{BDef}

with two optional arguments. If the \Largr{$x_0,y_0$} is missing then \Largr{$0,0$} is assumed as
the origin of the spinner.

\section{Optional arguments}

\subsection{The Radius \nxLkeyword{R}}
The radius \Lkeyword{R} of the circle in which the triple Fidget spinner is inscribed. It is preset to \nxLkeyword{R=3.9}.
\subsection{The colors}

The colors with their default value. They are numbered in the order: central bearing, peripheral rings,
and central cap.

  \begin{itemize}
    \item \Lkeyset{color0=honeydew}
    \item \Lkeyset{color1=red}
    \item \Lkeyset{color2=green}
    \item \Lkeyset{color3=blue}
    \item \Lkeyset{colorMask=honeydew}
  \end{itemize}

\subsection{Rotation}
With the optional argument \Lkeyword{rotation} the output of the spinner can be rotated.

\subsection{\nxLkeyword{mask}} 
\Lkeyword{mask} is a boolean value to customize the object with an image in eps format. Preset to \false.

\subsection{\nxLkeyword{customizeMask}}
\Lkeyword{customizeMask} is a boolean value. When set to \true\  the image is also printed on the cap of the central ball roll.

\subsection{\nxLkeyword{image}} 
The keyword \Lkeyword{image} defines the name including the path  of the image and is preset to empty.



\subsection{Background color}
The background color is set with the default PSTricks parameter \Lkeyword{fillcolor} and
the linecolor and linewidth with \Lkeyword{linecolor} and \Lkeyword{linewidth}.


\section{examples}


\begin{LTXexample}[width=0.6\linewidth,frame=,pos=r]
\begin{pspicture}(-4,-4)(4,4)
\psgrid[style=mmpaper](-4,-4)(4,4)
\psFidgetSpinner[
  fillcolor=cyan!10,
  linewidth=0.05,mask]
\end{pspicture}
\end{LTXexample}


\begin{LTXexample}[width=0.6\linewidth,frame=,pos=r]
\begin{pspicture}(-4,-4)(5,4)
\psgrid[subgriddiv=5,
 gridlabels=0,
 gridwidth=1pt,
 gridcolor=orange,
 subgridwidth=0.1pt,
 subgridcolor=orange](-4,-4)(5,4)
\psFidgetSpinner[
  fillcolor=cyan!10,
  linewidth=0.05,
  mask=false](1,0)
\end{pspicture}
\end{LTXexample}





\begin{LTXexample}[width=0.6\linewidth,frame=,pos=r]
\begin{pspicture}(-4,-4)(4,4)
\psgrid[subgriddiv=5,
  gridlabels=0,
  gridwidth=1pt,
  gridcolor=orange,
  subgridwidth=0.1pt,
  subgridcolor=orange](-4,-4)(4,4)
\psFidgetSpinner[colorMask=blue,
  linewidth=0.05,mask,customize,
  customizeMask,
  image=images/spirales-hsb.eps]
\rput(0,0){\color{white}\textbf{PSTricks}}
\end{pspicture}
\end{LTXexample}



\begin{LTXexample}[width=0.6\linewidth,frame=,pos=r]
\begin{pspicture}(-4,-4)(4,4)
\psgrid[subgriddiv=5,
  gridlabels=0,
  gridwidth=1pt,
  gridcolor=orange,
  subgridwidth=0.1pt,
  subgridcolor=orange](-4,-4)(4,4)
\psFidgetSpinner[colorMask=blue,linewidth=0.05,
  mask,customize,customizeMask,
  image=images/spirales-hsb.eps,
  rotation=-30]
\rput(0,0){\color{white}\textbf{PSTricks}}
\end{pspicture}
\end{LTXexample}


\begin{center}
\begin{animateinline}[controls,loop,
                     begin={\begin{pspicture}(-4,-4)(4,4)},
                     end={\end{pspicture}}]{25}% 25 images/s
\multiframe{72}{i=0+5}{%
\psgrid[subgriddiv=5,%
  	gridlabels=0,%
  	gridwidth=1pt,%
  	gridcolor=orange,
    subgridwidth=0.1pt,%
    subgridcolor=orange](-4,-4)(4,4)
\rput{\i}{\psFidgetSpinner[R=3.9,fillcolor=cyan!10,linewidth=0.05,mask]}
\rput(0,0){\textbf{PSTricks}}
}
\end{animateinline}
\end{center}

\begin{verbatim}
\begin{animateinline}[
  controls,loop,
  begin={\begin{pspicture}(-4,-4)(4,4)},
  end={\end{pspicture}}]{25}% 25 images/s
\multiframe{72}{i=0+5}{%
\psgrid[subgriddiv=5,
  gridlabels=0,  	
  gridwidth=1pt,
  gridcolor=orange,
  subgridwidth=0.1pt,
  subgridcolor=orange](-4,-4)(4,4)
\rput{\i}{\psFidgetSpinner[R=3.9,fillcolor=cyan!10,linewidth=0.05,mask]}
\rput(0,0){\textbf{PSTricks}}}
\end{animateinline}
\end{verbatim}

\iffalse

\begin{center}
\begin{animateinline}[controls,loop,
                     begin={\begin{pspicture}(-4,-4)(4,4)},
                     end={\end{pspicture}}]{25}% 25 images/s
\multiframe{72}{i=0+5}{%
\psgrid[subgriddiv=5,
  gridlabels=0,
  gridwidth=1pt,
  gridcolor=orange,
  subgridwidth=0.1pt,
  subgridcolor=orange](-4,-4)(4,4)
\psFidgetSpinner[R=3.9,colorMask=blue,linewidth=0.05,mask,customize,
  customizeMask,image=images/spirales-hsb.eps,rotation=\i]
\rput(0,0){\color{white}\textbf{PSTricks}}}
\end{animateinline}
\end{center}

\begin{verbatim}
\begin{animateinline}[controls,loop,
                     begin={\begin{pspicture}(-4,-4)(4,4)},
                     end={\end{pspicture}}]{25}% 25 images/s
\multiframe{72}{i=0+5}{%
\psgrid[subgriddiv=5,
  gridlabels=0,
  gridwidth=1pt,
  gridcolor=orange,
  subgridwidth=0.1pt,
  subgridcolor=orange](-4,-4)(4,4)
\psFidgetSpinner[R=3.9,colorMask=blue,linewidth=0.05,mask,customize,customizeMask,
     image=images/spirales-hsb.eps,rotation=\i]
\rput(0,0){\color{white}\textbf{PSTricks}}}
\end{animateinline}
\end{verbatim}

\fi


\clearpage
\section{List of all optional arguments for \texttt{pst-spinner}}

\xkvview{family=pst-spinner,columns={key,type,default}}


\nocite{*}
\bgroup
\RaggedRight
\printbibliography
\egroup

\printindex


\end{document} 