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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
% 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.16 c}
\def\filedate{2011/06/01}
%<--------------------------------------------------------------------------–>
% !!! idea from Y. Combe !!!
%<--------------------------------------------------------------------------–>
%
% \tkzProtractor Protractor
%
% Rapporteur ajustable et positionable
%
% Par défaut:
% centre en (0,0)
% rayon de 5 cm
% ligne de base horizontale.
% épaisseur de ligne 0.4 pt
%
% Paramètres (optionnels, gérés par xkeyval)
% shift : coordonées (n'importe quelle forme
% acceptée par tikz).
% scale : facteur d'échelle
% rotate : rotation
% lw : line width (épaisseur des lignes)
% ce paramètre subit le facteur d'échelle.
%<--------------------------------------------------------------------------–>
\def\HalfProtractor{%
\tkzActivOff
\draw [fill=black!50!blue!20!,even odd rule,semitransparent](-160:5cm) -- (-20:5cm) arc (-20:200:5cm) -- cycle %
(-180:3.5cm) -- (0:3.5cm) arc (0:180:3.5cm) -- cycle;%
\draw (-90:0.3cm) -- (0,0)
(-135:0.3cm) -- (0,0)
(-45:0.3cm) -- (0,0);
\foreach \MO@i in {0,1,...,180}
\pgfmathparse{ 4.8 * (mod(\MO@i ,5)==0) + 4.9 * (mod(\MO@i ,5)>0) }
\draw (\MO@i:\pgfmathresult cm)--(\MO@i:5cm);
\foreach \d in {0,1,...,180}
\pgfmathparse{3.7 * (mod(\d,5)==0) + 3.6 * (mod(\d,5)>0)}
\draw (\d:\pgfmathresult cm)--(\d:3.5cm);
\draw (0: 4.6cm) node[font=\small] {0}
(0: 4cm) node[font=\small] {180};
\foreach \d in {10,20,...,80}
\pgfmathtruncatemacro{\rang}{180 - \d }
\draw (\d:3.9 cm) node[font=\tiny] {\rang}
(\d:4.6 cm) node[font=\tiny] {\d};
\draw (90: 4.25cm) node[font=\small] {90};
\draw (90: 4.6 cm) -- (90:5cm)
(90: 3.9 cm) -- (90:3.5cm) ;
\foreach \d in {100,110,...,170}
\pgfmathtruncatemacro{\rang}{180 - \d }
\draw (\d:3.9 cm) node[font=\tiny] {\rang}
(\d:4.6 cm) node[font=\tiny] {\d};
\draw (180: 4.5cm) node[font=\small] {180}
(180: 3.9cm) node[font=\small] {0};
\tkzActivOn
}
\def\FullProtractor{%
\tkzActivOff
\draw[fill=black!50!yellow!20!,even odd rule,semitransparent]%
(0,0) circle (4cm);
\draw (0,0) circle (3.3cm);\draw (0,0) circle (4cm);
\draw[fill=black] (0,0) circle (.08mm);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x in {0, 90, ..., 360}{%
\draw[very thin, gray!40] (a) -- (\x:4cm);}
\foreach \x in {0,...,359} {\draw (\x:3.8cm) -- (\x:4cm);}
\foreach \x in {0,5,...,355} {\draw (\x:3.725cm) -- (\x:4cm);}
\foreach \x in {0,10,...,350}{%
\node[rotate=(\x-90)] at (\x:3.6cm) {\tiny\x};
}
\draw [>=stealth',->, thick,black] (0:2.5) arc(0:32:2.5);
\draw [>=stealth',->, thick,black] (0:2) arc(0:32:2);
\draw [>=stealth',->, thick,black] (0:1.5) arc(0:32:1.5);
\tkzActivOn
}
\def\FullProtractorReturn{%
\tkzActivOff
\draw[fill=black!50!yellow!20!,even odd rule,semitransparent]%
(0,0) circle (4cm);
\draw (0,0) circle (3.3cm);\draw (0,0) circle (4cm);
\draw[fill=black] (0,0) circle (.08mm);
\node[draw, circle, inner sep=.2mm] (a) at (0,0) {};
\foreach \x in {0, 90, ..., 360}{%
\draw[very thin, gray!40] (a) -- (\x:4cm);}
\foreach \x in {0,...,359} {\draw (\x:3.8cm) -- (\x:4cm);}
\foreach \x in {0,5,...,355} {\draw (\x:3.725cm) -- (\x:4cm);}
\begin{scope}
\foreach \x in {0,10,...,350}{%
\node[rotate=(-\x-90)] at (-\x:3.6cm) {\tiny\x};
}
\end{scope}
\draw [>=stealth',->, thick,black] (0:2.5) arc(0:-32:2.5);
\draw [>=stealth',->, thick,black] (0:2) arc(0:-32:2);
\draw [>=stealth',->, thick,black] (0:1.5) arc(0:-32:1.5);
\tkzActivOn
}
\newif\iftkz@RappReturn
\newif\iftkz@RappFull
\pgfkeys{
protractor/.cd,
with/.is choice,
with/full/.code = {\global\let\tkz@@Protractor\FullProtractor
\tkz@RappFulltrue},
with/half/.code = {\global\let\tkz@@Protractor\HalfProtractor
\tkz@RappFullfalse},
with/.default = full,
lw/.code = {\def\cmdMO@Rap@lw{#1}},
shift/.code = {\def\cmdMO@Rap@shift{#1}},
rotate/.code = {\def\cmdMO@Rap@rotate{#1}},
scale/.code = {\def\cmdMO@Rap@scale{#1}},
return/.is if = tkz@RappReturn,
return/.default = true
}
\def\tkzOriProtractor{\pgfutil@ifnextchar[{\tkz@OriProtractor}{%
\tkz@OriProtractor[]}}
\def\tkz@OriProtractor[#1]{
\pgfkeys{/protractor/.cd,
with=full,
shift={(0,0)},
rotate=0,
lw=0.4pt,
scale =1,
return=false
}
\pgfqkeys{/protractor}{#1}
\pgfmathsetlengthmacro{\MO@lw}{\cmdMO@Rap@lw * \cmdMO@Rap@scale}
\begin{scope}[shift = \cmdMO@Rap@shift,%
scale = \cmdMO@Rap@scale,%
rotate = \cmdMO@Rap@rotate,%
every node/.style = {scale =\cmdMO@Rap@scale,
rotate =\cmdMO@Rap@rotate},%
line width=\MO@lw
]%
\tkz@@Protractor
\end{scope}
}
\def\tkzProtractor{\pgfutil@ifnextchar[{\tkz@Protractor}{\tkz@Protractor[]}}
\def\tkz@Protractor[#1](#2,#3){
\pgfkeys{/protractor/.cd,
with=full,
shift={(0,0)},
rotate=0,
lw=0.4pt,
scale =1,
return=false
}
\pgfqkeys{/protractor}{#1}
\tkz@@extractxy{#2}
\global\tkz@ax\pgf@x
\global\tkz@ay\pgf@y
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{cmdMO@Rap@rotate}%
\iftkz@RappFull
\iftkz@RappReturn
\global\let\tkz@@Protractor\FullProtractorReturn
\fi
\pgfmathsetlengthmacro{\MO@lw}{\cmdMO@Rap@lw * \cmdMO@Rap@scale}
\begin{scope}[shift = {(\tkz@ax,\tkz@ay)},%
scale = \cmdMO@Rap@scale,%
rotate = \cmdMO@Rap@rotate,%
every node/.style = {scale =\cmdMO@Rap@scale,
rotate =\cmdMO@Rap@rotate},%
line width=\MO@lw]%
\tkz@@Protractor
\end{scope}
\else
\iftkz@RappReturn%
\pgfmathsubtract{\cmdMO@Rap@rotate}{180}
\let\cmdMO@Rap@rotate\pgfmathresult
\fi
\pgfmathsetlengthmacro{\MO@lw}{\cmdMO@Rap@lw * \cmdMO@Rap@scale}
\begin{scope}[shift = {(\tkz@ax,\tkz@ay)},%
scale = \cmdMO@Rap@scale,%
rotate = \cmdMO@Rap@rotate,%
every node/.style = {scale =\cmdMO@Rap@scale,
rotate =\cmdMO@Rap@rotate},%
line width=\MO@lw]%
\tkz@@Protractor
\end{scope}
\fi
}
%<--------------------------------------------------------------------------–>
% fin de \tkzProtractor
%<--------------------------------------------------------------------------–>
\endinput
|