%%
%% arrow.sty
%% Copyright 2008 Shouri Chatterjee
%% v0.1, Oct 30, 2008
%% v0.2, Nov  2, 2008
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Shouri Chatterjee.
%
% This work consists of the files arrow.sty, arrowstyle.tex.
%
% Use this package to give you beautiful arrows, when you use
% the \vector command in the picture environment
% 

\ProvidesPackage{arrow}
\RequirePackage{pstricks}

\let\vectorOLD=\vector

\newdimen\arrowscale
\arrowscale=0.4pt

\def\arrowhead#1{
\psset{unit=\arrowscale}
\pscustom[fillstyle=solid,fillcolor=black]{
\rotate{#1}
\newpath
\moveto(8,-28)
\curveto(3,-18)(3,-15)(0,0)
\curveto(-3,-15)(-3,-18)(-8,-28)
\curveto(-2,-26)(2,-26)(8,-28)
\closepath
}}

\newcount\angle \newcount\tmp \newcount\den \newcount\tmpangle
\newcount\iii
	\newcommand{\ataniteratex}{
		\ifnum \iii < 10
		\multiply\tmp by \yy \multiply\tmp by -\yy
		\divide\tmp by \xx \divide\tmp by \xx
		\advance\den by 2
		\tmpangle=\tmp \divide\tmpangle by \den
		\advance\angle\tmpangle
		\let\next=\ataniteratex
		\advance\iii 1
		\next
		\fi }
	\newcommand{\ataniteratey}{
		\ifnum \iii < 10
			\multiply\tmp by \xx \multiply\tmp by -\xx
			\divide\tmp by \yy \divide\tmp by \yy
			\advance\den by 2
			\tmpangle=\tmp \divide\tmpangle by \den
			\advance\angle\tmpangle
			\let\next=\ataniteratey
			\advance\iii 1
			\next
		\fi }
\def\arctangent#1#2{
\ifnum #1 < 0 \xx=-#1 \else \xx=#1 \fi
\ifnum #2 < 0 \yy=-#2 \else \yy=#2 \fi
\ifnum \xx > \yy
	\angle=\yy \multiply\angle by 57 \divide\angle by \xx
	\tmp=\angle \iii=0 \den=1
	\ataniteratex
	\advance\angle -90
\else
	\angle=\xx \multiply\angle by 57 \divide\angle by \yy
	\tmp=\angle \iii=0 \den=1
	\ataniteratey
	\angle=-\angle
\fi
\ifnum #1 < 0
	\ifnum #2 < 0 % Q3
		\advance\angle 180
	\else % Q2
		\angle=-\angle
	\fi
\else
	\ifnum #2 < 0 % Q4
		\angle=-\angle \advance\angle 180
	\else % Q1
		\relax
	\fi
\fi
}

\newcount\xx \newcount\yy \newdimen\vlen \newdimen\xpos \newdimen\ypos
\def\vector(#1,#2)#3{
\arctangent{#1}{#2}
\put(0,0){\line(#1,#2){#3}}
\xx=#1 \yy=#2 \vlen=#3\unitlength
\ifnum \xx = 0
	\xpos=0\unitlength
	\ifnum \yy =  1 \ypos=\vlen \fi
	\ifnum \yy = -1 \ypos=-\vlen \fi
\else
	\ifnum \xx > 0 \xpos=\vlen \fi
	\ifnum \xx < 0 \xpos=-\vlen \fi
	\ypos=\xpos \multiply\ypos by \yy \divide\ypos by \xx
\fi
\raise\ypos\hbox{\hskip\xpos\arrowhead{\number\angle}}
}

\endinput


