% Copyright 2011 by Alain Matthes
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.


\def\fileversion{1.13 c}
\def\filedate{2011/01/19}   

 
%<--------------------------------------------------------------------------–>
%                       tkzCircle center and one point 
%<--------------------------------------------------------------------------–>

\def\tkz@numc{0}
\pgfkeys{/tkzDefCircle/.cd,
radius/.code                   = \def\tkz@numc{0},
diameter/.code                 = \def\tkz@numc{1},
circum/.code                   = \def\tkz@numc{2},
in/.code                       = \def\tkz@numc{3},
euler/.code                    = \def\tkz@numc{4},
apollonius/.code               = \def\tkz@numc{5},
orthogonal from/.code args     = {#1}{\global\def\tkz@ptfrom{#1},
                                      \global\def\tkz@numc{6}}, 
orthogonal through/.code args  ={#1 and #2}{\global\def\tkz@ptone{#1}
                                            \global\def\tkz@pttwo{#2} 
                                            \global\def\tkz@numc{7}}, 
K/.code                        = \def\tkz@koeff{#1}
} 

\def\tkzDefCircle{\pgfutil@ifnextchar[{\tkz@DefCircle}{%
           \tkz@DefCircle[]}}
\def\tkz@DefCircle[#1](#2){% 
\begingroup
\pgfkeys{/tkzDefCircle/.cd,radius,K=2}   
\pgfqkeys{/tkzDefCircle}{#1}  
\ifcase\tkz@numc%
  \tkzDefCircleRadius(#2)
  \or% 1 
  \tkzDefCircleD(#2)  
  \or% 2
  \tkzDefCircumCircle(#2) 
  \or% 3
  \tkzDefInCircle(#2) 
  \or% 4
  \tkzDefEulerCircle(#2)
  \or% 5
  \tkzDefApolloniusCircle(#2) 
  \or% 6
  \tkzDefOrthogonalCircle(#2,\tkz@ptfrom) 
    \or% 7
  \tkzDefOrthoThroughCircle(#2,\tkz@ptone,\tkz@pttwo)   \fi    
\endgroup
}
%<--------------------------------------------------------------------------–>
\def\tkzDefCircumCircle(#1,#2,#3){%
\begingroup
   \tkzCircumCenter(#1,#2,#3)
   \tkzCalcLength(#1,tkzPointResult) 
\endgroup
} 
\def\tkzDefInCircle(#1,#2,#3){%
\begingroup
   \tkzInCenter(#1,#2,#3) \tkzGetPoint{tkz@ia} 
   \tkzUProjection(#2,#3)(tkzPointResult)
   \tkzCalcLength(tkzPointResult,tkz@ia)
   \tkzRenamePoint(tkz@ia){tkzPointResult} 
\endgroup
}    
\def\tkzDefEulerCircle(#1,#2,#3){%
\begingroup
    \tkzDefMidPoint(#2,#3) \tkzGetPoint{tkz@e}
    \tkzEulerCenter(#1,#2,#3) 
    \tkzCalcLength(tkz@e,tkzPointResult)
\endgroup
}   
\def\tkzDefApolloniusCircle(#1,#2){%
\begingroup
   \tkzApolloniusCenter(#1,#2)
   \tkzCalcLength(tkzPointResult,tkzFirstPointResult)   
\endgroup
}    
\def\tkzDefOrthogonalCircle(#1,#2,#3){%   
\begingroup
   \tkzTgtFromP(#1,#2)(#3)
   \tkzCalcLength[cm](#1,tkzFirstPointResult)   
\endgroup
} 
\def\tkzDefOrthoThroughCircle(#1,#2,#3,#4){%  
\begingroup  
   \tkzCalcLength[cm](#1,#2)\tkzGetLength{tkz@lna}% 
   \tkzCalcLength[cm](#1,#3)\tkzGetLength{tkz@lnb}% 
   \FPeval\tkz@lnc{\tkz@lna/\tkz@lnb*\tkz@lna}
   \tkzVecKNorm[\tkz@lnc](#1,#3){tkz@PointResult}
   \tkzCircumCenter(tkz@PointResult,#3,#4)
   \tkzCalcLength(tkzPointResult,#3)    
\endgroup
}   
%<--------------------------------------------------------------------------–>
\def\tkz@numdc{0}
\pgfkeys{
/DrawCircle/.cd,
 radius/.code              =\def\tkz@numdc{0},
 R/.code                   =\def\tkz@numdc{1},
 diameter/.code            =\def\tkz@numdc{2},
 circum/.code              =\def\tkz@numdc{3},
 in/.code                  =\def\tkz@numdc{4},
 euler/.code               =\def\tkz@numdc{5},
 apollonius/.code          =\def\tkz@numdc{6},
 orthogonal from/.code args= {#1}{\global\def\tkz@ptfrom{#1},
                                  \global\def\tkz@numdc{7}}, 
 orthogonal through/.code args={#1 and #2}{\global\def\tkz@ptone{#1}
                                           \global\def\tkz@pttwo{#2} 
                                           \global\def\tkz@numdc{8}}, 
 K/.code                   =\def\tkz@koeff{#1},  
 /DrawCircle/.unknown/.code ={\let\searchname=\pgfkeyscurrentname
                             \pgfkeysalso{\searchname/.try=#1,
                             /tikz/\searchname/.retry=#1}}
} 
%<--------------------------------------------------------------------------–>
\def\tkzDrawCircle{\pgfutil@ifnextchar[{\tkz@DrawCircle}{\tkz@DrawCircle[]}}
\def\tkz@DrawCircle[#1](#2){%     
\begingroup 
\pgfkeys{/DrawCircle/.cd,radius,K=2}
\pgfqkeys{/DrawCircle}{#1}  
\ifcase\tkz@numdc%
    \tkzDefCircleRadius(#2)
  \or% 1
    \tkzDefCircleR(#2) 
  \or% 2
    \tkzDefCircleD(#2)  
  \or% 3
   \tkzDefCircumCircle(#2) 
  \or% 4
  \tkzDefInCircle(#2)
   \or% 5
  \tkzDefEulerCircle(#2) 
   \or% 6
 \tkzDefApolloniusCircle(#2) 
   \or% 7
  \tkzDefOrthogonalCircle(#2,\tkz@ptfrom) 
    \or% 8
  \tkzDefOrthoThroughCircle(#2,\tkz@ptone,\tkz@pttwo)  
 \fi
\draw[/DrawCircle/.cd,line style,#1]%
       (tkzPointResult) circle (\tkzLengthResult pt);%      
\endgroup
} 
%<--------------------------------------------------------------------------–>
\def\tkzDefCircleRadius(#1,#2){% 
\begingroup
  \tkzCalcLength(#1,#2)
  \tkzRenamePoint(#1){tkzPointResult}
\endgroup
}    
%<--------------------------------------------------------------------------–>
\def\tkzDefCircleR(#1,#2){% 
  \begingroup 
  \tkz@radi=#2 %
  \FPeval\tkzLengthResult{\pgf@sys@tonumber{\tkz@radi}}%
  \FPround\tkzLengthResult\tkzLengthResult5\relax%
  \global\let\tkzLengthResult\tkzLengthResult  
  \tkzRenamePoint(#1){tkzPointResult}   
\endgroup
} 
%<--------------------------------------------------------------------------–>
\def\tkzDefCircleD(#1,#2){% 
\begingroup
  \tkzDefMidPoint(#1,#2)
  \tkzCalcLength(#1,tkzPointResult)
\endgroup
} 
%<--------------------------------------------------------------------------–>
%<---------------------------- Fill Circle  --------------------------------–>
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
\def\tkz@numfc{0}
\pgfkeys{
/fillcircle/.cd,
 radius/.code              =\def\tkz@numfc{0},
 R/.code                   =\def\tkz@numfc{1}, 
/fillcircle/.unknown/.code ={\let\searchname=\pgfkeyscurrentname
                             \pgfkeysalso{\searchname/.try=#1,
                             /tikz/\searchname/.retry=#1}}
}

\def\tkzFillCircle{\pgfutil@ifnextchar[{\tkz@FillCircle}{\tkz@FillCircle[]}}
\def\tkz@FillCircle[#1](#2,#3){%
\begingroup      
\pgfkeys{/fillcircle/.cd,radius}
\pgfqkeys{/fillcircle}{#1}
\ifcase\tkz@numfc%
 % first case 0
    \tkzCalcLength(#2,#3)
   \fill[/fillcircle/.cd,#1] (#2) circle (\tkzLengthResult pt);%  
  \or% 1
   \fill[/fillcircle/.cd,#1] (#2) circle (#3);%  
  \fi    
\endgroup
}
%<--------------------------- Clip Circle  ---------------------------------–>
% %<--------------------------------------------------------------------------–>
\def\tkz@numcc{0}
\pgfkeys{
/clipcircle/.cd,
 radius/.code              =\def\tkz@numcc{0},
 R/.code                   =\def\tkz@numcc{1}
}
%<--------------------------------------------------------------------------–>
\def\tkzClipCircle{\pgfutil@ifnextchar[{\tkz@ClipCircle}{%
                                        \tkz@ClipCircle[]}}

\def\tkz@ClipCircle[#1](#2,#3){%    
\pgfkeys{/clipcircle/.cd,radius}
\pgfqkeys{/clipcircle}{#1}
\ifcase\tkz@numcc
     \tkzCalcLength(#2,#3)
     \clip  (#2) circle (\tkzLengthResult pt);  
  \or% 1
     \clip  (#2) circle (#3);  
  \fi
} 
%<--------------------------- Label Circle  --------------------------------–>
%<--------------------------------------------------------------------------–>
% %<--------------------------------------------------------------------------–>
\def\tkz@numlc{0}
\pgfkeys{
/labelcircle/.cd,
 radius/.code                =\def\tkz@numlc{0},
 R/.code                     =\def\tkz@numlc{1},
 /labelcircle/.unknown/.code ={\let\searchname=\pgfkeyscurrentname
                             \pgfkeysalso{\searchname/.try=#1,
                             /tikz/\searchname/.retry=#1}}
}

\def\tkzLabelCircle{\pgfutil@ifnextchar[{\tkz@LabelCircle}{%
                                         \tkz@LabelCircle[]}}

\def\tkz@LabelCircle[#1](#2,#3)(#4)#5{%
\begingroup      
\pgfkeys{/labelcircle/.cd,radius}
\pgfqkeys{/labelcircle}{#1}
\ifcase\tkz@numlc
   \tkzURotateAngle(#2,#4)(#3)
   \node[/labelcircle/.cd,#1] at (tkzPointResult) {#5};    
  \or% 1
  \path (#2)--++(#3,0) coordinate (tkzPointResult);
  \tkzURotateAngle(#2,#4)(tkzPointResult)
   \node[/labelcircle/.cd,#1] at (tkzPointResult) {#5};   
 \fi    
\endgroup
}
%<--------------------------------------------------------------------------–> 
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
  
\endinput