%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                 The RotationFigure                   %
%                      Package                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Documentation available at : 
% blog.dorian-depriester.fr/wp-content/uploads/2012/12/RotationFigure_Doc.pdf

\NeedsTeXFormat{LaTeX2e}
 
\ProvidesPackage{RotationFigure}[2014/08/12, version 1.5]
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%            Required packages                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	

\RequirePackage{graphicx}
\RequirePackage{amsmath,amsfonts,mathrsfs}
\RequirePackage{amssymb}
\RequirePackage{tikz}
	\usetikzlibrary{calc}
	
	
	

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%            Geometrical parameters                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	

% Concerning the normal direction :
	\newcommand{\circleSize}{0.1}			% Size of outside circle for drawing the normal direction
	\newcommand{\dotSize}{\circleSize/5}	% Size of the inner dot for drawing the normal direction
	\newcommand{\normXpos}{-\circleSize}	% x position of the center of the normal direction
	\newcommand{\normYpos}{-\circleSize}	% y position of the center of the normal direction
		
% Style of the drawn angles
	\newcommand{\angleRadius}{0.9}		% Relative position of the arc circle along the axes
	\newcommand{\angleValue}{20}		% Actual value of the drawn angle	
		
		
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%            Styling parameters                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	

	\tikzstyle{initStyle}=[black]			% Style de la base initiale
	\tikzstyle{rotaStyle}=[black]			% Style de la base tournée
	\tikzstyle{thickness}=[thick]			% Epaisseur de trait des vecteurs
	\tikzstyle{basesArrows}=[<->]			% Style des fleches des vecteurs
	\tikzstyle{angleStyle}=[black]			% Style des fleches des vecteurs
	\tikzstyle{angleArrows}=[->]			% Style des fleches des vecteurs
	\tikzstyle{fontStyle}=[]				% Style des fleches des vecteurs





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definition of the so-called 'RotationFigure' command %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\RotationFigure}[8][] { 
\shorthandoff{:;!?}							% Avoid conflic with french Babel
		\begin{tikzpicture}[#1,scale=2]		% Allow optional parameters for the whole figure
			% Initial base
    			\coordinate (O) at (0,0);
    			\coordinate (x) at (1,0);
    				\draw (x) node[below,initStyle,fontStyle] {$\overrightarrow{#2}$};
    			\coordinate (y) at (0,1);
    				\draw (y) node[right,initStyle,fontStyle] {$\overrightarrow{#3}$};
    			\draw [initStyle,thickness,basesArrows] (y)--(O)--(x);
    			    			\coordinate (O) at (0,0);
    			    			
    		% Rotated base
    			\begin{scope}[rotate=\angleValue]    			
	    			\coordinate (x1) at (1,0);
	    				\draw (x1) node[above,rotaStyle,fontStyle] {$\overrightarrow{#5}$};
	    			\coordinate (y1) at (0,1);
	    				\draw (y1) node[left,rotaStyle,fontStyle] {$\overrightarrow{#6}$};
	    			\draw [rotaStyle,thickness,basesArrows] (y1)--(O)--(x1);
	    		\end{scope}
	    		
	    	% Bottom angle
        		\draw [angleStyle,angleArrows,thickness](O)+(0:\angleRadius) 	% Circle arc
        			 arc (0:\angleValue:\angleRadius);							
           		\draw[angleStyle,fontStyle] (O)+(\angleValue/2:\angleRadius) 	% Name of this angle
           			 node[right] {{$#8$}};
           			 
	    	% Top angle
        		\draw [angleStyle,angleArrows,thickness](O)+(90:\angleRadius) 	% Circle arc
        			 arc (90:90+\angleValue:\angleRadius);							
           		\draw[angleStyle,fontStyle] (O)+(90+\angleValue/2:\angleRadius) % Name of this angle
           			 node[above] {{$#8$}};           			 
         
         	% Normal direction
         		\coordinate (z) at (\normXpos,\normYpos);									% Creates the point where the normal direction will be drawn
         			\draw[thickness,initStyle] (z) circle (\circleSize) ;					% Outside circle
         				\fill[initStyle] (z) circle (\dotSize);								% Inner dot
         			\draw (\normXpos,\normYpos-\circleSize) 								% shift the annotation below the outside circle
         				node[anchor=north,inner sep=1pt,initStyle,fontStyle]				% Names of the normal direction
         					{$\overrightarrow{#4}=\overrightarrow{#7}$};
         \end{tikzpicture}
\shorthandon{:;!?}
}
