summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/schulmathematik/schulma-physik.sty
blob: b3996d6cc2df5645d1eb9ad14a394377f55b8998 (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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
% schulmathematik bundle: package schulma-physik
% Version 1.3
% 12. August 2022
\ProvidesExplPackage{schulma-physik}{2022-08-12}{1.3}{Befehle für die Schulphysik}

\RequirePackage {siunitx}
\RequirePackage {tikz}

\sisetup { locale = DE , uncertainty-mode = separate }

\NewDocumentCommand \Massstab {m m m m}
  {
    \ensuremath
      {
        \qty {#1} {#2}
        \; \widehat {=} \;
        \qty {#3} {#4}
      }
  }

\NewDocumentCommand \tqty {m m}
  {
    \ensuremath
      {  
        \group_begin:
        \textstyle
        \qty [ per-mode = fraction ] {#1} {#2}
        \group_end:
      }
  }

\cs_new_eq:NN \tSI \tqty

\NewDocumentCommand \tunit {m}
  {
    \ensuremath
      {  
        \group_begin:
        \textstyle
        \unit [ per-mode = fraction ] {#1}
        \group_end:
      }
  }

\cs_new_eq:NN \tsi \tunit

\NewDocumentCommand \Beschl {m}
  {
    \tqty {#1} { \m \per \square \s }
  }

\NewDocumentCommand \Erdb { }
  {
    \tqty {9,81} { \m \per \square \s }
  }

\NewDocumentCommand \Ortsf { }
  {
    \tqty {9,81} { \N \per \kg }
  }

\NewDocumentCommand \Elem { }
  {
    \qty {1,60e-19} {\coulomb}
  }

\NewDocumentCommand \Elekm { }
  {
    \qty {9,11e-31} {\kg}
  }

\NewDocumentCommand \Lichtg { }
  {
    \qty {3,00e8} { \m \per \s }
  }

\NewDocumentCommand \Planck { }
  {
    \qty {6,63e-34} { \J \s }
  }

\NewDocumentCommand \EFK { }
  {
    \qty {8,85e-12} { \A \s \per \V \per \m }
  }

\NewDocumentCommand \MFK {s}
  {
    \IfBooleanTF {#1}
      {
        \qty {1,26e-6} { \V \s \per \A \per \m }
      }
      {
        \ensuremath
          {
            4 \,
            \cs_if_exist_use:N \symup
            \pi
            \cdot
            \qty [ print-unity-mantissa = false ] {e-7} { \V \s \per \A \per \m }
          }
      }
  }

\dim_const:Nn \c_schulma_physik_messschieber_l_skala_dim {15.2cm}
\dim_const:Nn \c_schulma_physik_messschieber_b_skala_dim {15mm}
\dim_const:Nn \c_schulma_physik_messschieber_l_schieber_dim {4cm}
\dim_const:Nn \c_schulma_physik_messschieber_b_schieber_dim {17mm}
\dim_const:Nn \c_schulma_physik_messschieber_l_fenster_dim {25mm}
\dim_const:Nn \c_schulma_physik_messschieber_b_fenster_dim {1cm}

\NewDocumentCommand \Messschieber {m}
  {
    \begin {tikzpicture} [ font = \sffamily ]
    % Hauptskala
    \draw ( -1.6cm , -0.5 * \c_schulma_physik_messschieber_b_skala_dim + 0.5 * \c_schulma_physik_messschieber_b_fenster_dim )
      -- ++ ( \c_schulma_physik_messschieber_l_skala_dim , 0 ) node [ above~left ] { \small cm }
      -- ++ ( 0 , \c_schulma_physik_messschieber_b_skala_dim )
      -- ++ ( - \c_schulma_physik_messschieber_l_skala_dim , 0)
      -- cycle ;
    \int_step_inline:nnn {0} {120}
      {
        \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {10} }
        \int_compare:nNnTF {\l_tmpa_int} = {0}
          {
            \draw (##1*1mm,-1mm)--(##1*1mm,6mm) node [ left , xshift=2pt , yshift = -2pt ]
              { \footnotesize \int_eval:n {##1/10} } ;
          }
          {
            \int_compare:nNnTF {\l_tmpa_int} = {5}
              {
                \draw (##1*1mm,-1mm)--(##1*1mm,4.5mm);
              }
              {
                \draw (##1*1mm,-1mm)--(##1*1mm,3mm);
              }
          }
      }
    % Schieber
    \draw [ fill = white , even~odd~rule ]
      ( #1cm - 0.5 * \c_schulma_physik_messschieber_l_schieber_dim + 4.5mm ,
        -0.5 * \c_schulma_physik_messschieber_b_schieber_dim + 0.5 * \c_schulma_physik_messschieber_b_fenster_dim )
      rectangle ++ ( \c_schulma_physik_messschieber_l_schieber_dim , \c_schulma_physik_messschieber_b_schieber_dim )
      { [rounded~corners = 0.5 * \c_schulma_physik_messschieber_b_fenster_dim ]
        ( #1cm - 0.5 * \c_schulma_physik_messschieber_l_fenster_dim + 4.5mm , 0 )
        rectangle ++ ( \c_schulma_physik_messschieber_l_fenster_dim , \c_schulma_physik_messschieber_b_fenster_dim ) } ;
    % Noniusskala
    \int_step_inline:nnn {0} {10}
      {
        \int_set:Nn \l_tmpa_int { \int_mod:nn {##1} {10} }
        \int_compare:nNnTF {\l_tmpa_int} = {0}
          {
            \draw ( #1cm + ##1 * 0.9mm , 0 ) -- ( #1cm + ##1 * 0.9mm , -1.6mm ) ;
          }
          {
            \int_compare:nNnTF {\l_tmpa_int} = {5}
              {
                \draw ( #1cm + ##1 * 0.9mm , 0 ) -- ( #1cm + ##1 * 0.9mm , -1.3mm ) ;
              }
              {
                \draw ( #1cm + ##1 * 0.9mm , 0 ) -- ( #1cm + ##1 * 0.9mm , -1mm ) ;
              }
          }
      }
    \end{tikzpicture}
  }

\dim_new:N \l_schulma_physik_messschraube_massstab_dim
\dim_set:Nn \l_schulma_physik_messschraube_massstab_dim {2mm}
\dim_new:N \l_schulma_physik_messschraube_skalenstrich_y_dim
\dim_new:N \l_schulma_physik_messschraube_skalenstrich_deltay_dim
\int_new:N \l_schulma_physik_messschraube_skalenbeschriftung_int
\fp_new:N \l_schulma_physik_messschraube_hundertstelbruchteile_fp

\NewDocumentCommand \Messschraube {m}
  {
    % nach: dexteritas, https://tex.stackexchange.com/questions/472876/how-to-draw-micrometer-scale-using-tikz
    \begin{tikzpicture} [ font = \sffamily ]
    % horizontale Skala
    \draw [semithick] (0,0) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , 0 ) ;
    \int_step_inline:nnn {0} { \fp_to_int:n {#1} + 2 }
      {
        \int_compare:nNnTF { \int_mod:nn {##1} {5} } = {0}
          {
            \draw [thick] ( ##1 * \l_schulma_physik_messschraube_massstab_dim , -0.5 ) -- ++ (0,0.65) node [above] { \small ##1 } ;
          }
          {
            \draw ( ##1 * \l_schulma_physik_messschraube_massstab_dim , 0) -- ++ (0,-0.5) ;
          }
      }
    \node [ above~right ] at (-5mm,-1cm) {\small mm} ;
    % drehbare Skala
    \fp_set:Nn \l_schulma_physik_messschraube_hundertstelbruchteile_fp { #1 * 100 - \fp_to_int:n { #1 * 100} }
    \fill [white] ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) -- ++ (8mm,5mm) -- ++ (0,-3cm) -- ++ (-8mm,5mm) -- cycle ;
    \draw [thin] ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1 ) -- ++ (0,-2cm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) -- ++ (8mm,5mm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , -1cm ) -- ++ (8mm,-5mm) ;
    \int_step_inline:nnn {-17} {17}
      {
        \int_set:Nn \l_schulma_physik_messschraube_skalenbeschriftung_int
          {
            \int_mod:nn { \fp_to_int:n { #1 * 100 } + ##1 } {100}
          }
        \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_y_dim
          {
            \fp_eval:n { ( ##1 - \l_schulma_physik_messschraube_hundertstelbruchteile_fp ) / 18 } cm
          }
        \int_compare:nNnTF { \int_mod:nn {\l_schulma_physik_messschraube_skalenbeschriftung_int} {5} } = {0}
          {
            % langer Strich mit Zahl
            \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_deltay_dim { 4.375mm * ##1/18 }
            \int_compare:nNnTF {\l_schulma_physik_messschraube_skalenbeschriftung_int} < {10}
              {
                \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
                  -- ++ ( 7mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim )
                  node [right] { \footnotesize 0 \int_to_arabic:n {\l_schulma_physik_messschraube_skalenbeschriftung_int} } ;
              }
              {
                \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
                  -- ++ ( 7mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim )
                  node [right] { \footnotesize \int_to_arabic:n {\l_schulma_physik_messschraube_skalenbeschriftung_int} } ;
              }
          }
          {
            % kurzer Strich
            \dim_set:Nn \l_schulma_physik_messschraube_skalenstrich_deltay_dim { 2.5mm * ##1/18 }
            \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim , \l_schulma_physik_messschraube_skalenstrich_y_dim )
              -- ++ ( 4mm , \l_schulma_physik_messschraube_skalenstrich_deltay_dim ) ;
          }
       }
    % oberer und unterer Rand
    \draw (-5mm,1cm) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , 1cm ) ;
    \draw (-5mm,-1cm) -- ( #1 * \l_schulma_physik_messschraube_massstab_dim , -1cm ) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 8mm, 1.5cm ) -- ++ (2cm,0) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 8mm, -1.5cm ) -- ++ (2cm,0) ;
    % geschwungene Linien links und rechts
    \draw (-5mm,-1cm) to [ out=130 , in=-130 ] (-5mm,0) to [ out=130 , in=-130 ] (-5mm,1cm) ;
    \draw [very~thin] (-5mm,0) to [ out=50 , in=-50 ] (-5mm,1cm) ;
    \draw ( #1 * \l_schulma_physik_messschraube_massstab_dim + 2.8cm , 1.5cm ) to [ out=-50 , in=50 ] ++ (0,-1.5cm) to [ out=-50 , in=50 ] ++ (0,-1.5cm) ;
    \draw [very~thin] ( #1 * \l_schulma_physik_messschraube_massstab_dim + 2.8cm , 0 ) to [ out=130 , in=-130 ] ++ (0,1.5cm) ;
    \end{tikzpicture}
  }

\ExplSyntaxOff

\usetikzlibrary{circuits.ee.IEC}

\pgfdeclareshape{doppelbuchse}
  {%
    \inheritsavedanchors[from=rectangle ee]%
    \inheritanchor[from=rectangle ee]{center}%
    \inheritanchor[from=rectangle ee]{north}%
    \inheritanchor[from=rectangle ee]{south}%
    \inheritanchor[from=rectangle ee]{east}%
    \inheritanchor[from=rectangle ee]{west}%
    \inheritanchor[from=rectangle ee]{north east}%
    \inheritanchor[from=rectangle ee]{north west}%
    \inheritanchor[from=rectangle ee]{south east}%
    \inheritanchor[from=rectangle ee]{south west}%
    \inheritanchor[from=rectangle ee]{input}%
    \inheritanchor[from=rectangle ee]{output}%
    \inheritanchorborder[from=rectangle ee]%
    \backgroundpath{
      \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}%
      \pgf@xa=\pgf@x \pgf@ya=\pgf@y
      \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}}%
      \pgf@xb=\pgf@x \pgf@yb=\pgf@y
      \pgfutil@tempdima=\pgf@yb%
      \advance\pgfutil@tempdima by -\pgf@ya%
      \pgfutil@tempdima=0.5\pgfutil@tempdima%
      \advance\pgf@xa by \pgfutil@tempdima%
      \advance\pgf@xb by -\pgfutil@tempdima%
      {\pgfpathcircle{\pgfqpoint{\pgf@xa}{0pt}}{\pgfutil@tempdima}}
      {\pgfpathcircle{\pgfqpoint{\pgf@xb}{0pt}}{\pgfutil@tempdima}}
    }%
  }

\tikzset
  {
    bulb IEC graphic/.style=
      {
        circuit symbol lines,
        circuit symbol size=width 1.9 height 1.9,
        shape=generic circle IEC,
        /pgf/generic circle IEC/before background=
          {
            \pgfpathmoveto{\pgfpointpolar{-135}{1pt}}
            \pgfpathlineto{\pgfpointpolar{45}{1pt}}
            \pgfpathmoveto{\pgfpointpolar{-45}{1pt}}
            \pgfpathlineto{\pgfpointpolar{135}{1pt}}
            \pgfusepathqstroke
          },
        transform shape,
      },
    capacitor IEC graphic/.style=
      {
        circuit symbol lines,
        circuit symbol size=width 0.8 height 2.4,
        transform shape,
        shape=capacitor IEC,
      },
    amperemeter graphic/.style=
      {
        circuit symbol open,
        circuit symbol size=width 2 height 2,
        transform shape,
        shape=generic circle IEC,
        info=center:{\sffamily A}
      },
    voltmeter graphic/.style=
      {
        circuit symbol open,
        circuit symbol size=width 2 height 2,
        transform shape,
        shape=generic circle IEC,
        info=center:{\sffamily V}
      },
    circuit declare symbol=messgeraet,
    set messgeraet graphic=
      {
        circuit symbol open,
        circuit symbol size=width 2 height 2,
        transform shape,
        shape=generic circle IEC,
        /pgf/generic circle IEC/before background=
          {
            \draw[annotation arrow,->] (0.58pt,-0.58pt)--(-0.58pt,0.58pt);
          }
      },
    circuit declare symbol=spannungsquelle,
    set spannungsquelle graphic=
      {
        circuit symbol open,
        circuit symbol size=width 2.4 height 0.5,
        transform shape,
        shape=doppelbuchse,
        outer sep=0pt
      },
  }