summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/circuitikz/pgfcircmath.sty
blob: bcde183dd9aade63661d7fe733fd0e8b32fd2bf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% Copyright 2007-2009 by Massimo Redaelli
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/LICENSE for more details.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%    Math routines

\def\pgf@circ@stripdecimals#1.#2\pgf@nil{#1}

% angle between 0 and 360
\def\pgf@circ@slope#1#2{%
 \pgf@process{#1}%
 \pgf@xa=\pgf@x%
 \pgf@ya=\pgf@y%
 \pgf@process{#2}%
 \advance\pgf@x by-\pgf@xa%
 \advance\pgf@y by-\pgf@ya%
 \ifdim\pgf@x<0.0001pt 
 	\ifdim\pgf@x>-0.0001pt % vertical
		\ifdim\pgf@y<0pt
			\def\pgfmathresult{-90.0}
		\else
			\def\pgfmathresult{+90.0}
		\fi 	
 	\else % oblique with dx < 0
		\pgfmathdivide{\pgf@y}{\pgf@x}
		\pgfmathatan{\pgfmathresult}
		\ifdim\pgf@x<0pt
			\pgfmathsubtract{\pgfmathresult}{+180}
		\fi
 	\fi
 \else % oblique with dx > 0
	\pgfmathdivide{\pgf@y}{\pgf@x}
	\pgfmathatan{\pgfmathresult}
	\ifdim\pgf@x<0pt
		\pgfmathsubtract{\pgfmathresult}{+180}
	\fi
 \fi
 \pgf@x=\pgfmathresult pt
 \ifdim\pgf@x<0pt
	\pgfmathadd{\pgfmathresult}{+360} 
 \fi
 }

\endinput