% These are macros for using TikZ and tkz-2d for drawing diagrams.
% As an abstraction on top of tkz-2d (which uses 'tkz'), these are prefixed
% with 'tky'. I tried to stay consisten with tkz-2d's naming scheme.
%
%% ----------------------------------------------------------------------------

%\def\tkyVar(#1)#2{
%%{
%	\newlength{#1}
%	\setlength{#1}{#2}
%}

%% -- cm Functions ------------------------------------------------------------

\def\tkyCircleR[#1](#2,#3){
%{
	\tkzCircleR[#1](#2,#3 cm)
}

\def\tkyInterLCR(#1,#2)(#3,#4)#5#6{
%{
	\tkzInterLCR(#1,#2)(#3,#4 cm){#5}{#6}
}

%% -- Vector Functions --------------------------------------------------------

% Create the unit vector the points from Point #1 to Point #2 and store the
% vector's components in #3.
%
\def\tkyUnitVect(#1,#2)#3{
%{
	\tkzGetPointxy(#1){p}
	\tkzGetPointxy(#2){q}
	\pgfmathparse{\qx-\px}\let\rx\pgfmathresult
	\pgfmathparse{\qy-\py}\let\ry\pgfmathresult

	\pgfmathparse{sqrt(\rx*\rx+\ry*\ry)}
	\let\tkymathresult\pgfmathresult

	\pgfmathparse{\rx/\tkymathresult}\let\rx\pgfmathresult
	\pgfmathparse{\ry/\tkymathresult}\let\ry\pgfmathresult

	\tkzPoint*(\rx,\ry){#3}
}

% Add Point #1 to Vector #2 and store the resulting point's components in
% Point #3.
\def\tkyPointVect(#1,#2)#3{
%{
	\tkzGetPointxy(#1){p}
	\tkzGetPointxy(#2){v}

	\pgfmathparse{\px+\vx}\let\rx\pgfmathresult
	\pgfmathparse{\py+\vy}\let\ry\pgfmathresult

	\tkzPoint*(\rx,\ry){#3}
}

% Add Point #1 to Vector #2 scaled by a factor of #3. The resulting point
% is store in Point #4.
\def\tkyPointVectL(#1,#2,#3)#4{
%{
	\tkzGetPointxy(#1){p}
	\tkzGetPointxy(#2){v}

	\pgfmathparse{\px+\vx*#3}\let\rx\pgfmathresult
	\pgfmathparse{\py+\vy*#3}\let\ry\pgfmathresult

	\tkzPoint*(\rx,\ry){#4}
}

% Add Point #1 to Vector #2 and store as Point #3. In addition, a vector from
% Point #1 to Point #3 is drawn.
\def\tkyDrawPointVect(#1,#2)#3{
%{
	\tkzGetPointxy(#1){p}
	\tkzGetPointxy(#2){v}

	\pgfmathparse{\px+\vx}\let\rx\pgfmathresult
	\pgfmathparse{\py+\vy}\let\ry\pgfmathresult

	\tkzPoint*(\rx,\ry){#3}
	\tkzDrawVector(#1/#3)
}

%
