summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/texdraw/txdtools.tex
blob: c3d5ee1aa01757721a29da208e5a3c4d29f832d5 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% TeXdraw toolbox macros, useful for extended TeXdraw commands

% $Id: txdtools.tex,v 1.8 1993/04/10 texdraw-V2R0 $

%   Copyright (C) 1991,1992  Peter Kabal

% The routines in this file are provided free of charge without
% warranty of any kind.  Note that the TeXdraw routines are copyrighted.
% They may be distributed freely provided that the recipients also
% acquire the right to distribute them freely.  The notices to this
% effect must be preserved when the files are distributed.

%  Peter Kabal
%  Department of Electrical Engineering
%  McGill University
%  3480 University
%  Montreal, Quebec
%  Canada  H3A 2A7

%  kabal@TSP.EE.McGill.CA
\chardef\catamp=\the\catcode`\@
\catcode`\@=11
\def\realadd #1#2#3{\dimen0=#1pt
\dimen2=#2pt
\advance \dimen0 by \dimen2
\edef #3{\expandafter\c@lean\the\dimen0}}
\def\realdiv #1#2#3{\dimen0=#1pt
\t@counta=\dimen0
\dimen0=#2pt
\t@countb=\dimen0
\intdiv \t@counta \t@countb #3}
\def\lenhyp #1#2#3{\t@counta=#1%
\multiply \t@counta by \t@counta
\t@countb=#2%
\multiply \t@countb by \t@countb
\advance \t@counta by \t@countb
\sqrtnum \t@counta #3}
\let\bk=\t@counta
\let\bn=\t@countb
\let\xval=\t@countc
\def\sqrtnum #1#2{\xval=#1%
\bk=\xval
\loop
\bn=\xval
\divide \bn by \bk
\advance \bn by \bk
\advance \bn by 1
\divide \bn by 2
\ifnum \bn < \bk
\bk=\bn
\repeat
#2=\bn}
\def\currentpos #1#2{\t@pixa=\x@pix
\advance \t@pixa by -\x@segoffpix
\pixtocoord \t@pixa #1
\t@pixa=\y@pix
\advance \t@pixa by -\y@segoffpix
\pixtocoord \t@pixa #2}
\def\vectlen (#1 #2)(#3 #4)#5{\getpos (#1 #2)\x@arga\y@arga
\getpos (#3 #4)\x@argb\y@argb
\coordtopix \x@arga \t@pixa
\coordtopix \x@argb \t@pixb
\advance \t@pixb by -\t@pixa
\coordtopix \y@arga \t@pixc
\coordtopix \y@argb \t@pixd
\advance \t@pixd by -\t@pixc
\lenhyp \t@pixb \t@pixd \t@pixc
\pixtocoord \t@pixc #5}
\def\cossin (#1 #2)(#3 #4)#5#6{\getpos (#1 #2)\x@arga\y@arga
\getpos (#3 #4)\x@argb\y@argb
\coordtopix \x@arga \t@pixa
\coordtopix \x@argb \t@pixb
\advance \t@pixb by -\t@pixa
\coordtopix \y@arga \t@pixc
\coordtopix \y@argb \t@pixd
\advance \t@pixd by -\t@pixc
\lenhyp \t@pixb \t@pixd \t@pixc
\intdiv \t@pixb\t@pixc #5%
\intdiv \t@pixd\t@pixc #6}
\catcode`\@=\catamp