Debian Codegraph @

texmf-dist/source/latex/glmatrix/glmatrix.dtx

raw
1 % \iffalse meta-comment
2 % !TEX program = pdfLaTeX
3 %<*internal>
4 \iffalse
5 %</internal>
6 %<*readme>
7 ----------------------------------------------------------------
8 glmatrix v1.0.0 --- This package provides macros for linear algebra calculations with scalars, vectors, and matrices. Its structure is based on the JavaScript library glmatrix.js, and it similarly provides several convenience functions often used in computer graphics contexts, like creating a translation matrix.
9 E-mail: [email protected]
10
11 Released under BSD 3-Clause License
12
13 BSD 3-Clause License
14
15 Copyright (c) 2026, Rene Warnking
16
17 Redistribution and use in source and binary forms, with or without
18 modification, are permitted provided that the following conditions are met:
19
20 1. Redistributions of source code must retain the above copyright notice, this
21 list of conditions and the following disclaimer.
22
23 2. Redistributions in binary form must reproduce the above copyright notice,
24 this list of conditions and the following disclaimer in the documentation
25 and/or other materials provided with the distribution.
26
27 3. Neither the name of the copyright holder nor the names of its
28 contributors may be used to endorse or promote products derived from
29 this software without specific prior written permission.
30
31 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
35 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ----------------------------------------------------------------
43
44 This package provides macros for linear algebra calculations with scalars, vectors, and matrices. Its structure is based on the JavaScript library glmatrix.js, and it similarly provides several convenience functions often used in computer graphics contexts, like creating a translation matrix.
45 %</readme>
46
47 %<*internal>
48 \fi
49 \def\nameofplainTeX{plain}
50 \ifx\fmtname\nameofplainTeX\else
51 \expandafter\begingroup
52 \fi
53 %</internal>
54 %<*install>
55 \input docstrip.tex % chktex 27
56 \keepsilent
57 \askforoverwritefalse
58 \preamble
59 ---------------------------------------------------------------
60 glmatrix v1.0.0 --- This package provides macros for linear algebra calculations with scalars, vectors, and matrices. Its structure is based on the JavaScript library glmatrix.js, and it similarly provides several convenience functions often used in computer graphics contexts, like creating a translation matrix.
61 Maintained by Rene Warnking
62 E-mail: [email protected]
63
64 Released under BSD 3-Clause License
65
66 BSD 3-Clause License
67
68 Copyright (c) 2026, Rene Warnking
69
70 Redistribution and use in source and binary forms, with or without
71 modification, are permitted provided that the following conditions are met:
72
73 1. Redistributions of source code must retain the above copyright notice, this
74 list of conditions and the following disclaimer.
75
76 2. Redistributions in binary form must reproduce the above copyright notice,
77 this list of conditions and the following disclaimer in the documentation
78 and/or other materials provided with the distribution.
79
80 3. Neither the name of the copyright holder nor the names of its
81 contributors may be used to endorse or promote products derived from
82 this software without specific prior written permission.
83
84 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
85 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
88 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
91 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
92 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
93 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94
95 ---------------------------------------------------------------
96 \endpreamble
97 \postamble
98 Copyright (C) 2026/04/03 by
99 Rene Warnking <[email protected]>
100
101 Released under BSD 3-Clause License
102
103 BSD 3-Clause License
104
105 Copyright (c) 2026, Rene Warnking
106
107 Redistribution and use in source and binary forms, with or without
108 modification, are permitted provided that the following conditions are met:
109
110 1. Redistributions of source code must retain the above copyright notice, this
111 list of conditions and the following disclaimer.
112
113 2. Redistributions in binary form must reproduce the above copyright notice,
114 this list of conditions and the following disclaimer in the documentation
115 and/or other materials provided with the distribution.
116
117 3. Neither the name of the copyright holder nor the names of its
118 contributors may be used to endorse or promote products derived from
119 this software without specific prior written permission.
120
121 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
122 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
123 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
124 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
125 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
126 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
127 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
128 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
129 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
130 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
131
132
133 This work is maintained by
134 Rene Warnking.
135
136 This work consists of the file glmatrix.dtx
137 and the derived files glmatrix.pdf,
138 glmatrix.sty and
139 glmatrix.ins.
140
141 \endpostamble
142 \usedir{tex/latex/glmatrix}
143 \generate{
144 \file{glmatrix.sty}{\from{glmatrix.dtx}{package}}
145 }
146 %</install>
147 %<install>\endbatchfile
148 %<*internal>
149 \usedir{source/latex/glmatrix}
150 \generate{
151 \file{glmatrix.ins}{\from{glmatrix.dtx}{install}}
152 }
153 \nopreamble\nopostamble
154 \usedir{doc/latex/glmatrix}
155 \generate{
156 \file{README.txt}{\from{glmatrix.dtx}{readme}}
157 }
158 \ifx\fmtname\nameofplainTeX
159 \expandafter\endbatchfile
160 \else
161 \expandafter\endgroup
162 \fi
163 %</internal>
164
165 %<*package>
166 \NeedsTeXFormat{LaTeX2e}
167 \ProvidesPackage{glmatrix}[2026/04/03 v1.0.0 Macros for linear algebra calculations common in computer graphics]
168
169 \RequirePackage{xinttools}
170 \RequirePackage{xintfrac}
171 \RequirePackage{fp}
172
173 \newcommand{\R}{\ensuremath{\textrm{I\!R}}}
174 \newcommand{\trans}[1]{\ensuremath{{#1}\mkern-1mu^{\mathsf{T}}}}
175 \newcommand{\norm}[1]{\ensuremath{\left\Vert #1 \right\Vert}}
176
177 %</package>
178
179 %<*driver>
180 \documentclass{ltxdoc}
181 \usepackage{xcolor}
182 \definecolor{uos-red}{cmyk}{0.2, 1, 0.65, 0.25}
183
184 \usepackage{etoc}
185 \setcounter{tocdepth}{2} % show only sections and subsections
186 \usepackage{hyperref}
187 \hypersetup{
188 linkcolor=uos-red,
189 }
190 \usepackage{tabularx}
191 \usepackage{ltablex}
192 \usepackage{makecell}
193
194 \usepackage{amsmath}
195
196 \usepackage{tcolorbox}
197
198 \usepackage{listings}
199
200 \tcbset{
201 mydocbox/.style={
202 sharp corners,
203 boxrule=0.8pt,
204 left=6pt,
205 right=6pt,
206 top=6pt,
207 bottom=6pt,
208 % breakable
209 }
210 }
211
212 % Red box
213 \newtcolorbox{descriptionbox}{
214 mydocbox,
215 colback=gray!15,
216 colframe=gray!75!black,
217 title=Description,
218 fonttitle=\bfseries
219 }
220
221 % Red box
222 \newtcolorbox{warningbox}{
223 mydocbox,
224 colback=red!15,
225 colframe=red!75!black,
226 title=Warning,
227 fonttitle=\bfseries
228 }
229
230 % Blue box
231 \newtcolorbox{equationbox}{
232 mydocbox,
233 colback=blue!10,
234 colframe=blue!70!black,
235 title=Equation,
236 fonttitle=\bfseries
237 }
238
239 % Yellow box
240 \newtcolorbox{examplebox}{
241 mydocbox,
242 colback=yellow!20,
243 colframe=yellow!60!black,
244 title=Example,
245 fonttitle=\bfseries
246 }
247
248 \lstdefinelanguage{latex}
249 {
250 sensitive=true,
251 alsoletter={\\},
252 morekeywords=[1]{
253 \\newVec, \\addVec, \\newMat, \\newDiagMat, \\mulMat, \\transformVec, \\printMat, \\printVec, \\begin, \\end, \\left, \\right
254 },
255 morekeywords=[2]{
256 align
257 },
258 morekeywords=[3]{
259 \\myMatA, \\myMatB, \\myVecV, \\myVecW, \\mulMatResult, \\addVecResult, \\transformVecResult
260 },
261 }
262
263 % [LaTeX]TeX
264 \lstdefinestyle{latexStyle}{
265 language=latex,
266 tabsize=2,
267 basicstyle=\footnotesize\ttfamily,
268 upquote=true,
269 % frame=leftline,
270 columns=fixed,
271 showstringspaces=false,
272 extendedchars=true,
273 breaklines=true,
274 aboveskip=1em,
275 belowskip=0.1em,
276 showtabs=false,
277 showspaces=false,
278 showstringspaces=false,
279 numberstyle=\color[rgb]{0.5,0.5,0.5},
280 identifierstyle=\ttfamily,
281 commentstyle=\color[rgb]{.3, .53, .42},
282 comment=[l]\%,
283 %\color{syntaxComment},
284 keywordstyle=[1]\color[rgb]{.13, .13, 1},
285 keywordstyle=[2]\color[rgb]{.19, .52, .58},
286 keywordstyle=[3]\color[rgb]{.51, .25, .73},
287 keywordstyle=[4]\color[rgb]{0.4,0.4,0.4},
288 stringstyle=\color[rgb]{0.639,0.082,0.082},
289 }
290
291 % \usepackage{etoolbox}
292 % \appto{DescribeMacro}{\color{blue}}
293
294 % \usepackage[a4paper, left=2.5cm, right=2.5cm, top=2cm, bottom=2cm]{geometry}
295
296 \setlength{\parindent}{0pt}
297
298 \usepackage{fancyhdr}
299
300 % TODO make this modular
301 \pagestyle{fancy}
302 \fancyhf{}
303 \fancyhead[C]{%
304 \hyperref[subsec:scalar]{Scalar} |
305 \hyperref[subsec:vector]{Vector} |
306 \hyperref[subsec:matrix]{Matrix}
307 }
308 \renewcommand{\headrulewidth}{0.4pt}
309
310 \makeatletter
311 \newcommand{\setlabel}[2]{%
312 \phantomsection
313 \def\@currentlabel{\unexpanded{#1}}\label{#2}%
314 }
315 \makeatother
316 \EnableCrossrefs
317 \CodelineIndex
318 \RecordChanges
319 \begin{document}
320 \title{The \textsf{glmatrix} Package}
321 \author{Rene Warnking}
322 \date{Version 1.0.0\\2026/04/03}
323 \maketitle
324
325 \tableofcontents
326
327 \section{Introduction}
328
329 The \texttt{glmatrix} package provides a small set of macros that allow you to
330 do basic vector and matrix arithmetics in \LaTeX. It is inspired by the javascript
331 library with the same name (https://glmatrix.net/) and provides the same functions and more.
332 Using this package, you can easily do vector calculations like dot and cross
333 product as well as more complex calculations, like vector matrix multiplication.
334
335 The package is specifically targeting use cases in computer graphics.
336 Consequently, it provides macros for vector transformations using matrices and
337 the creation of commonly used matrices in computer graphics, like the lookAt matrix.
338 In combination, these macros allow you to do many calculations that regularly occurr in computer graphics.
339
340 \clearpage
341
342 \section{Example}
343
344 Given the following equation:
345 \[A B (\vec{v} + \vec{w})\ \vert\ v, w \in \R^3, A, B \in \R^{3\times3}\]
346
347 The code below recreates the equation with exemplary values and directly calculates the results.
348 Then, the results are used to print a step-by-step solution with the chosen values.\\
349 Note:
350 \begin{itemize}
351 \setlength\itemsep{0em}
352 \item While creating a new vector or matrix is done by providing its name as a simple string, accessing its content after creation is done as a command (with backslash)
353 \item This package mainly provides macros for mathematical calculations. These macros assign the calculated result automatically to a variable using the optional parameter (for example \textbackslash addVec). If you wish to specify the name of the variable yourself, you may pass a string for the optional argument.
354 \end{itemize}
355
356 \lstset{style=latexStyle}
357 \begin{lstlisting}[gobble=4]
358 % Initialize two vectors and add them together
359 \newVec{myVecV}{1,2,3}
360 \newVec{myVecW}{7,8,9}
361 \addVec[addVecResult]{\myVecV}{\myVecW}
362
363 % Initialize two matrices and multiply them with each other
364 \newMat{myMatA}{{{0.5,2,3}{4,5,6}{7,8,9}}}
365 \newDiagMat{myMatB}{2, 3, 4}
366 \mulMat[mulMatResult]{\myMatA}{\myMatB}
367
368 % Transform the result vector with the created matrix
369 \transformVec{\mulMatResult}{\addVecResult}
370
371 % Print a step-by-step solution
372 \begin{align}
373 \printMat{\myMatA} \printMat{\myMatB}
374 \left(\printVec{\myVecV} + \printVec{\myVecW}\right)
375 =
376 \printMat{\mulMatResult}
377 \printVec{\addVecResult}
378 =
379 \printVec{\transformVecResult}
380 \end{align}
381 \end{lstlisting}
382 \vspace{5mm}
383
384 When compiling the above \LaTeX{} code, the following output is created.
385 \begin{align*}
386 \begin{pmatrix}0.5&2&3\\4&5&6\\7&8&9\end{pmatrix}
387 \begin{pmatrix}2&0&0\\0&3&0\\0&0&4\end{pmatrix}
388 \left(
389 \begin{pmatrix}1\\2\\3\end{pmatrix} +
390 \begin{pmatrix}7\\8\\9\end{pmatrix}
391 \right)
392 = \begin{pmatrix}1&6&12\\8&15&24\\14&24&36\end{pmatrix}
393 \begin{pmatrix}8\\10\\12\end{pmatrix}
394 = \begin{pmatrix}212\\502\\784\end{pmatrix}
395 \end{align*}
396
397 All three classes provide various macros to print the content of a variable for all kinds of use cases.
398 For example, you can print a vector inside a line of text using the \textbackslash printVecT, which prints a transposed version of the vector's contents.
399
400 \clearpage
401 \DocInput{glmatrix.dtx}
402 \clearpage
403 \section{License}
404 Released under BSD 3-Clause License
405
406 BSD 3-Clause License
407
408 Copyright (c) 2026, Rene Warnking
409
410 Redistribution and use in source and binary forms, with or without
411 modification, are permitted provided that the following conditions are met:
412
413 1. Redistributions of source code must retain the above copyright notice, this
414 list of conditions and the following disclaimer.
415
416 2. Redistributions in binary form must reproduce the above copyright notice,
417 this list of conditions and the following disclaimer in the documentation
418 and/or other materials provided with the distribution.
419
420 3. Neither the name of the copyright holder nor the names of its
421 contributors may be used to endorse or promote products derived from
422 this software without specific prior written permission.
423
424 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
425 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
426 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
427 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
428 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
429 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
430 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
431 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
432 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
433 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
434
435 \end{document}
436 %</driver>
437 % \fi
438
439 % \section{Macro Documentation}
440 % \subsection{matrix}
441 % \label{subsec:matrix}
442 % \begin{center}
443 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
444 % \textbf{Command} & \textbf{Arguments} \\ \hline
445 % \ref{macro:newMat} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalars}} \\
446 % \ref{macro:newMatFromRow} & \makecell[t{p{8cm}}]{\marg{out}, \marg{row}} \\
447 % \ref{macro:newMatFromRowVecs} & \makecell[t{p{8cm}}]{\marg{out}, \marg{rows}} \\
448 % \ref{macro:newMatFromColVecs} & \makecell[t{p{8cm}}]{\marg{out}, \marg{columns}} \\
449 % \ref{macro:newEmptyMat} & \makecell[t{p{8cm}}]{\marg{out}} \\
450 % \ref{macro:newDiagMat} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalars}} \\
451 % \ref{macro:appendRowToMat} & \makecell[t{p{8cm}}]{\marg{out}, \marg{matrix}, \marg{vector r}} \\
452 % \ref{macro:newTransMat} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector t}} \\
453 % \ref{macro:newScaleMat} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector s}} \\
454 % \ref{macro:newRotMatTwoD} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: rotMatResult} \\
455 % \ref{macro:newRotMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\Default Argument: rotMatResult} \\
456 % \ref{macro:newLookAtMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{right}, \marg{up}, \marg{dir}, \marg{pos}\\Default Argument: lookAtMatResult} \\
457 % \ref{macro:newProjMat} & \makecell[t{p{8cm}}]{\marg{out}} \\
458 % \ref{macro:newProjMatGen} & \makecell[t{p{8cm}}]{\marg{out}} \\
459 % \ref{macro:newFrustumMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{fovx}, \marg{fovy}, \marg{near}, \marg{far}\\Default Argument: frustMatResult} \\
460 % \ref{macro:printMat} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{matrix}\\Default Argument: 0} \\
461 % \ref{macro:printMatDiag} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{matrix}\\Default Argument: 0} \\
462 % \ref{macro:getMatHeight} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\Default Argument: matHeightResult} \\
463 % \ref{macro:getMatWidth} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\Default Argument: matWidthResult} \\
464 % \ref{macro:transposeMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\Default Argument: transposeMatResult} \\
465 % \ref{macro:addMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{matrices}\\Default Argument: addMatResult} \\
466 % \ref{macro:subMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{matrices}\\Default Argument: subMatResult} \\
467 % \ref{macro:mulMatScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{scalar}\\Default Argument: mulMatScalarResult} \\
468 % \ref{macro:mulMatVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{vector}\\Default Argument: mulMatVecResult} \\
469 % \ref{macro:mulMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix M}, \marg{matrix N}\\Default Argument: mulMatResult} \\
470 % \ref{macro:getMatTranslation} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\Default Argument: matTranslationResult} \\
471 % \ref{macro:detMat} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\Default Argument: detMatResult} \\
472 % \end{tabularx}
473 % \end{center}
474
475 % \setlabel{\textbackslash newMat}{macro:newMat}
476 % \DescribeMacro{newMat}
477 % \marg{out}\marg{scalars}\\[1mm]
478 % \marg{out}: var name to save the result (matrix) to\\
479 % \marg{scalars}: matrix values that are assigned to out
480 % \begin{descriptionbox}
481 % Create a new matrix from the given values.
482 % \end{descriptionbox}
483 % \begin{equationbox}
484 % \(o = \mathbf{M} \in \R^{m\times n} = \begin{bmatrix} s_{11} & \dots & s_{1n}\\ \vdots & \ddots & \vdots\\ s_{m1} & \dots & s_{mn}\end{bmatrix}\)
485 % \end{equationbox}
486 % \begin{examplebox}
487 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
488 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0.5&2&3\\4&5&6\\7&8&9\end{pmatrix}\)\\
489 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\}\}\\
490 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0.5&2&3\end{pmatrix}\)\\
491 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5\}\{4\}\{7\}\}\}\\
492 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0.5\\4\\7\end{pmatrix}\)
493 % \end{examplebox}
494
495 % \setlabel{\textbackslash newMatFromRow}{macro:newMatFromRow}
496 % \DescribeMacro{newMatFromRow}
497 % \marg{out}\marg{row}\\[1mm]
498 % \marg{out}: var name to save the result (matrix) to\\
499 % \marg{row}: matrix row that is assigned to out
500 % \begin{descriptionbox}
501 % Create a new matrix from the given row.
502 % \end{descriptionbox}
503
504 % \setlabel{\textbackslash newMatFromRowVecs}{macro:newMatFromRowVecs}
505 % \DescribeMacro{newMatFromRowVecs}
506 % \marg{out}\marg{rows}\\[1mm]
507 % \marg{out}: var name to save the result (matrix) to\\
508 % \marg{rows}: the rows that are used to construct the matrix
509 % \begin{descriptionbox}
510 % Create a new matrix from the given row vectors.
511 % \end{descriptionbox}
512 % \begin{examplebox}
513 % \textbackslash newVec\{myRowVecA\}\{1, 0, 0\}\\
514 % \textbackslash newVec\{myRowVecB\}\{0, 2, 0\}\\
515 % \textbackslash newVec\{myRowVecC\}\{0, 0, 3\}\\
516 % \textbackslash newMatFromRowVecs\{myNewMatrix\}\{\textbackslash myRowVecA, \textbackslash myRowVecB, \textbackslash myRowVecC\}\\
517 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}1&0&0\\0&2&0\\0&0&3\end{pmatrix}\)
518 % \end{examplebox}
519
520 % \setlabel{\textbackslash newMatFromColVecs}{macro:newMatFromColVecs}
521 % \DescribeMacro{newMatFromColVecs}
522 % \marg{out}\marg{columns}\\[1mm]
523 % \marg{out}: var name to save the result (matrix) to\\
524 % \marg{columns}: the columns that are used to construct the matrix
525 % \begin{descriptionbox}
526 % Create a new matrix from the given column vectors.
527 % \end{descriptionbox}
528
529 % \setlabel{\textbackslash newEmptyMat}{macro:newEmptyMat}
530 % \DescribeMacro{newEmptyMat}
531 % \marg{out}\\[1mm]
532 % \marg{out}: var name to save the result (matrix) to
533 % \begin{descriptionbox}
534 % Create a new empty matrix.
535 % Obacht: It is not necessary to call this to create a new matrix before using any of the arithmetic commands.
536 % \end{descriptionbox}
537 % \begin{equationbox}
538 % \(o = \mathbf{M} = \emptyset\)
539 % \end{equationbox}
540 % \begin{examplebox}
541 % \textbackslash newEmptyMat\{myNewMatrix\}\\
542 % \textbackslash myNewMatrix \(\mapsto{} \emptyset\)
543 % \end{examplebox}
544
545 % \setlabel{\textbackslash newDiagMat}{macro:newDiagMat}
546 % \DescribeMacro{newDiagMat}
547 % \marg{out}\marg{scalars}\\[1mm]
548 % \marg{out}: var name to save the result (matrix) to\\
549 % \marg{scalars}: the values that define the diagonal of the matrix
550 % \begin{descriptionbox}
551 % Create a new diagonal matrix from the given vector.
552 % \end{descriptionbox}
553 % \begin{equationbox}
554 % \(o = \mathbf{M} \in \R^{3\times 3} = \begin{bmatrix} s_1 & 0 & 0\\ 0 & s_2 & 0\\ 0 & 0 & s_3\end{bmatrix}\)
555 % \end{equationbox}
556 % \begin{examplebox}
557 % \textbackslash newDiagMat\{myNewMatrix\}\{0.5,2,3\}\\
558 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0.5&0&0\\0&2&0\\0&0&3\end{pmatrix}\)
559 % \end{examplebox}
560
561 % \setlabel{\textbackslash appendRowToMat}{macro:appendRowToMat}
562 % \DescribeMacro{appendRowToMat}
563 % \marg{out}\marg{matrix}\marg{vector r}\\[1mm]
564 % \marg{out}: var name to save the result (matrix) to\\
565 % \marg{matrix}: the matrix to append the vector to\\
566 % \marg{vector r}: the row vector that should be appended to the matrix
567 % \begin{descriptionbox}
568 % Append the given row to the given matrix.
569 % \end{descriptionbox}
570 % \begin{equationbox}
571 % \(o = \begin{bmatrix}\mathbf{M} \\\mathbf{r}\end{bmatrix} \in \R^{m+1\times n}\ \vert\ \mathbf{M} \in \R^{m\times n}, \mathbf{r} \in \R^{1\times n}\)
572 % \end{equationbox}
573
574 % \setlabel{\textbackslash newTransMat}{macro:newTransMat}
575 % \DescribeMacro{newTransMat}
576 % \marg{out}\marg{vector t}\\[1mm]
577 % \marg{out}: var name to save the result (matrix) to\\
578 % \marg{vector t}: the translation vector to construct the matrix from
579 % \begin{descriptionbox}
580 % Create translation matrix from the given vector.
581 % \end{descriptionbox}
582 % \begin{equationbox}
583 % \(o = \mathbf{T} \in \R^{4\times 4} = \begin{bmatrix}1 & 0 & 0 & \mathbf{t}_x \\0 & 1 & 0 & \mathbf{t}_y \\0 & 0 & 1 & \mathbf{t}_z \\0 & 0 & 0 & 1\end{bmatrix}\)
584 % \end{equationbox}
585 % \begin{examplebox}
586 % \textbackslash newVec\{vecTest\}\{5, 2, 3\}\\
587 % \textbackslash newTransMat\{myNewMatrix\}\{\textbackslash vecTest\}\\
588 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}1&0&0&5\\0&1&0&2\\0&0&1&3\\0&0&0&1\end{pmatrix}\)
589 % \end{examplebox}
590
591 % \setlabel{\textbackslash newScaleMat}{macro:newScaleMat}
592 % \DescribeMacro{newScaleMat}
593 % \marg{out}\marg{vector s}\\[1mm]
594 % \marg{out}: var name to save the result (matrix) to\\
595 % \marg{vector s}: the scaling vector to construct the matrix from
596 % \begin{descriptionbox}
597 % Create scaling matrix from the given vector.
598 % \end{descriptionbox}
599 % \begin{equationbox}
600 % \(o = \mathbf{S} \in \R^{4\times 4} = \begin{bmatrix}\mathbf{s}_x & 0 & 0 & 0 \\0 & \mathbf{s}_y & 0 & 0 \\0 & 0 & \mathbf{s}_z & 0 \\0 & 0 & 0 & 1\end{bmatrix}\)
601 % \end{equationbox}
602 % \begin{examplebox}
603 % \textbackslash newVec\{vecTest\}\{5, 2, 3\}\\
604 % \textbackslash newScaleMat\{myNewMatrix\}\{\textbackslash vecTest\}\\
605 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}5&0&0&0\\0&2&0&0\\0&0&3&0\\0&0&0&1\end{pmatrix}\)
606 % \end{examplebox}
607
608 % \setlabel{\textbackslash newRotMatTwoD}{macro:newRotMatTwoD}
609 % \DescribeMacro{newRotMatTwoD}
610 % \oarg{out}\marg{scalar}\\[1mm]
611 % \oarg{out}: var name to save the result (matrix) to, default: rotMatResult\\
612 % \marg{scalar}: the rotation value
613 % \begin{descriptionbox}
614 % Create rotation matrix from the given scalar (2D).
615 % \end{descriptionbox}
616 % \begin{equationbox}
617 % \(o = \mathbf{R} \in \R^{3\times 3}\)
618 % \end{equationbox}
619 % \begin{examplebox}
620 % \textbackslash newScalarPi\{scalarTest\}\{0.5\}\\
621 % \textbackslash newRotMatTwoD[myNewMatrix]\{\textbackslash scalarTest\}\\
622 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0&-1&0\\1&0&0\\0&0&1\end{pmatrix}\)
623 % \end{examplebox}
624
625 % \setlabel{\textbackslash newRotMat}{macro:newRotMat}
626 % \DescribeMacro{newRotMat}
627 % \oarg{out}\marg{vector}\marg{scalar}\\[1mm]
628 % \oarg{out}: var name to save the result (matrix) to, default: rotMatResult\\
629 % \marg{vector}: the axis to rotate around\\
630 % \marg{scalar}: the angle in degree to rotate with (counterclockwise)
631 % \begin{descriptionbox}
632 % Create a rotation matrix using the rodrigues’ matrix
633 % \end{descriptionbox}
634 % \begin{equationbox}
635 % \(o = \mathbf{R} \in \R^{3\times 3}\)
636 % \end{equationbox}
637 % \begin{examplebox}
638 % \textbackslash newVec\{rotationAxis\}\{1,1,1\}\\
639 % \textbackslash newScalarPi\{scalarTest\}\{0.5\}\\
640 % \textbackslash newRotMat[myNewMatrix]\{\textbackslash rotationAxis\}\{\textbackslash scalarTest\}\\
641 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0&0&1\\1&0&0\\0&1&0\end{pmatrix}\)
642 % \end{examplebox}
643
644 % \setlabel{\textbackslash newLookAtMat}{macro:newLookAtMat}
645 % \DescribeMacro{newLookAtMat}
646 % \oarg{out}\marg{right}\marg{up}\marg{dir}\marg{pos}\\[1mm]
647 % \oarg{out}: var name to save the result (matrix) to, default: lookAtMatResult\\
648 % \marg{right}: the right vector\\
649 % \marg{up}: the up vector\\
650 % \marg{dir}: the direction vector\\
651 % \marg{pos}: the camera position vector
652 % \begin{descriptionbox}
653 % Create a new lookAt matrix.
654 % \end{descriptionbox}
655 % \begin{equationbox}
656 % \(o = \mathbf{L} \in \R^{4\times 4} = \begin{bmatrix}\mathbf{r}_x & \mathbf{r}_y & \mathbf{r}_z & -\mathbf{r} \cdot \mathbf{p} \\\mathbf{u}_x & \mathbf{u}_y & \mathbf{u}_z & -\mathbf{u} \cdot \mathbf{p} \\-\mathbf{d}_x & -\mathbf{d}_y & -\mathbf{d}_z & \mathbf{d} \cdot \mathbf{p} \\0 & 0 & 0 & 1\end{bmatrix}\)
657 % \end{equationbox}
658 % \begin{examplebox}
659 % \textbackslash newVec\{right\}\{5, 2, 3\}\\
660 % \textbackslash newVec\{up\}\{0.5, 1.75, 2\}\\
661 % \textbackslash newVec\{dir\}\{0.5, 2, -3\}\\
662 % \textbackslash newVec\{pos\}\{5, 2, 3\}\\
663 % \textbackslash newLookAtMat[myNewMatrix]\{\textbackslash right\}\{\textbackslash up\}\{\textbackslash dir\}\{\textbackslash pos\}\\
664 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}5&2&3&-38\\0.5&1.75&2&-12\\-0.5&-2&3&-2.5\\0&0&0&1\end{pmatrix}\)
665 % \end{examplebox}
666
667 % \setlabel{\textbackslash newProjMat}{macro:newProjMat}
668 % \DescribeMacro{newProjMat}
669 % \marg{out}\\[1mm]
670 % \marg{out}: var name to save the result (matrix) to
671 % \begin{descriptionbox}
672 % Create a new default projection matrix.
673 % \end{descriptionbox}
674 % \begin{equationbox}
675 % \(o = \mathbf{P} \in \R^{4\times 4}\)
676 % \end{equationbox}
677 % \begin{examplebox}
678 % \textbackslash newProjMat\{\textbackslash myNewMatrix\}\\
679 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&-1&0\end{pmatrix}\)
680 % \end{examplebox}
681
682 % \setlabel{\textbackslash newProjMatGen}{macro:newProjMatGen}
683 % \DescribeMacro{newProjMatGen}
684 % \marg{out}\\[1mm]
685 % \marg{out}: var name to save the result (matrix) to
686 % \begin{descriptionbox}
687 % Create a new projection matrix from normal and distance from origin.
688 % \end{descriptionbox}
689 % \begin{equationbox}
690 % \(o = \mathbf{P} \in \R^{4\times 4}\)
691 % \end{equationbox}
692 % \begin{examplebox}
693 % \textbackslash newScalar\{myDelta\}\{5\}\\
694 % \textbackslash newVec\{myNormal\}\{1,1,0\}\\
695 % \textbackslash newProjMatGen\{\textbackslash myNewMatrix\}\{\textbackslash myNormal\}\{\textbackslash myDelta\}\\
696 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0.2&0.2&0.2&0\end{pmatrix}\)
697 % \end{examplebox}
698
699 % \setlabel{\textbackslash newFrustumMat}{macro:newFrustumMat}
700 % \DescribeMacro{newFrustumMat}
701 % \oarg{out}\marg{fovx}\marg{fovy}\marg{near}\marg{far}\\[1mm]
702 % \oarg{out}: var name to save the result (matrix) to, default: frustMatResult\\
703 % \marg{fovx}: the fovx scalar\\
704 % \marg{fovy}: the fovy scalar\\
705 % \marg{near}: the position of the near plane (scalar)\\
706 % \marg{far}: the psition of the far lane (scalar)
707 % \begin{descriptionbox}
708 % Create a new frustum matrix.
709 % \end{descriptionbox}
710 % \begin{equationbox}
711 % \(o = \mathbf{F} \in \R^{4\times 4}\)
712 % \end{equationbox}
713 % \begin{examplebox}
714 % \textbackslash newScalar\{fovx\}\{90\}\\
715 % \textbackslash newScalar\{fovy\}\{90\}\\
716 % \textbackslash newScalar\{near\}\{1\}\\
717 % \textbackslash newScalar\{far\}\{6\}\\
718 % \textbackslash newFrustumMat[myNewMatrix]\{\textbackslash fovx\}\{\textbackslash fovy\}\{\textbackslash near\}\{\textbackslash far\}\\
719 % \textbackslash myNewMatrix \(\mapsto{} \begin{pmatrix}0.6174&0&0&0\\0&06174&0&0\\0&0&-1.4&-2.4\\0&0&-1&0\end{pmatrix}\)
720 % \end{examplebox}
721
722 % \setlabel{\textbackslash printMat}{macro:printMat}
723 % \DescribeMacro{printMat}
724 % \oarg{fraction}\marg{matrix}\\[1mm]
725 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
726 % \marg{matrix}: the matrix that should be printed
727 % \begin{descriptionbox}
728 % Print the values of this matrix variable.
729 % \end{descriptionbox}
730 % \begin{equationbox}
731 % \(\begin{bmatrix} a_{11} & \dots & a_{1n}\\ \vdots & \ddots & \vdots\\ a_{m1} & \dots & a_{mn}\end{bmatrix}\)
732 % \end{equationbox}
733 % \begin{examplebox}
734 % \textbackslash newMat\{myNewMatrix\}\{\{\{\(a_{11},\dots,a_{1n}\)\}\{\(a_{21},\dots,a_{2n}\)\}\{\(a_{m1},\dots,a_{mn}\)\}\}\}\\
735 % \textbackslash printMat\{\textbackslash myNewMatrix\} \(\mapsto{} \begin{bmatrix} a_{11} & \dots & a_{1n}\\ \vdots & \ddots & \vdots\\ a_{m1} & \dots & a_{mn}\end{bmatrix}\)
736 % \end{examplebox}
737
738 % \setlabel{\textbackslash printMatDiag}{macro:printMatDiag}
739 % \DescribeMacro{printMatDiag}
740 % \oarg{fraction}\marg{matrix}\\[1mm]
741 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
742 % \marg{matrix}: the matrix that should be printed
743 % \begin{descriptionbox}
744 % Print only the diagonal values of this matrix variable.
745 % \end{descriptionbox}
746 % \begin{examplebox}
747 % \textbackslash newMat\{myNewMatrix\}\{\{\{\(a_{11},\dots,a_{1n}\)\}\{\(a_{21},\dots,a_{2n}\)\}\{\(a_{m1},\dots,a_{mn}\)\}\}\}\\
748 % \textbackslash printMatDiag\{\textbackslash myNewMatrix\} \(\mapsto{} \text{diag}(a_{11}, a_{22}, a_{mm})\)
749 % \end{examplebox}
750
751 % \setlabel{\textbackslash getMatHeight}{macro:getMatHeight}
752 % \DescribeMacro{getMatHeight}
753 % \oarg{out}\marg{matrix}\\[1mm]
754 % \oarg{out}: var name to save the result (scalar) to, default: matHeightResult\\
755 % \marg{matrix}: the matrix from which to get the height
756 % \begin{descriptionbox}
757 % Get the height of the given matrix.
758 % \end{descriptionbox}
759 % \begin{equationbox}
760 % \(o = rows(\mathbf{M})\ \vert\ \mathbf{M} \in \R^{m\times n}\)
761 % \end{equationbox}
762 % \begin{examplebox}
763 % \textbackslash newMat\{myNewMatrix\}\{\{\{\(a_{11},\dots,a_{1n}\)\}\{\(a_{21},\dots,a_{2n}\)\}\{\(a_{m1},\dots,a_{mn}\)\}\}\}\\
764 % \textbackslash getMatHeight\{myNewMatrix\}\\
765 % \textbackslash matHeightResult \(\mapsto{} m\)
766 % \end{examplebox}
767
768 % \setlabel{\textbackslash getMatWidth}{macro:getMatWidth}
769 % \DescribeMacro{getMatWidth}
770 % \oarg{out}\marg{matrix}\\[1mm]
771 % \oarg{out}: var name to save the result (scalar) to, default: matWidthResult\\
772 % \marg{matrix}: the matrix from which to get the width
773 % \begin{descriptionbox}
774 % Get the width of the given matrix.
775 % \end{descriptionbox}
776 % \begin{equationbox}
777 % \(o = cols(\mathbf{M})\ \vert\ \mathbf{M} \in \R^{m\times n}\)
778 % \end{equationbox}
779 % \begin{examplebox}
780 % \textbackslash newMat\{myNewMatrix\}\{\{\{\(a_{11},\dots,a_{1n}\)\}\{\(a_{21},\dots,a_{2n}\)\}\{\(a_{m1},\dots,a_{mn}\)\}\}\}\\
781 % \textbackslash getMatWidth\{myNewMatrix\}\\
782 % \textbackslash matWidthResult \(\mapsto{} n\)
783 % \end{examplebox}
784
785 % \setlabel{\textbackslash transposeMat}{macro:transposeMat}
786 % \DescribeMacro{transposeMat}
787 % \oarg{out}\marg{matrix}\\[1mm]
788 % \oarg{out}: var name to save the result (matrix) to, default: transposeMatResult\\
789 % \marg{matrix}: the matrix to transpose
790 % \begin{descriptionbox}
791 % Transpose a given Matrix. The parameter can also be a vector,
792 % but the result will be a matrix.
793 % \end{descriptionbox}
794 % \begin{equationbox}
795 % \(o = \trans{\mathbf{M}}\)
796 % \end{equationbox}
797 % \begin{examplebox}
798 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
799 % \textbackslash transposeMat\{\textbackslash myNewMatrix\} \(\mapsto{} \begin{bmatrix}0.5&4&7\\2&5&8\\3&6&9\end{bmatrix}\)
800 % \end{examplebox}
801
802 % \setlabel{\textbackslash addMat}{macro:addMat}
803 % \DescribeMacro{addMat}
804 % \oarg{out}\marg{matrix}\marg{matrices}\\[1mm]
805 % \oarg{out}: var name to save the result (matrix) to, default: addMatResult\\
806 % \marg{matrix}: the matrix to add to\\
807 % \marg{matrices}: the matrizes to add
808 % \begin{descriptionbox}
809 % Add two or more matrices.
810 % \end{descriptionbox}
811 % \begin{equationbox}
812 % \(o = \mathbf{X} = \mathbf{M} + \mathbf{B}\ \vert\ \mathbf{M}, \mathbf{M}, \mathbf{B} \in \R^{m\times n}\)
813 % \end{equationbox}
814 % \begin{examplebox}
815 % \textbackslash newMat\{myNewMatrixA\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
816 % \textbackslash newMat\{myNewMatrixB\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
817 % \textbackslash addMat\{\textbackslash myNewMatrixA\}\{\textbackslash myNewMatrixB\}\\
818 % \textbackslash addMatResult \(\mapsto{} \begin{bmatrix}1&4&6\\8&10&12\\14&16&18\end{bmatrix}\)\\
819 % \textbackslash addMat[resultName]\{\textbackslash myNewMatrixA\}\{\textbackslash myNewMatrixB\}\\
820 % \textbackslash resultName \(\mapsto{} \begin{bmatrix}1&4&6\\8&10&12\\14&16&18\end{bmatrix}\)
821 % \end{examplebox}
822
823 % \setlabel{\textbackslash subMat}{macro:subMat}
824 % \DescribeMacro{subMat}
825 % \oarg{out}\marg{matrix}\marg{matrices}\\[1mm]
826 % \oarg{out}: var name to save the result (matrix) to, default: subMatResult\\
827 % \marg{matrix}: the matrix to subtract from\\
828 % \marg{matrices}: the matrizes to subtract
829 % \begin{descriptionbox}
830 % Subtract two or more matrices.
831 % \end{descriptionbox}
832 % \begin{equationbox}
833 % \(o = \mathbf{X} = \mathbf{M} - \mathbf{B}\ \vert\ \mathbf{X}, \mathbf{M}, \mathbf{B} \in \R^{m\times n}\)
834 % \end{equationbox}
835 % \begin{examplebox}
836 % \textbackslash newMat\{myNewMatrixA\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
837 % \textbackslash newMat\{myNewMatrixB\}\{\{\{0.25,1,2\}\{3,2,1\}\{3,3,3\}\}\}\\
838 % \textbackslash subMat[subMatResult]\{\textbackslash myNewMatrixA\}\{\textbackslash myNewMatrixB\}\\
839 % \textbackslash subMatResult \(\mapsto{} \begin{bmatrix}0.25&1&1\\1&3&4\\4&5&6\end{bmatrix}\)
840 % \end{examplebox}
841
842 % \setlabel{\textbackslash mulMatScalar}{macro:mulMatScalar}
843 % \DescribeMacro{mulMatScalar}
844 % \oarg{out}\marg{matrix}\marg{scalar}\\[1mm]
845 % \oarg{out}: var name to save the result (matrix) to, default: mulMatScalarResult\\
846 % \marg{matrix}: the matrix to multiply\\
847 % \marg{scalar}: the scalar to multiply with
848 % \begin{descriptionbox}
849 % Multiply the given matrix with a scalar.
850 % \end{descriptionbox}
851 % \begin{equationbox}
852 % \(o = \mathbf{X} = \mathbf{M} * s\ \vert\ \mathbf{X}, \mathbf{M} \in \R^{m\times n}, s \in \R\)
853 % \end{equationbox}
854 % \begin{examplebox}
855 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
856 % \textbackslash newScalar\{myNewScalar\}\{2\}\\
857 % \textbackslash mulMatScalar\{\textbackslash myNewMatrix\}\{\textbackslash myNewScalar\}\\
858 % \textbackslash mulMatScalarResult \(\mapsto{} \begin{bmatrix}1&4&6\\8&10&12\\14&16&18\end{bmatrix}\)\\
859 % \textbackslash mulMatScalar[resultName]\{\textbackslash myNewMatrix\}\{\textbackslash myNewScalar\}\\
860 % \textbackslash resultName \(\mapsto{} \begin{bmatrix}1&4&6\\8&10&12\\14&16&18\end{bmatrix}\)
861 % \end{examplebox}
862
863 % \setlabel{\textbackslash mulMatVec}{macro:mulMatVec}
864 % \DescribeMacro{mulMatVec}
865 % \oarg{out}\marg{matrix}\marg{vector}\\[1mm]
866 % \oarg{out}: var name to save the result (vector) to, default: mulMatVecResult\\
867 % \marg{matrix}: the matrix to transform the vetor with\\
868 % \marg{vector}: the vector to transform
869 % \begin{descriptionbox}
870 % Multiply the given matrix with a vector (for transformation).
871 % \end{descriptionbox}
872 % \begin{equationbox}
873 % \(o = \mathbf{M} \cdot \mathbf{v}\ \vert\ \mathbf{M} \in \R^{m\times n}, \mathbf{v} \in \R^n\)
874 % \end{equationbox}
875 % \begin{examplebox}
876 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
877 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5, 1, 2\}\{4, 5, 6\}\{7, 8, 9\}\}\}\\
878 % \textbackslash mulMatVec\{\textbackslash myNewMatrix\}\{\textbackslash myNewVec\}\\
879 % \textbackslash mulMatVecResult \(\mapsto{} \begin{pmatrix} 5.25\\ 19\\ 29.5\end{pmatrix}\)\\
880 % \textbackslash mulMatVec[resultName]\{\textbackslash myNewMatrix\}\{\textbackslash myNewVec\}\\
881 % \textbackslash resultName \(\mapsto{} \begin{pmatrix} 5.25\\ 19\\ 29.5\end{pmatrix}\)
882 % \end{examplebox}
883 % \begin{warningbox}
884 % When matrix and vector have a dimension mismatch
885 % \end{warningbox}
886
887 % \setlabel{\textbackslash mulMat}{macro:mulMat}
888 % \DescribeMacro{mulMat}
889 % \oarg{out}\marg{matrix M}\marg{matrix N}\\[1mm]
890 % \oarg{out}: var name to save the result (matrix) to, default: mulMatResult\\
891 % \marg{matrix M}: the matrix to multiply\\
892 % \marg{matrix N}: the matrix to multiply with
893 % \begin{descriptionbox}
894 % Multiply the given matrix with another matrix.
895 % \end{descriptionbox}
896 % \begin{equationbox}
897 % \(o = \mathbf{X} = \mathbf{M} \mathbf{N}\ \vert\ \mathbf{M} \in \R^{m\times n}, \mathbf{N} \in \R^{n\times p}, \mathbf{X} \in \R^{m\times p}\)
898 % \end{equationbox}
899 % \begin{examplebox}
900 % \textbackslash newMat\{myNewMatrixA\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
901 % \textbackslash newMat\{myNewMatrixB\}\{\{\{0.25,1,2\}\{3,2,1\}\{3,3,3\}\}\}\\
902 % \textbackslash mulMat[mulMatResult]\{\textbackslash myNewMatrixA\}\{\textbackslash myNewMatrixB\}\\
903 % \textbackslash mulMatResult \(\mapsto{} \begin{bmatrix}15.125&13.5&12\\34&32&31\\52.75&50&49\end{bmatrix}\)
904 % \end{examplebox}
905 % \begin{warningbox}
906 % When the matrizes have a dimension mismatch
907 % \end{warningbox}
908
909 % \setlabel{\textbackslash getMatTranslation}{macro:getMatTranslation}
910 % \DescribeMacro{getMatTranslation}
911 % \oarg{out}\marg{matrix}\\[1mm]
912 % \oarg{out}: var name to save the result (vector) to, default: matTranslationResult\\
913 % \marg{matrix}: the matrix to extract the translation from
914 % \begin{descriptionbox}
915 % Get the translation component from the given matrix.
916 % \end{descriptionbox}
917 % \begin{equationbox}
918 % \(o = \mathbf{v} = trans(\mathbf{M})\ \vert\ \mathbf{M} \in \R^{m\times n}, \mathbf{v} \in \R^{m-1}\)
919 % \end{equationbox}
920 % \begin{examplebox}
921 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
922 % \textbackslash getMatTranslation[matTranslationResult]\{\textbackslash myNewMatrix\}\\
923 % \textbackslash matTranslationResult \(\mapsto{} \begin{pmatrix}3\\6\\\end{pmatrix}\)
924 % \end{examplebox}
925
926 % \setlabel{\textbackslash detMat}{macro:detMat}
927 % \DescribeMacro{detMat}
928 % \oarg{out}\marg{matrix}\\[1mm]
929 % \oarg{out}: var name to save the result (scalar) to, default: detMatResult\\
930 % \marg{matrix}: the matrix to calculate the determinate for
931 % \begin{descriptionbox}
932 % Get the determinate of the given matrix.
933 % \end{descriptionbox}
934 % \begin{equationbox}
935 % \(o = det(\mathbf{M})\ \vert\ \mathbf{M} \in \R^{m\times n}\)
936 % \end{equationbox}
937 % \begin{examplebox}
938 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5,2,3\}\{4,5,6\}\{7,8,9\}\}\}\\
939 % \textbackslash detMat[detMatResult]\{\textbackslash myNewMatrix\}\\
940 % \textbackslash detMatResult \(\mapsto{} 1.5\)
941 % \end{examplebox}
942 % \subsection{scalar}
943 % \label{subsec:scalar}
944 % \begin{center}
945 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
946 % \textbf{Command} & \textbf{Arguments} \\ \hline
947 % \ref{macro:newScalar} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
948 % \ref{macro:newScalarPi} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
949 % \ref{macro:newScalarFraction} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar n}, \marg{scalar d}} \\
950 % \ref{macro:randomScalar} & \makecell[t{p{8cm}}]{\marg{out}, \marg{lower bound}, \marg{upper bound}} \\
951 % \ref{macro:copyScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: scalarCopyResult} \\
952 % \ref{macro:setScalar} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
953 % \ref{macro:zeroScalar} & \makecell[t{p{8cm}}]{\marg{out}} \\
954 % \ref{macro:printScalar} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\Default Argument: 0} \\
955 % \ref{macro:printScalarAsPi} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\Default Argument: 0} \\
956 % \ref{macro:printPiScalarInDegree} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\Default Argument: 0} \\
957 % \ref{macro:printScalarRounded} & \makecell[t{p{8cm}}]{\oarg{digits}, \marg{scalar}\\Default Argument: 4} \\
958 % \ref{macro:roundScalar} & \makecell[t{p{8cm}}]{\oarg{digits}, \marg{scalar}\\Default Argument: 4} \\
959 % \ref{macro:ceilScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: scalarCeilResult} \\
960 % \ref{macro:floorScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: scalarFloorResult} \\
961 % \ref{macro:clipScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: clipScalarResult} \\
962 % \ref{macro:radianToDegree} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: radianToDegreeResult} \\
963 % \ref{macro:toRadian} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: degreeToRadianResult} \\
964 % \ref{macro:addScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: scalarAddResult} \\
965 % \ref{macro:subScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: scalarSubResult} \\
966 % \ref{macro:mulScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: scalarMulResult} \\
967 % \ref{macro:divScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: scalarDivResult} \\
968 % \ref{macro:powScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: scalarPowResult} \\
969 % \ref{macro:negateScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: scalarNegateResult} \\
970 % \ref{macro:arccosScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\Default Argument: scalarArccosResult} \\
971 % \ref{macro:mulAndAddScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}, \marg{scalar u}\\Default Argument: scalarMulAndAddResult} \\
972 % \ref{macro:lerpScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar i}, \marg{scalar j}, \marg{scalar t}\\Default Argument: lerpScalarResult} \\
973 % \ref{macro:minScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: minScalarResult} \\
974 % \ref{macro:maxScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\Default Argument: maxScalarResult} \\
975 % \ref{macro:betweenScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}, \marg{lower bound}, \marg{upper bound}\\Default Argument: betweenScalarResult} \\
976 % \ref{macro:forEachScalar} & \makecell[t{p{8cm}}]{\marg{input}, \marg{macro}, \marg{args}} \\
977 % \end{tabularx}
978 % \end{center}
979
980 % \setlabel{\textbackslash newScalar}{macro:newScalar}
981 % \DescribeMacro{newScalar}
982 % \marg{out}\marg{scalar}\\[1mm]
983 % \marg{out}: var name to save the result (scalar) to\\
984 % \marg{scalar}: scalar value that is assigned to out
985 % \begin{descriptionbox}
986 % Create a new scalar and assign the given value.
987 % \end{descriptionbox}
988 % \begin{examplebox}
989 % \textbackslash newScalar\{myNewScalar\}\{3\}\\
990 % \textbackslash myNewScalar \(\mapsto{}\) 3
991 % \end{examplebox}
992
993 % \setlabel{\textbackslash newScalarPi}{macro:newScalarPi}
994 % \DescribeMacro{newScalarPi}
995 % \marg{out}\marg{scalar}\\[1mm]
996 % \marg{out}: var name to save the result (scalar) to\\
997 % \marg{scalar}: scalar value that is multiplied with pi and assigned to out
998 % \begin{descriptionbox}
999 % Create a new scalar and assign the given value as a multiple of pi.
1000 % \end{descriptionbox}
1001 % \begin{examplebox}
1002 % \textbackslash newScalarPi\{myNewScalar\}\{3\}\\
1003 % \textbackslash myNewScalar \(\mapsto{}\) 9.42
1004 % \end{examplebox}
1005
1006 % \setlabel{\textbackslash newScalarFraction}{macro:newScalarFraction}
1007 % \DescribeMacro{newScalarFraction}
1008 % \marg{out}\marg{scalar n}\marg{scalar d}\\[1mm]
1009 % \marg{out}: var name to save the result (scalar) to\\
1010 % \marg{scalar n}: nominator\\
1011 % \marg{scalar d}: denominator
1012 % \begin{descriptionbox}
1013 % Create a scalar from a given fraction
1014 % \end{descriptionbox}
1015 % \begin{examplebox}
1016 % \textbackslash newScalarFraction\{myScalarFraction\}\{3\}\{10\}\\
1017 % \textbackslash myScalarFraction \(\mapsto{}\frac{3}{10}\)
1018 % \end{examplebox}
1019
1020 % \setlabel{\textbackslash randomScalar}{macro:randomScalar}
1021 % \DescribeMacro{randomScalar}
1022 % \marg{out}\marg{lower bound}\marg{upper bound}\\[1mm]
1023 % \marg{out}: var name to save the result (scalar) to\\
1024 % \marg{lower bound}: scalar that limits the possible values at the bottom\\
1025 % \marg{upper bound}: scalar that limits the possible values at the top
1026 % \begin{descriptionbox}
1027 % Create a new scalar variable with a random value between lower and
1028 % upper bound. The value is obtained by creating a random value between 0 and 1
1029 % and then interpolating between lower and upper bound.
1030 % \end{descriptionbox}
1031 % \begin{examplebox}
1032 % \textbackslash randomScalar\{myRandomScalar\}\{3\}\{10\}\\
1033 % \textbackslash myRandomScalar \(\mapsto{}\) 5
1034 % \end{examplebox}
1035
1036 % \setlabel{\textbackslash copyScalar}{macro:copyScalar}
1037 % \DescribeMacro{copyScalar}
1038 % \oarg{out}\marg{scalar}\\[1mm]
1039 % \oarg{out}: var name to save the result (scalar) to, default: scalarCopyResult\\
1040 % \marg{scalar}: scalar which value is assigned to out
1041 % \begin{descriptionbox}
1042 % Copy the value of one scalar variable to another.
1043 % \end{descriptionbox}
1044 % \begin{examplebox}
1045 % \textbackslash newScalar\{myNewScalar\}\{3\}\\
1046 % \textbackslash copyScalar\{myCopyScalar\}\{\textbackslash myNewScalar\}\\
1047 % \textbackslash myCopyScalar \(\mapsto{}\) 3
1048 % \end{examplebox}
1049
1050 % \setlabel{\textbackslash setScalar}{macro:setScalar}
1051 % \DescribeMacro{setScalar}
1052 % \marg{out}\marg{scalar}\\[1mm]
1053 % \marg{out}: var name to save the result (scalar) to\\
1054 % \marg{scalar}: scalar value that is assigned to out
1055 % \begin{descriptionbox}
1056 % Set the value of a given scalar.
1057 % \end{descriptionbox}
1058 % \begin{examplebox}
1059 % \textbackslash newScalar\{myNewScalar\}\{3\}\\
1060 % \textbackslash setScalar\{myNewScalar\}\{4\}\\
1061 % \textbackslash myNewScalar \(\mapsto{}\) 4
1062 % \end{examplebox}
1063
1064 % \setlabel{\textbackslash zeroScalar}{macro:zeroScalar}
1065 % \DescribeMacro{zeroScalar}
1066 % \marg{out}\\[1mm]
1067 % \marg{out}: var name to save the result (scalar) to
1068 % \begin{descriptionbox}
1069 % Set or create a scalar with value 0.
1070 % \end{descriptionbox}
1071 % \begin{examplebox}
1072 % \textbackslash zeroScalar\{myZeroScalar\}\\
1073 % \textbackslash myZeroScalar \(\mapsto{}\) 0
1074 % \end{examplebox}
1075
1076 % \setlabel{\textbackslash printScalar}{macro:printScalar}
1077 % \DescribeMacro{printScalar}
1078 % \oarg{fraction}\marg{scalar}\\[1mm]
1079 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1080 % \marg{scalar}: the scalar that should be printed
1081 % \begin{descriptionbox}
1082 % Print the value of the given scalar.
1083 % \end{descriptionbox}
1084 % \begin{examplebox}
1085 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
1086 % \textbackslash printScalar[1]\{\textbackslash myNewScalar\} \(\mapsto{} \frac{1}{2}\)
1087 % \end{examplebox}
1088
1089 % \setlabel{\textbackslash printScalarAsPi}{macro:printScalarAsPi}
1090 % \DescribeMacro{printScalarAsPi}
1091 % \oarg{fraction}\marg{scalar}\\[1mm]
1092 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1093 % \marg{scalar}: the scalar that should be printed
1094 % \begin{descriptionbox}
1095 % Print the value of the given scalar as a multiple of Pi.
1096 % \end{descriptionbox}
1097 % \begin{equationbox}
1098 % \(\left\{\frac{s}{\pi}\right\}\pi\)
1099 % \end{equationbox}
1100 % \begin{examplebox}
1101 % \textbackslash newScalarPi\{myNewScalar\}\{0.5\}\\
1102 % \textbackslash printScalarAsPi[1]\{\textbackslash myNewScalar\} \(\mapsto{} \frac{1}{2} \pi\)
1103 % \end{examplebox}
1104
1105 % \setlabel{\textbackslash printPiScalarInDegree}{macro:printPiScalarInDegree}
1106 % \DescribeMacro{printPiScalarInDegree}
1107 % \oarg{fraction}\marg{scalar}\\[1mm]
1108 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1109 % \marg{scalar}: the value that schould be printed
1110 % \begin{descriptionbox}
1111 % Print the value of the given scalar in degree.
1112 % This macro does do a conversion and therefore expects the input to be in radian.
1113 % A degree sign is automatically added.
1114 % \end{descriptionbox}
1115 % \begin{equationbox}
1116 % \(\left\{\frac{s*180}{\pi}\right\}^\circ\)
1117 % \end{equationbox}
1118 % \begin{examplebox}
1119 % \textbackslash newScalarPi\{myNewScalar\}\{0.5\}\\
1120 % \textbackslash printPiScalarInDegree[1]\{\textbackslash myNewScalar\} \(\mapsto{} 90^\circ\)
1121 % \end{examplebox}
1122
1123 % \setlabel{\textbackslash printScalarRounded}{macro:printScalarRounded}
1124 % \DescribeMacro{printScalarRounded}
1125 % \oarg{digits}\marg{scalar}\\[1mm]
1126 % \oarg{digits}: number of digits after comma, default: 4\\
1127 % \marg{scalar}: the value that schould be printed
1128 % \begin{descriptionbox}
1129 % Print the rounded value of the given scalar.
1130 % \end{descriptionbox}
1131 % \begin{examplebox}
1132 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
1133 % \textbackslash printScalarRounded\{\textbackslash myNewScalar\} \(\mapsto{} 1\)
1134 % \end{examplebox}
1135
1136 % \setlabel{\textbackslash roundScalar}{macro:roundScalar}
1137 % \DescribeMacro{roundScalar}
1138 % \oarg{digits}\marg{scalar}\\[1mm]
1139 % \oarg{digits}: number of digits after comma, default: 4\\
1140 % \marg{scalar}: the value that schould be rounded
1141 % \begin{descriptionbox}
1142 % Round the value ot the given scalar and save it.
1143 % \end{descriptionbox}
1144 % \begin{examplebox}
1145 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
1146 % \textbackslash roundScalar\{\textbackslash myNewScalar\}\\
1147 % \textbackslash myNewScalar \(\mapsto{} 1\)
1148 % \end{examplebox}
1149
1150 % \setlabel{\textbackslash ceilScalar}{macro:ceilScalar}
1151 % \DescribeMacro{ceilScalar}
1152 % \oarg{out}\marg{scalar}\\[1mm]
1153 % \oarg{out}: var name to save the result (scalar) to, default: scalarCeilResult\\
1154 % \marg{scalar}: the scalar that schould be ceiled
1155 % \begin{descriptionbox}
1156 % Ceil the value of the given scalar.
1157 % \end{descriptionbox}
1158 % \begin{examplebox}
1159 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
1160 % \textbackslash ceilScalar\{\textbackslash myNewScalar\}\\
1161 % \textbackslash myNewScalar \(\mapsto{} 1\)
1162 % \end{examplebox}
1163
1164 % \setlabel{\textbackslash floorScalar}{macro:floorScalar}
1165 % \DescribeMacro{floorScalar}
1166 % \oarg{out}\marg{scalar}\\[1mm]
1167 % \oarg{out}: var name to save the result (scalar) to, default: scalarFloorResult\\
1168 % \marg{scalar}: the scalar that schould be floored
1169 % \begin{descriptionbox}
1170 % Floor the value of the given scalar.
1171 % \end{descriptionbox}
1172 % \begin{examplebox}
1173 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
1174 % \textbackslash floorScalar\{\textbackslash myNewScalar\}\\
1175 % \textbackslash myNewScalar \(\mapsto{} 0\)
1176 % \end{examplebox}
1177
1178 % \setlabel{\textbackslash clipScalar}{macro:clipScalar}
1179 % \DescribeMacro{clipScalar}
1180 % \oarg{out}\marg{scalar}\\[1mm]
1181 % \oarg{out}: var name to save the result (scalar) to, default: clipScalarResult\\
1182 % \marg{scalar}: the scalar from which the zeros should be removed
1183 % \begin{descriptionbox}
1184 % Remove all trailing zeros from the value of the given scalar.
1185 % \end{descriptionbox}
1186 % \begin{examplebox}
1187 % \textbackslash newScalar\{myNewScalar\}\{5.0000\}\\
1188 % \textbackslash clipScalar\{\textbackslash myNewScalar\}\\
1189 % \textbackslash myNewScalar \(\mapsto{} 5\)
1190 % \end{examplebox}
1191
1192 % \setlabel{\textbackslash radianToDegree}{macro:radianToDegree}
1193 % \DescribeMacro{radianToDegree}
1194 % \oarg{out}\marg{scalar}\\[1mm]
1195 % \oarg{out}: var name to save the result (scalar) to, default: radianToDegreeResult\\
1196 % \marg{scalar}: the scalar which to convert
1197 % \begin{descriptionbox}
1198 % Convert the value of the given scalar to degree.
1199 % \end{descriptionbox}
1200 % \begin{examplebox}
1201 % \textbackslash newScalarPi\{myNewScalar\}\{0.5\}\\
1202 % \textbackslash radianToDegree\{\textbackslash myNewScalar\}\\
1203 % \textbackslash radianToDegreeResult \(\mapsto{} 90\)
1204 % \end{examplebox}
1205
1206 % \setlabel{\textbackslash toRadian}{macro:toRadian}
1207 % \DescribeMacro{toRadian}
1208 % \oarg{out}\marg{scalar}\\[1mm]
1209 % \oarg{out}: var name to save the result (scalar) to, default: degreeToRadianResult\\
1210 % \marg{scalar}: the scalar which to convert
1211 % \begin{descriptionbox}
1212 % Convert the value of the given scalar to radian.
1213 % \end{descriptionbox}
1214 % \begin{examplebox}
1215 % \textbackslash newScalarPi\{myNewScalar\}\{180\}\\
1216 % \textbackslash toRadian\{\textbackslash myNewScalar\}\\
1217 % \textbackslash degreeToRadianResult \(\mapsto{} 1.5707\)
1218 % \end{examplebox}
1219
1220 % \setlabel{\textbackslash addScalar}{macro:addScalar}
1221 % \DescribeMacro{addScalar}
1222 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1223 % \oarg{out}: var name to save the result (scalar) to, default: scalarAddResult\\
1224 % \marg{scalar s}: the first scalar of the sum\\
1225 % \marg{scalar t}: the second scalar of the sum
1226 % \begin{descriptionbox}
1227 % Add the values of two scalars.
1228 % \end{descriptionbox}
1229 % \begin{equationbox}
1230 % \(o = s + t\)
1231 % \end{equationbox}
1232 % \begin{examplebox}
1233 % \textbackslash newScalar\{myNewScalarA\}\{1\}\\
1234 % \textbackslash newScalar\{myNewScalarB\}\{2\}\\
1235 % \textbackslash addScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1236 % \textbackslash scalarAddResult \(\mapsto{} 3\)
1237 % \end{examplebox}
1238
1239 % \setlabel{\textbackslash subScalar}{macro:subScalar}
1240 % \DescribeMacro{subScalar}
1241 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1242 % \oarg{out}: var name to save the result (scalar) to, default: scalarSubResult\\
1243 % \marg{scalar s}: the scalar to subtract from\\
1244 % \marg{scalar t}: the scalar to subtract
1245 % \begin{descriptionbox}
1246 % Subtract the values of two scalars.
1247 % \end{descriptionbox}
1248 % \begin{equationbox}
1249 % \(o = s - t\)
1250 % \end{equationbox}
1251 % \begin{examplebox}
1252 % \textbackslash newScalar\{myNewScalarA\}\{1\}\\
1253 % \textbackslash newScalar\{myNewScalarB\}\{2\}\\
1254 % \textbackslash subScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1255 % \textbackslash scalarSubResult \(\mapsto{} -1\)
1256 % \end{examplebox}
1257
1258 % \setlabel{\textbackslash mulScalar}{macro:mulScalar}
1259 % \DescribeMacro{mulScalar}
1260 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1261 % \oarg{out}: var name to save the result (scalar) to, default: scalarMulResult\\
1262 % \marg{scalar s}: the scalar to multiply\\
1263 % \marg{scalar t}: the scalar with which to multply
1264 % \begin{descriptionbox}
1265 % Multiply the values of two scalars.
1266 % \end{descriptionbox}
1267 % \begin{equationbox}
1268 % \(o = s * t\)
1269 % \end{equationbox}
1270 % \begin{examplebox}
1271 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1272 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1273 % \textbackslash mulScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1274 % \textbackslash scalarMulResult \(\mapsto{} 6\)
1275 % \end{examplebox}
1276
1277 % \setlabel{\textbackslash divScalar}{macro:divScalar}
1278 % \DescribeMacro{divScalar}
1279 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1280 % \oarg{out}: var name to save the result (scalar) to, default: scalarDivResult\\
1281 % \marg{scalar s}: the scalar to divide\\
1282 % \marg{scalar t}: the scalar to divide with
1283 % \begin{descriptionbox}
1284 % Divide the values of two scalars.
1285 % \end{descriptionbox}
1286 % \begin{equationbox}
1287 % \(o = \frac{s}{t}\)
1288 % \end{equationbox}
1289 % \begin{examplebox}
1290 % \textbackslash newScalar\{myNewScalarA\}\{6\}\\
1291 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1292 % \textbackslash divScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1293 % \textbackslash scalarDivResult \(\mapsto{} 2\)
1294 % \end{examplebox}
1295 % \begin{warningbox}
1296 % On division by zero
1297 % \end{warningbox}
1298
1299 % \setlabel{\textbackslash powScalar}{macro:powScalar}
1300 % \DescribeMacro{powScalar}
1301 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1302 % \oarg{out}: var name to save the result (scalar) to, default: scalarPowResult\\
1303 % \marg{scalar s}: the scalar to raise\\
1304 % \marg{scalar t}: the scalar with which to raise
1305 % \begin{descriptionbox}
1306 % Raise the values of one scalar by another.
1307 % \end{descriptionbox}
1308 % \begin{equationbox}
1309 % \(o = s ^ t\)
1310 % \end{equationbox}
1311 % \begin{examplebox}
1312 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1313 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1314 % \textbackslash powScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1315 % \textbackslash scalarPowResult \(\mapsto{} 8\)
1316 % \end{examplebox}
1317
1318 % \setlabel{\textbackslash negateScalar}{macro:negateScalar}
1319 % \DescribeMacro{negateScalar}
1320 % \oarg{out}\marg{scalar}\\[1mm]
1321 % \oarg{out}: var name to save the result (scalar) to, default: scalarNegateResult\\
1322 % \marg{scalar}: the scalar to negate
1323 % \begin{descriptionbox}
1324 % Negate the value of the given scalar.
1325 % \end{descriptionbox}
1326 % \begin{equationbox}
1327 % \(o = -s\)
1328 % \end{equationbox}
1329 % \begin{examplebox}
1330 % \textbackslash newScalar\{myNewScalar\}\{2\}\\
1331 % \textbackslash negateScalar\{\textbackslash myNewScalar\}\\
1332 % \textbackslash scalarNegateResult \(\mapsto{} -2\)
1333 % \end{examplebox}
1334
1335 % \setlabel{\textbackslash arccosScalar}{macro:arccosScalar}
1336 % \DescribeMacro{arccosScalar}
1337 % \oarg{out}\marg{scalar}\\[1mm]
1338 % \oarg{out}: var name to save the result (scalar) to, default: scalarArccosResult\\
1339 % \marg{scalar}: the scalar to calculate the arccos for
1340 % \begin{descriptionbox}
1341 % Get the arccos of the value of the given scalar.
1342 % \end{descriptionbox}
1343 % \begin{equationbox}
1344 % \(o = arccos(s)\)
1345 % \end{equationbox}
1346 % \begin{examplebox}
1347 % \textbackslash newScalar\{myNewScalar\}\{TODO\}\\
1348 % \textbackslash arccosScalar\{\textbackslash myNewScalar\}\\
1349 % \textbackslash scalarArccosResult \(\mapsto{} TODO\)
1350 % \end{examplebox}
1351
1352 % \setlabel{\textbackslash mulAndAddScalar}{macro:mulAndAddScalar}
1353 % \DescribeMacro{mulAndAddScalar}
1354 % \oarg{out}\marg{scalar s}\marg{scalar t}\marg{scalar u}\\[1mm]
1355 % \oarg{out}: var name to save the result (scalar) to, default: scalarMulAndAddResult\\
1356 % \marg{scalar s}: the scalar to add to\\
1357 % \marg{scalar t}: the scalar that is multiplied and then added\\
1358 % \marg{scalar u}: the scalar that is the muliplier
1359 % \begin{descriptionbox}
1360 % Adds two scalars after multiplying the second one by a scalar.
1361 % \end{descriptionbox}
1362 % \begin{equationbox}
1363 % \(o = s + t * u\)
1364 % \end{equationbox}
1365 % \begin{examplebox}
1366 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1367 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1368 % \textbackslash mulAndAddScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\{\textbackslash myNewScalarB\}\\
1369 % \textbackslash scalarMulAndAddResult \(\mapsto{} 11\)
1370 % \end{examplebox}
1371
1372 % \setlabel{\textbackslash lerpScalar}{macro:lerpScalar}
1373 % \DescribeMacro{lerpScalar}
1374 % \oarg{out}\marg{scalar i}\marg{scalar j}\marg{scalar t}\\[1mm]
1375 % \oarg{out}: var name to save the result (scalar) to, default: lerpScalarResult\\
1376 % \marg{scalar i}: the start scalar\\
1377 % \marg{scalar j}: the end scalar\\
1378 % \marg{scalar t}: interpolation amount range [0-1]
1379 % \begin{descriptionbox}
1380 % Lineraly interpolate between values of two scalars.
1381 % \end{descriptionbox}
1382 % \begin{equationbox}
1383 % \(o = (1-t) * i + t * j\)
1384 % \end{equationbox}
1385 % \begin{examplebox}
1386 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1387 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1388 % \textbackslash newScalar\{myNewScalarT\}\{0.5\}\\
1389 % \textbackslash lerpScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\{\textbackslash myNewScalarT\}\\
1390 % \textbackslash lerpScalarResult \(\mapsto{} 2.5\)
1391 % \end{examplebox}
1392
1393 % \setlabel{\textbackslash minScalar}{macro:minScalar}
1394 % \DescribeMacro{minScalar}
1395 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1396 % \oarg{out}: var name to save the result (scalar) to, default: minScalarResult\\
1397 % \marg{scalar s}: the first scalar\\
1398 % \marg{scalar t}: the second scalar
1399 % \begin{descriptionbox}
1400 % Return the minimum of two scalar values.
1401 % \end{descriptionbox}
1402 % \begin{equationbox}
1403 % \(o = s \text{ falls } s < t \text{ sonst } t\)
1404 % \end{equationbox}
1405 % \begin{examplebox}
1406 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1407 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1408 % \textbackslash minScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1409 % \textbackslash minScalarResult \(\mapsto{} 2\)
1410 % \end{examplebox}
1411
1412 % \setlabel{\textbackslash maxScalar}{macro:maxScalar}
1413 % \DescribeMacro{maxScalar}
1414 % \oarg{out}\marg{scalar s}\marg{scalar t}\\[1mm]
1415 % \oarg{out}: var name to save the result (scalar) to, default: maxScalarResult\\
1416 % \marg{scalar s}: first scalar value\\
1417 % \marg{scalar t}: second scalar value
1418 % \begin{descriptionbox}
1419 % Return the maximum of two scalar values.
1420 % \end{descriptionbox}
1421 % \begin{equationbox}
1422 % \(o = s \text{ falls } s > t \text{ sonst } t\)
1423 % \end{equationbox}
1424 % \begin{examplebox}
1425 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1426 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1427 % \textbackslash maxScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1428 % \textbackslash maxScalarResult \(\mapsto{} 3\)\\
1429 % \textbackslash maxScalar[resultName]\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\\
1430 % \textbackslash resultName \(\mapsto{} 3\)
1431 % \end{examplebox}
1432
1433 % \setlabel{\textbackslash betweenScalar}{macro:betweenScalar}
1434 % \DescribeMacro{betweenScalar}
1435 % \oarg{out}\marg{scalar}\marg{lower bound}\marg{upper bound}\\[1mm]
1436 % \oarg{out}: var name to save the result (scalar) to (0 or 1), default: betweenScalarResult\\
1437 % \marg{scalar}: the scalar to test\\
1438 % \marg{lower bound}: scalar needs to be greater then this for this macro to return 1\\
1439 % \marg{upper bound}: scalar needs to be smaller than this for this macro to return 1
1440 % \begin{descriptionbox}
1441 % Return whether a scalar lies between two other values.
1442 % \end{descriptionbox}
1443 % \begin{examplebox}
1444 % \textbackslash newScalar\{myNewScalarA\}\{2\}\\
1445 % \textbackslash newScalar\{myNewScalarB\}\{3\}\\
1446 % \textbackslash newScalar\{myNewScalarC\}\{4\}\\
1447 % \textbackslash betweenScalar\{\textbackslash myNewScalarA\}\{\textbackslash myNewScalarB\}\{\textbackslash myNewScalarC\}\\
1448 % \textbackslash betweenScalarResult \(\mapsto{} 1\)
1449 % \end{examplebox}
1450
1451 % \setlabel{\textbackslash forEachScalar}{macro:forEachScalar}
1452 % \DescribeMacro{forEachScalar}
1453 % \marg{input}\marg{macro}\marg{args}\\[1mm]
1454 % \marg{input}: list of commands (var names) that should be altered\\
1455 % \marg{macro}: the chosen function\\
1456 % \marg{args}: params for function
1457 % \begin{descriptionbox}
1458 % Apply the given function to a list of variables.
1459 % \end{descriptionbox}
1460 % \subsection{vector}
1461 % \label{subsec:vector}
1462 % \begin{center}
1463 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
1464 % \textbf{Command} & \textbf{Arguments} \\ \hline
1465 % \ref{macro:newVec} & \makecell[t{p{8cm}}]{\marg{out}, \marg{values}} \\
1466 % \ref{macro:newVecPi} & \makecell[t{p{8cm}}]{\marg{out}, \marg{values}} \\
1467 % \ref{macro:randomVec} & \makecell[t{p{8cm}}]{\marg{out}, \marg{dimensions}, \marg{lower bound}, \marg{upper bound}} \\
1468 % \ref{macro:copyVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: copyVecResult} \\
1469 % \ref{macro:zeroVec} & \makecell[t{p{8cm}}]{\oarg{dims}, \marg{out}\\Default Argument: 3} \\
1470 % \ref{macro:appendToVec} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector}, \marg{scalar}} \\
1471 % \ref{macro:printVec} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\Default Argument: 0} \\
1472 % \ref{macro:printVecT} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\Default Argument: 0} \\
1473 % \ref{macro:printVecAsPoint} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\Default Argument: 0} \\
1474 % \ref{macro:printVecAsPi} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\Default Argument: 0} \\
1475 % \ref{macro:printVecAsPiT} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\Default Argument: 0} \\
1476 % \ref{macro:printVecContent} & \makecell[t{p{8cm}}]{\marg{vector}} \\
1477 % \ref{macro:printVecContentXY} & \makecell[t{p{8cm}}]{\marg{vector}} \\
1478 % \ref{macro:printVecContentXYZ} & \makecell[t{p{8cm}}]{\marg{vector}} \\
1479 % \ref{macro:printVecContentXYZW} & \makecell[t{p{8cm}}]{\marg{vector}} \\
1480 % \ref{macro:getVecHeight} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: vecHeightResult} \\
1481 % \ref{macro:printScalarPComp} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector v}, \marg{vector w}\\Default Argument: 0} \\
1482 % \ref{macro:printCrossPComp} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector v}, \marg{vector w}\\Default Argument: 0} \\
1483 % \ref{macro:roundVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{digits}\\Default Argument: roundVecResult} \\
1484 % \ref{macro:ceilVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: ceilVecResult} \\
1485 % \ref{macro:floorVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: floorVecResult} \\
1486 % \ref{macro:dehomogenVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: dehomogenVecResult} \\
1487 % \ref{macro:addVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\Default Argument: addVecResult} \\
1488 % \ref{macro:subVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\Default Argument: subVecResult} \\
1489 % \ref{macro:mulVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\Default Argument: mulVecResult} \\
1490 % \ref{macro:divVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\Default Argument: divVecResult} \\
1491 % \ref{macro:scaleVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\Default Argument: scaleVecResult} \\
1492 % \ref{macro:divVecScalar} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\Default Argument: divVecScalarResult} \\
1493 % \ref{macro:negateVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: negateVecResult} \\
1494 % \ref{macro:scaleAndAddVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar}\\Default Argument: scaleAndAddVecResult} \\
1495 % \ref{macro:lerpVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar t}\\Default Argument: lerpVecResult} \\
1496 % \ref{macro:slerpVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar t}\\Default Argument: slerpVecResult} \\
1497 % \ref{macro:dotVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: dotVecResult} \\
1498 % \ref{macro:lenVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: lenVecResult} \\
1499 % \ref{macro:sqrLenVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: sqrLenVecResult} \\
1500 % \ref{macro:normalizeVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: normalizeVecResult} \\
1501 % \ref{macro:crossVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: crossVecResult} \\
1502 % \ref{macro:crossVecTwoD} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: crossVecResult} \\
1503 % \ref{macro:angleVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: angleVecResult} \\
1504 % \ref{macro:distVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: distVecResult} \\
1505 % \ref{macro:sqrDistVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: sqrDistVecResult} \\
1506 % \ref{macro:transformVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{vector}\\Default Argument: transformVecResult} \\
1507 % \ref{macro:tensorVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\Default Argument: tensorVecResult} \\
1508 % \ref{macro:minVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: minVecResult} \\
1509 % \ref{macro:maxVec} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: maxVecResult} \\
1510 % \ref{macro:solveVecEQL} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\Default Argument: solveVecEQLResult} \\
1511 % \end{tabularx}
1512 % \end{center}
1513
1514 % \setlabel{\textbackslash newVec}{macro:newVec}
1515 % \DescribeMacro{newVec}
1516 % \marg{out}\marg{values}\\[1mm]
1517 % \marg{out}: var name to save the result (vector) to\\
1518 % \marg{values}: values that are assigned to out
1519 % \begin{descriptionbox}
1520 % Create a new vector and assign the given values.
1521 % \end{descriptionbox}
1522 % \begin{examplebox}
1523 % \textbackslash newVec\{myNewVec\}\{2, 3, 4\}\\
1524 % \textbackslash myNewVec \(\mapsto{} \begin{pmatrix}2\\3\\4\end{pmatrix}\)
1525 % \end{examplebox}
1526
1527 % \setlabel{\textbackslash newVecPi}{macro:newVecPi}
1528 % \DescribeMacro{newVecPi}
1529 % \marg{out}\marg{values}\\[1mm]
1530 % \marg{out}: var name to save the result (vector) to\\
1531 % \marg{values}: values that are multiplied with pi and assigned to out
1532 % \begin{descriptionbox}
1533 % Create a new vector and assign the given values as a multiple of pi.
1534 % \end{descriptionbox}
1535 % \begin{examplebox}
1536 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1537 % \textbackslash myNewVec \(\mapsto{} \begin{pmatrix}\frac{1}{2}\pi\\\pi\\2\pi\end{pmatrix}\)
1538 % \end{examplebox}
1539
1540 % \setlabel{\textbackslash randomVec}{macro:randomVec}
1541 % \DescribeMacro{randomVec}
1542 % \marg{out}\marg{dimensions}\marg{lower bound}\marg{upper bound}\\[1mm]
1543 % \marg{out}: var name to save the result (vector) to\\
1544 % \marg{dimensions}: scalar that defines the number of dimensions out should have\\
1545 % \marg{lower bound}: scalar that limits the possible values at the bottom\\
1546 % \marg{upper bound}: scalar that limits the possible values at the top
1547 % \begin{descriptionbox}
1548 % Create a new vector and assign random values between lower and
1549 % upper bound to its components.
1550 % The value is obtained by creating a random value between 0 and 1
1551 % and then interpolating between lower and upper bound.
1552 % \end{descriptionbox}
1553 % \begin{examplebox}
1554 % \textbackslash randomVec\{myNewVec\}\{4\}\{3\}\{10\}\\
1555 % \textbackslash myNewVec \(\mapsto{} \begin{pmatrix}5, 4, 8, 4\end{pmatrix}\)
1556 % \end{examplebox}
1557
1558 % \setlabel{\textbackslash copyVec}{macro:copyVec}
1559 % \DescribeMacro{copyVec}
1560 % \oarg{out}\marg{vector}\\[1mm]
1561 % \oarg{out}: var name to save the result (vector) to, default: copyVecResult\\
1562 % \marg{vector}: vector which values are assigned to out
1563 % \begin{descriptionbox}
1564 % Copy values from one vector variable to another.
1565 % \end{descriptionbox}
1566 % \begin{examplebox}
1567 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1568 % \textbackslash copyVec[copyVecResult]\{\textbackslash myNewVec\}\\
1569 % \textbackslash copyVecResult \(\mapsto{} \begin{pmatrix}0.5\\ 1\\ 2\end{pmatrix}\)
1570 % \end{examplebox}
1571
1572 % \setlabel{\textbackslash zeroVec}{macro:zeroVec}
1573 % \DescribeMacro{zeroVec}
1574 % \oarg{dims}\marg{out}\\[1mm]
1575 % \oarg{dims}: number of dimensions (rows), default: 3\\
1576 % \marg{out}: var name to save the result (vector) to
1577 % \begin{descriptionbox}
1578 % Create or override a vector with all its components being 0.
1579 % Obacht: It is not necessary to call this to create a new vector.
1580 % This is just for convenience when requiring a vector with initialized with zero.
1581 % \end{descriptionbox}
1582 % \begin{examplebox}
1583 % \textbackslash zeroVec[3]\{zeroVecResult\}\\
1584 % \textbackslash zeroVecResult \(\mapsto{} \begin{pmatrix}0\\ 0\\ 0\end{pmatrix}\)
1585 % \end{examplebox}
1586
1587 % \setlabel{\textbackslash appendToVec}{macro:appendToVec}
1588 % \DescribeMacro{appendToVec}
1589 % \marg{out}\marg{vector}\marg{scalar}\\[1mm]
1590 % \marg{out}: var name to save the result (vector) to\\
1591 % \marg{vector}: the currently present values\\
1592 % \marg{scalar}: the scalar to add to vector
1593 % \begin{descriptionbox}
1594 % Append a dimension with the given value to an already defined vector.
1595 % \end{descriptionbox}
1596 % \begin{examplebox}
1597 % \textbackslash newVec\{myNewVec\}\{0.5, 1\}\\
1598 % \textbackslash appendToVec\{myNewVec\}\{\textbackslash myNewVec\}\{-10\}\\
1599 % \textbackslash myNewVec \(\mapsto{} \begin{pmatrix}0.5\\ 1\\ -10\end{pmatrix}\)
1600 % \end{examplebox}
1601
1602 % \setlabel{\textbackslash printVec}{macro:printVec}
1603 % \DescribeMacro{printVec}
1604 % \oarg{fraction}\marg{vector}\\[1mm]
1605 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1606 % \marg{vector}: the vector that should be printed
1607 % \begin{descriptionbox}
1608 % Print the values of the given vector in vector notation.
1609 % \end{descriptionbox}
1610 % \begin{equationbox}
1611 % \(\begin{pmatrix} \mathbf{v}_1\\ \ldots\\ \mathbf{v}_n \end{pmatrix}\)
1612 % \end{equationbox}
1613 % \begin{examplebox}
1614 % \textbackslash newVec\{myNewVec\}\{1, 2, 3\}\\
1615 % \textbackslash printVec\{\textbackslash myNewVec\} \(\mapsto{} \begin{pmatrix}1\\2\\3\end{pmatrix}\)
1616 % \end{examplebox}
1617
1618 % \setlabel{\textbackslash printVecT}{macro:printVecT}
1619 % \DescribeMacro{printVecT}
1620 % \oarg{fraction}\marg{vector}\\[1mm]
1621 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1622 % \marg{vector}: the vector that should be printed
1623 % \begin{descriptionbox}
1624 % Print the values of the given vector in transposed notation.
1625 % \end{descriptionbox}
1626 % \begin{equationbox}
1627 % \(\trans{(\mathbf{v}_1, \ldots, \mathbf{v}_n)}\)
1628 % \end{equationbox}
1629 % \begin{examplebox}
1630 % \textbackslash newVec\{myNewVec\}\{1, 2, 3\}\\
1631 % \textbackslash printVecT\{\textbackslash myNewVec\} \(\mapsto{} \trans{(1, 2, 3)}\)
1632 % \end{examplebox}
1633
1634 % \setlabel{\textbackslash printVecAsPoint}{macro:printVecAsPoint}
1635 % \DescribeMacro{printVecAsPoint}
1636 % \oarg{fraction}\marg{vector}\\[1mm]
1637 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1638 % \marg{vector}: the vector that should be printed
1639 % \begin{descriptionbox}
1640 % Print the values of the given vector in point notation.
1641 % \end{descriptionbox}
1642 % \begin{equationbox}
1643 % \(\begin{bmatrix}\mathbf{v}_1\\ \ldots\\ \mathbf{v}_n\end{bmatrix}\)
1644 % \end{equationbox}
1645 % \begin{examplebox}
1646 % \textbackslash newVec\{myNewVec\}\{1, 2, 3\}\\
1647 % \textbackslash printVecAsPoint\{\textbackslash myNewVec\} \(\mapsto{} \begin{bmatrix}1\\2\\3\end{bmatrix}\)
1648 % \end{examplebox}
1649
1650 % \setlabel{\textbackslash printVecAsPi}{macro:printVecAsPi}
1651 % \DescribeMacro{printVecAsPi}
1652 % \oarg{fraction}\marg{vector}\\[1mm]
1653 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1654 % \marg{vector}: the vector that should be printed
1655 % \begin{descriptionbox}
1656 % Print the values of the given vector as a multiple of \(\pi\) in vector notation.
1657 % \end{descriptionbox}
1658 % \begin{equationbox}
1659 % \(\begin{pmatrix}\left\{\frac{\mathbf{v}_1}{\pi}\right\}\\ \ldots\\ \left\{\frac{\mathbf{v}_n}{\pi}\right\}\end{pmatrix}\pi\)
1660 % \end{equationbox}
1661 % \begin{examplebox}
1662 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1663 % \textbackslash printVecAsPi\{\textbackslash myNewVec\} \(\mapsto{} \begin{pmatrix}0.5\pi\\\pi\\2\pi\end{pmatrix}\)
1664 % \end{examplebox}
1665
1666 % \setlabel{\textbackslash printVecAsPiT}{macro:printVecAsPiT}
1667 % \DescribeMacro{printVecAsPiT}
1668 % \oarg{fraction}\marg{vector}\\[1mm]
1669 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1670 % \marg{vector}: the vector that should be printed
1671 % \begin{descriptionbox}
1672 % Print the values of the given vector as a multiple of Pi in transposed notation.
1673 % \end{descriptionbox}
1674 % \begin{equationbox}
1675 % \(\trans{\left(\left\{\frac{\mathbf{v}_1}{\pi}\right\}, \ldots, \left\{\frac{\mathbf{v}_n}{\pi}\right\}\right)}\pi\)
1676 % \end{equationbox}
1677 % \begin{examplebox}
1678 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1679 % \textbackslash printVecAsPi\{\textbackslash myNewVec\} \(\mapsto{} \trans{(0.5\pi,\pi,2\pi)}\)
1680 % \end{examplebox}
1681
1682 % \setlabel{\textbackslash printVecContent}{macro:printVecContent}
1683 % \DescribeMacro{printVecContent}
1684 % \marg{vector}\\[1mm]
1685 % \marg{vector}: the vector which values should be printed
1686 % \begin{descriptionbox}
1687 % Print the values of the given vector comma separated.
1688 % \end{descriptionbox}
1689 % \begin{equationbox}
1690 % \(\mathbf{v}_1, \ldots, \mathbf{v}_n\)
1691 % \end{equationbox}
1692
1693 % \setlabel{\textbackslash printVecContentXY}{macro:printVecContentXY}
1694 % \DescribeMacro{printVecContentXY}
1695 % \marg{vector}\\[1mm]
1696 % \marg{vector}: the vector which values should be printed
1697 % \begin{descriptionbox}
1698 % Returns the x and y component of the given vector.
1699 % \end{descriptionbox}
1700 % \begin{equationbox}
1701 % \(\mathbf{v}_1, \mathbf{v}_2\)
1702 % \end{equationbox}
1703
1704 % \setlabel{\textbackslash printVecContentXYZ}{macro:printVecContentXYZ}
1705 % \DescribeMacro{printVecContentXYZ}
1706 % \marg{vector}\\[1mm]
1707 % \marg{vector}: the vector which values should be printed
1708 % \begin{descriptionbox}
1709 % Returns the x, y and z component of the given vector.
1710 % \end{descriptionbox}
1711 % \begin{equationbox}
1712 % \(\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3\)
1713 % \end{equationbox}
1714
1715 % \setlabel{\textbackslash printVecContentXYZW}{macro:printVecContentXYZW}
1716 % \DescribeMacro{printVecContentXYZW}
1717 % \marg{vector}\\[1mm]
1718 % \marg{vector}: the vector which values should be printed
1719 % \begin{descriptionbox}
1720 % Returns the x, y, z and w component of the given vector
1721 % \end{descriptionbox}
1722 % \begin{equationbox}
1723 % \(\mathbf{v}_1, \mathbf{v}_2, \mathbf{v}_3, \mathbf{v}_4\)
1724 % \end{equationbox}
1725
1726 % \setlabel{\textbackslash getVecHeight}{macro:getVecHeight}
1727 % \DescribeMacro{getVecHeight}
1728 % \oarg{out}\marg{vector}\\[1mm]
1729 % \oarg{out}: var name to save the result (scalar) to, default: vecHeightResult\\
1730 % \marg{vector}: the vector of which to return the height
1731 % \begin{descriptionbox}
1732 % Returns the number of components that given vector has (number of dimensions).
1733 % \end{descriptionbox}
1734 % \begin{equationbox}
1735 % \(o = dim(\mathbf{v})\)
1736 % \end{equationbox}
1737 % \begin{examplebox}
1738 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1739 % \textbackslash getVecHeight\{\textbackslash myNewVec\}\\
1740 % \textbackslash vecHeightResult \(\mapsto{} 3\)
1741 % \end{examplebox}
1742
1743 % \setlabel{\textbackslash printScalarPComp}{macro:printScalarPComp}
1744 % \DescribeMacro{printScalarPComp}
1745 % \oarg{fraction}\marg{vector v}\marg{vector w}\\[1mm]
1746 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1747 % \marg{vector v}: the first vector\\
1748 % \marg{vector w}: the second vector
1749 % \begin{descriptionbox}
1750 % Print the intermediate components of the scalarproduct calculation.
1751 % \end{descriptionbox}
1752 % \begin{equationbox}
1753 % \(\mathbf{v}_1 * \mathbf{w}_1 + \ldots + \mathbf{v}_n * \mathbf{w}_n\)
1754 % \end{equationbox}
1755 % \begin{examplebox}
1756 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1757 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1758 % \textbackslash printScalarPComp\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\} \(\mapsto{} 0.5*0.5+1*1+2*2\)
1759 % \end{examplebox}
1760 % \begin{warningbox}
1761 % When both vectors do not have the same length
1762 % \end{warningbox}
1763
1764 % \setlabel{\textbackslash printCrossPComp}{macro:printCrossPComp}
1765 % \DescribeMacro{printCrossPComp}
1766 % \oarg{fraction}\marg{vector v}\marg{vector w}\\[1mm]
1767 % \oarg{fraction}: whether or not the value should be printed as a fraction (val=1), default: 0\\
1768 % \marg{vector v}: the first vector\\
1769 % \marg{vector w}: the second vector
1770 % \begin{descriptionbox}
1771 % Print the intermediate components of the crossproduct calculation.
1772 % \end{descriptionbox}
1773 % \begin{equationbox}
1774 % \(\begin{pmatrix} \mathbf{v}_2*\mathbf{w}_3 - \mathbf{v}_3*\mathbf{w}_2\\ \mathbf{v}_3*\mathbf{w}_1-\mathbf{v}_1*\mathbf{w}_3\\ \mathbf{v}_1*\mathbf{w}_2-\mathbf{w}_2*\mathbf{w}_1 \end{pmatrix}\)
1775 % \end{equationbox}
1776 % \begin{examplebox}
1777 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1778 % \textbackslash newVec\{myNewVecB\}\{3, 4, 5\}\\
1779 % \textbackslash printScalarPComp\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\} \(\mapsto{} \begin{pmatrix}1*5 - 2*4\\ 2*3 - 0.5*5\\ 0.5*4 -1*3\end{pmatrix}\)
1780 % \end{examplebox}
1781 % \begin{warningbox}
1782 % When one of both vectors does not have length 3
1783 % \end{warningbox}
1784
1785 % \setlabel{\textbackslash roundVec}{macro:roundVec}
1786 % \DescribeMacro{roundVec}
1787 % \oarg{out}\marg{vector}\marg{digits}\\[1mm]
1788 % \oarg{out}: var name to save the result (vector) to, default: roundVecResult\\
1789 % \marg{vector}: the vector that schould be rounded\\
1790 % \marg{digits}: number of digits after comma
1791 % \begin{descriptionbox}
1792 % Round the values ot the given vector.
1793 % \end{descriptionbox}
1794 % \begin{equationbox}
1795 % \(\mathbf{v} = \begin{pmatrix}\lfloor d_1\rceil\\\ldots\\\lfloor d_n\rceil\end{pmatrix}\)
1796 % \end{equationbox}
1797 % \begin{examplebox}
1798 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1799 % \textbackslash roundVec[roundVecResult]\{\textbackslash myNewVec\}\{0\}\\
1800 % \textbackslash roundVecResult \(\mapsto{} \begin{pmatrix}1\\1\\2\end{pmatrix}\)
1801 % \end{examplebox}
1802
1803 % \setlabel{\textbackslash ceilVec}{macro:ceilVec}
1804 % \DescribeMacro{ceilVec}
1805 % \oarg{out}\marg{vector}\\[1mm]
1806 % \oarg{out}: var name to save the result (vector) to, default: ceilVecResult\\
1807 % \marg{vector}: the vector that should be ceiled
1808 % \begin{descriptionbox}
1809 % Ceil the values of the given vector.
1810 % \end{descriptionbox}
1811 % \begin{equationbox}
1812 % \(o = \begin{pmatrix}\lceil \mathbf{v}_1\rceil\\\ldots\\\lceil \mathbf{v}_n\rceil\end{pmatrix}\)
1813 % \end{equationbox}
1814 % \begin{examplebox}
1815 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1816 % \textbackslash ceilVec[ceilVecResult]\{\textbackslash myNewVec\}\\
1817 % \textbackslash ceilVecResult \(\mapsto{} \begin{pmatrix}1\\1\\2\end{pmatrix}\)
1818 % \end{examplebox}
1819
1820 % \setlabel{\textbackslash floorVec}{macro:floorVec}
1821 % \DescribeMacro{floorVec}
1822 % \oarg{out}\marg{vector}\\[1mm]
1823 % \oarg{out}: var name to save the result (vector) to, default: floorVecResult\\
1824 % \marg{vector}: the vector that should be floored
1825 % \begin{descriptionbox}
1826 % Floor the values of the given vector.
1827 % \end{descriptionbox}
1828 % \begin{equationbox}
1829 % \(o = \begin{pmatrix}\lfloor \mathbf{v}_1\rfloor\\\ldots\\\lfloor \mathbf{v}_n\rfloor\end{pmatrix}\)
1830 % \end{equationbox}
1831 % \begin{examplebox}
1832 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
1833 % \textbackslash floorVec[floorVecResult]\{\textbackslash myNewVec\}\\
1834 % \textbackslash floorVecResult \(\mapsto{} \begin{pmatrix}0\\1\\2\end{pmatrix}\)
1835 % \end{examplebox}
1836
1837 % \setlabel{\textbackslash dehomogenVec}{macro:dehomogenVec}
1838 % \DescribeMacro{dehomogenVec}
1839 % \oarg{out}\marg{vector}\\[1mm]
1840 % \oarg{out}: var name to save the result (vector) to, default: dehomogenVecResult\\
1841 % \marg{vector}: the vector that should be dehomogenized
1842 % \begin{descriptionbox}
1843 % Dehomogenize the values of the given vector. This divides all vector components by the last component.
1844 % \end{descriptionbox}
1845 % \begin{equationbox}
1846 % \(o = \begin{pmatrix} \frac{\mathbf{v}_1}{\mathbf{v}_n} \\ \ldots \\ \frac{\mathbf{v}_{n-1}}{\mathbf{v}_n} \end{pmatrix}\)
1847 % \end{equationbox}
1848 % \begin{examplebox}
1849 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2, 2\}\\
1850 % \textbackslash dehomogenVec[dehomogenVecResult]\{\textbackslash myNewVec\}\\
1851 % \textbackslash dehomogenVecResult \(\mapsto{} \begin{pmatrix}0.25\\0.5\\1\\1\end{pmatrix}\)
1852 % \end{examplebox}
1853
1854 % \setlabel{\textbackslash addVec}{macro:addVec}
1855 % \DescribeMacro{addVec}
1856 % \oarg{out}\marg{vector}\marg{vectors}\\[1mm]
1857 % \oarg{out}: var name to save the result (vector) to, default: addVecResult\\
1858 % \marg{vector}: the vector to add to\\
1859 % \marg{vectors}: the list of vectors with which to add
1860 % \begin{descriptionbox}
1861 % Add the values of \(1\) to \(m\) vectors to the values of the given vector.
1862 % \end{descriptionbox}
1863 % \begin{equationbox}
1864 % \(o = \begin{pmatrix}\mathbf{v}_1 + \mathbf{vs}_{1,1} + \ldots + \mathbf{vs}_{m,1}\\\ldots\\\mathbf{v}_n + \mathbf{vs}_{1,n} + \ldots + \mathbf{vs}_{m,n}\end{pmatrix}\)
1865 % \end{equationbox}
1866 % \begin{examplebox}
1867 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1868 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1869 % \textbackslash addVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
1870 % \textbackslash addVecResult \(\mapsto{} \begin{pmatrix}1.5\\3\\6\end{pmatrix}\)\\
1871 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1872 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1873 % \textbackslash newVec\{myNewVecC\}\{0.5, 1, 2\}\\
1874 % \textbackslash addVec[resultName]\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB, \textbackslash myNewVecC\}\\
1875 % \textbackslash resultName \(\mapsto{} \begin{pmatrix}1.5\\3\\6\end{pmatrix}\)
1876 % \end{examplebox}
1877
1878 % \setlabel{\textbackslash subVec}{macro:subVec}
1879 % \DescribeMacro{subVec}
1880 % \oarg{out}\marg{vector}\marg{vectors}\\[1mm]
1881 % \oarg{out}: var name to save the result (vector) to, default: subVecResult\\
1882 % \marg{vector}: the vector to subtract from\\
1883 % \marg{vectors}: the list of vectors with which to subtract
1884 % \begin{descriptionbox}
1885 % Subract the values of \(1\) to \(m\) vectors from the values of the given vector.
1886 % \end{descriptionbox}
1887 % \begin{equationbox}
1888 % \(o = \begin{pmatrix}\mathbf{v}_1 - \mathbf{vs}_{1,1} - \ldots - \mathbf{vs}_{m,1}\\\ldots\\\mathbf{v}_n - \mathbf{vs}_{1,n} - \ldots - \mathbf{vs}_{m,n}\end{pmatrix}\)
1889 % \end{equationbox}
1890 % \begin{examplebox}
1891 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1892 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1893 % \textbackslash subVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
1894 % \textbackslash subVecResult \(\mapsto{} \begin{pmatrix}0\\0\\0\end{pmatrix}\)\\
1895 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1896 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1897 % \textbackslash newVec\{myNewVecC\}\{0.5, 1, 2\}\\
1898 % \textbackslash subVec[resultName]\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB, \textbackslash myNewVecC\}\\
1899 % \textbackslash resultName \(\mapsto{} \begin{pmatrix}-0.5\\-1\\-2\end{pmatrix}\)
1900 % \end{examplebox}
1901
1902 % \setlabel{\textbackslash mulVec}{macro:mulVec}
1903 % \DescribeMacro{mulVec}
1904 % \oarg{out}\marg{vector}\marg{vectors}\\[1mm]
1905 % \oarg{out}: var name to save the result (vector) to, default: mulVecResult\\
1906 % \marg{vector}: the vector to multiply\\
1907 % \marg{vectors}: the list of vectors with which to multiply
1908 % \begin{descriptionbox}
1909 % Multiply the values of \(1\) to \(m\) vectors with the values of the given vector.
1910 % See Hadamard product (element-wise product) for more information.
1911 % \end{descriptionbox}
1912 % \begin{equationbox}
1913 % \begin{align*}o &= \mathbf{v} \odot \mathbf{vs}_1 \odot \ldots \odot \mathbf{vs}_m\\ &= \begin{pmatrix}\mathbf{v}_1 * \mathbf{vs}_{1,1} * \ldots * \mathbf{vs}_{m,1}\\\ldots\\\mathbf{v}_n * \mathbf{vs}_{1,n} * \ldots * \mathbf{vs}_{m,n}\end{pmatrix}\end{align*}
1914 % \end{equationbox}
1915 % \begin{examplebox}
1916 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1917 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1918 % \textbackslash mulVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\} \(\mapsto{} \begin{pmatrix}0.25\\1\\4\end{pmatrix}\)
1919 % \end{examplebox}
1920
1921 % \setlabel{\textbackslash divVec}{macro:divVec}
1922 % \DescribeMacro{divVec}
1923 % \oarg{out}\marg{vector}\marg{vectors}\\[1mm]
1924 % \oarg{out}: var name to save the result (vector) to, default: divVecResult\\
1925 % \marg{vector}: the vector to divide\\
1926 % \marg{vectors}: the list of vectors to divide with
1927 % \begin{descriptionbox}
1928 % Divide the values of the given vector by the values of \(1\) to \(m\) vectors (element-wise division).
1929 % \end{descriptionbox}
1930 % \begin{equationbox}
1931 % \begin{align*}o &= \mathbf{v} \oslash \mathbf{vs}_1 \oslash \ldots \oslash \mathbf{vs}_m\\ &= \begin{pmatrix}\mathbf{v}_1 / \mathbf{vs}_{1,1} / \ldots / \mathbf{vs}_{m,1}\\\ldots\\\mathbf{v}_n / \mathbf{vs}_{1,n} / \ldots / \mathbf{vs}_{m,n}\end{pmatrix}\end{align*}
1932 % \end{equationbox}
1933 % \begin{examplebox}
1934 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1935 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
1936 % \textbackslash divVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\} \(\mapsto{} \begin{pmatrix}1\\1\\1\end{pmatrix}\)
1937 % \end{examplebox}
1938
1939 % \setlabel{\textbackslash scaleVec}{macro:scaleVec}
1940 % \DescribeMacro{scaleVec}
1941 % \oarg{out}\marg{vector}\marg{scalar}\\[1mm]
1942 % \oarg{out}: var name to save the result (vector) to, default: scaleVecResult\\
1943 % \marg{vector}: the vector to scale\\
1944 % \marg{scalar}: the scalar to scale with
1945 % \begin{descriptionbox}
1946 % Multiply the values of the given vector by a scalar.
1947 % \end{descriptionbox}
1948 % \begin{equationbox}
1949 % \(o = \begin{pmatrix}\mathbf{v}_1 * s\\\ldots\\\mathbf{v}_n * s\end{pmatrix}\)
1950 % \end{equationbox}
1951 % \begin{examplebox}
1952 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1953 % \textbackslash newScalar\{myNewScalar\}\{2\}\\
1954 % \textbackslash scaleVec\{\textbackslash myNewVecA\}\{\textbackslash myNewScalar\}\\
1955 % \textbackslash scaleVecResult \(\mapsto{} \begin{pmatrix}1\\2\\4\end{pmatrix}\)
1956 % \end{examplebox}
1957
1958 % \setlabel{\textbackslash divVecScalar}{macro:divVecScalar}
1959 % \DescribeMacro{divVecScalar}
1960 % \oarg{out}\marg{vector}\marg{scalar}\\[1mm]
1961 % \oarg{out}: var name to save the result (vector) to, default: divVecScalarResult\\
1962 % \marg{vector}: the vector to divide\\
1963 % \marg{scalar}: the scalar to divide with
1964 % \begin{descriptionbox}
1965 % Divide the values of the given vector by a scalar.
1966 % \end{descriptionbox}
1967 % \begin{equationbox}
1968 % \(o = \begin{pmatrix}\frac{\mathbf{v}_1}{s}\\\ldots\\\frac{\mathbf{v}_n}{s}\end{pmatrix}\)
1969 % \end{equationbox}
1970 % \begin{examplebox}
1971 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1972 % \textbackslash newScalar\{myNewScalar\}\{2\}\\
1973 % \textbackslash divVecScalar\{\textbackslash myNewVecA\}\{\textbackslash myNewScalar\}\\
1974 % \textbackslash divVecScalarResult \(\mapsto{} \begin{pmatrix}0.25\\0.5\\1\end{pmatrix}\)
1975 % \end{examplebox}
1976
1977 % \setlabel{\textbackslash negateVec}{macro:negateVec}
1978 % \DescribeMacro{negateVec}
1979 % \oarg{out}\marg{vector}\\[1mm]
1980 % \oarg{out}: var name to save the result (vector) to, default: negateVecResult\\
1981 % \marg{vector}: the vector to negate
1982 % \begin{descriptionbox}
1983 % Negate the values of the given vector.
1984 % \end{descriptionbox}
1985 % \begin{equationbox}
1986 % \(o = \begin{pmatrix}-\mathbf{v}_1\\\ldots\\-\mathbf{v}_n\end{pmatrix}\)
1987 % \end{equationbox}
1988 % \begin{examplebox}
1989 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
1990 % \textbackslash negateVecResult\{\textbackslash myNewVecA\}\\
1991 % \textbackslash negateVecResult \(\mapsto{} \begin{pmatrix}-0.5\\-1\\-2\end{pmatrix}\)
1992 % \end{examplebox}
1993
1994 % \setlabel{\textbackslash scaleAndAddVec}{macro:scaleAndAddVec}
1995 % \DescribeMacro{scaleAndAddVec}
1996 % \oarg{out}\marg{vector v}\marg{vector w}\marg{scalar}\\[1mm]
1997 % \oarg{out}: var name to save the result (vector) to, default: scaleAndAddVecResult\\
1998 % \marg{vector v}: the vector to add to\\
1999 % \marg{vector w}: the vector that is multiplied and then added\\
2000 % \marg{scalar}: the scalar that is the muliplier
2001 % \begin{descriptionbox}
2002 % Adds two vectors after multiplying the second one by a scalar.
2003 % \end{descriptionbox}
2004 % \begin{equationbox}
2005 % \(o = \mathbf{v} + \mathbf{w} * s = \begin{pmatrix}\mathbf{v}_1 + \mathbf{w}_1 * s\\\ldots\\\mathbf{v}_n + \mathbf{w}_n * s\end{pmatrix}\)
2006 % \end{equationbox}
2007 % \begin{examplebox}
2008 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2009 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
2010 % \textbackslash newScalar\{myNewScalar\}\{2\}\\
2011 % \textbackslash scaleAndAddVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\{\textbackslash myNewScalar\}\\
2012 % \textbackslash scaleAndAddVecResult \(\mapsto{} \begin{pmatrix}1.5\\3\\6\end{pmatrix}\)
2013 % \end{examplebox}
2014
2015 % \setlabel{\textbackslash lerpVec}{macro:lerpVec}
2016 % \DescribeMacro{lerpVec}
2017 % \oarg{out}\marg{vector v}\marg{vector w}\marg{scalar t}\\[1mm]
2018 % \oarg{out}: var name to save the result (vector) to, default: lerpVecResult\\
2019 % \marg{vector v}: the start vector\\
2020 % \marg{vector w}: the end vector\\
2021 % \marg{scalar t}: interpolation amount range [0-1]
2022 % \begin{descriptionbox}
2023 % Lineraly interpolate between the values of two vectors (element-wise interpolation).
2024 % \end{descriptionbox}
2025 % \begin{equationbox}
2026 % \(o = (1-t) * \mathbf{v} + t * \mathbf{w} = \begin{pmatrix}(1-t) \mathbf{v}_1 + t *\mathbf{w}_1\\\ldots\\(1-t) \mathbf{v}_n + t *\mathbf{w}_n\end{pmatrix}\)
2027 % \end{equationbox}
2028 % \begin{examplebox}
2029 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2030 % \textbackslash newVec\{myNewVecB\}\{1, 2, 4\}\\
2031 % \textbackslash newScalar\{myNewScalar\}\{0.5\}\\
2032 % \textbackslash lerpVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\{\textbackslash myNewScalar\}\\
2033 % \textbackslash lerpVecResult \(\mapsto{} \begin{pmatrix}0.75\\1.5\\3\end{pmatrix}\)
2034 % \end{examplebox}
2035
2036 % \setlabel{\textbackslash slerpVec}{macro:slerpVec}
2037 % \DescribeMacro{slerpVec}
2038 % \oarg{out}\marg{vector v}\marg{vector w}\marg{scalar t}\\[1mm]
2039 % \oarg{out}: var name to save the result (vector) to, default: slerpVecResult\\
2040 % \marg{vector v}: the start vector\\
2041 % \marg{vector w}: the end vector\\
2042 % \marg{scalar t}: interpolation amount range [0-1]
2043 % \begin{descriptionbox}
2044 % Performs a spherical linear interpolation between two vectors.
2045 % This expects vector v and vector w to be normalized.
2046 % \end{descriptionbox}
2047 % \begin{equationbox}
2048 % TODO
2049 % \end{equationbox}
2050
2051 % \setlabel{\textbackslash dotVec}{macro:dotVec}
2052 % \DescribeMacro{dotVec}
2053 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2054 % \oarg{out}: var name to save the result (scalar) to, default: dotVecResult\\
2055 % \marg{vector v}: the first vector\\
2056 % \marg{vector w}: the second vector
2057 % \begin{descriptionbox}
2058 % Calculate the dotproduct of the given two vectors.
2059 % Other names for this operation are inner product and scalarproduct.
2060 % \end{descriptionbox}
2061 % \begin{equationbox}
2062 % \(o = \mathbf{v}_1 * \mathbf{w}_1 + \ldots + \mathbf{v}_n * \mathbf{w}_n\)
2063 % \end{equationbox}
2064 % \begin{examplebox}
2065 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2066 % \textbackslash newVec\{myNewVecB\}\{1, 2, 4\}\\
2067 % \textbackslash dotVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2068 % \textbackslash dotVecResult \(\mapsto{} 10.5\)\\
2069 % \textbackslash dotVec[resultName]\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2070 % \textbackslash resultName \(\mapsto{} 10.5\)
2071 % \end{examplebox}
2072 % \begin{warningbox}
2073 % When both vectors do not have the same length
2074 % \end{warningbox}
2075
2076 % \setlabel{\textbackslash lenVec}{macro:lenVec}
2077 % \DescribeMacro{lenVec}
2078 % \oarg{out}\marg{vector}\\[1mm]
2079 % \oarg{out}: var name to save the result (scalar) to, default: lenVecResult\\
2080 % \marg{vector}: the vector for which to calculate the length
2081 % \begin{descriptionbox}
2082 % Calculate the length of the given vector.
2083 % \end{descriptionbox}
2084 % \begin{equationbox}
2085 % \(o = \norm{\mathbf{v}} = \sqrt{\mathbf{v}_1^2 + \ldots + \mathbf{v}_n^2}\)
2086 % \end{equationbox}
2087 % \begin{examplebox}
2088 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2089 % \textbackslash lenVec\{\textbackslash myNewVecA\}\\
2090 % \textbackslash lenVecResult \(\mapsto{} 2.29\)
2091 % \end{examplebox}
2092
2093 % \setlabel{\textbackslash sqrLenVec}{macro:sqrLenVec}
2094 % \DescribeMacro{sqrLenVec}
2095 % \oarg{out}\marg{vector}\\[1mm]
2096 % \oarg{out}: var name to save the result (scalar) to, default: sqrLenVecResult\\
2097 % \marg{vector}: the vector for which to calculate the squared length
2098 % \begin{descriptionbox}
2099 % Calculate the squared length of the given vector.
2100 % \end{descriptionbox}
2101 % \begin{equationbox}
2102 % \(o = \norm{\mathbf{v}}^2 = \mathbf{v}_1^2 + \ldots + \mathbf{v}_n^2\)
2103 % \end{equationbox}
2104 % \begin{examplebox}
2105 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2106 % \textbackslash sqrLenVec\{\textbackslash myNewVecA\}\\
2107 % \textbackslash sqrLenVecResult \(\mapsto{} 5.25\)
2108 % \end{examplebox}
2109
2110 % \setlabel{\textbackslash normalizeVec}{macro:normalizeVec}
2111 % \DescribeMacro{normalizeVec}
2112 % \oarg{out}\marg{vector}\\[1mm]
2113 % \oarg{out}: var name to save the result (vector) to, default: normalizeVecResult\\
2114 % \marg{vector}: the vector which to normalize
2115 % \begin{descriptionbox}
2116 % Divide all components of the vector by its length.
2117 % \end{descriptionbox}
2118 % \begin{equationbox}
2119 % \(o = \begin{pmatrix} \frac{\mathbf{v}_1}{\norm{\mathbf{v}}}\\ \ldots\\ \frac{\mathbf{v}_n}{\norm{\mathbf{v}}}\end{pmatrix}\)
2120 % \end{equationbox}
2121 % \begin{examplebox}
2122 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2123 % \textbackslash normalizeVec\{\textbackslash myNewVecA\}\\
2124 % \textbackslash normalizeVecResult \(\mapsto{} \begin{pmatrix} 0.12\\ 0.24\\ 0.96\end{pmatrix}\)\\
2125 % \textbackslash normalizeVec[resultName]\{\textbackslash myNewVecA\}\\
2126 % \textbackslash resultName \(\mapsto{} \begin{pmatrix} 0.12\\ 0.24\\ 0.96\end{pmatrix}\)
2127 % \end{examplebox}
2128
2129 % \setlabel{\textbackslash crossVec}{macro:crossVec}
2130 % \DescribeMacro{crossVec}
2131 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2132 % \oarg{out}: var name to save the result (vector) to, default: crossVecResult\\
2133 % \marg{vector v}: the first vector\\
2134 % \marg{vector w}: the second vector
2135 % \begin{descriptionbox}
2136 % Calculate crossproduct for the two given vectors.
2137 % \end{descriptionbox}
2138 % \begin{equationbox}
2139 % \(o = \begin{pmatrix} \mathbf{v}_2*\mathbf{w}_3 - \mathbf{v}_3*\mathbf{w}_2\\ \mathbf{v}_3*\mathbf{w}_1-\mathbf{v}_1*\mathbf{w}_3\\ \mathbf{v}_1*\mathbf{w}_2-\mathbf{w}_2*\mathbf{w}_1 \end{pmatrix}\)
2140 % \end{equationbox}
2141 % \begin{examplebox}
2142 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2143 % \textbackslash newVec\{myNewVecB\}\{0.5, 0, 2\}\\
2144 % \textbackslash crossVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2145 % \textbackslash crossVecResult \(\mapsto{} \begin{pmatrix} 2\\ 0\\ -0.5\end{pmatrix}\)
2146 % \end{examplebox}
2147 % \begin{warningbox}
2148 % When one of both vectors does not have length 3
2149 % \end{warningbox}
2150
2151 % \setlabel{\textbackslash crossVecTwoD}{macro:crossVecTwoD}
2152 % \DescribeMacro{crossVecTwoD}
2153 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2154 % \oarg{out}: var name to save the result (vector) to, default: crossVecResult\\
2155 % \marg{vector v}: the first vector\\
2156 % \marg{vector w}: the second vector
2157 % \begin{descriptionbox}
2158 % Calculate crossproduct for the two given vectors.
2159 % \end{descriptionbox}
2160 % \begin{equationbox}
2161 % \(o = \mathbf{v}_1*\mathbf{w}_2 - \mathbf{v}_2*\mathbf{w}_1\)
2162 % \end{equationbox}
2163 % \begin{examplebox}
2164 % \textbackslash newVec\{myNewVecA\}\{0.5, 1\}\\
2165 % \textbackslash newVec\{myNewVecB\}\{0.5, 0\}\\
2166 % \textbackslash crossVecTwoD\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2167 % \textbackslash crossVecResult \(\mapsto{} -0.5\)
2168 % \end{examplebox}
2169 % \begin{warningbox}
2170 % When one of both vectors does not have length 3
2171 % \end{warningbox}
2172
2173 % \setlabel{\textbackslash angleVec}{macro:angleVec}
2174 % \DescribeMacro{angleVec}
2175 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2176 % \oarg{out}: var name to save the result (scalar) to, default: angleVecResult\\
2177 % \marg{vector v}: the first vector\\
2178 % \marg{vector w}: the second vector
2179 % \begin{descriptionbox}
2180 % Get the angle between the given two vectors in radian.
2181 % \end{descriptionbox}
2182 % \begin{equationbox}
2183 % \(o = \angle(\mathbf{v}, \mathbf{w})\)
2184 % \end{equationbox}
2185 % \begin{examplebox}
2186 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2187 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
2188 % \textbackslash angleVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2189 % \textbackslash angleVecResult \(\mapsto{} TODO scalar\)
2190 % \end{examplebox}
2191
2192 % \setlabel{\textbackslash distVec}{macro:distVec}
2193 % \DescribeMacro{distVec}
2194 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2195 % \oarg{out}: var name to save the result (scalar) to, default: distVecResult\\
2196 % \marg{vector v}: the first vector\\
2197 % \marg{vector w}: the second vector
2198 % \begin{descriptionbox}
2199 % Calculates the euclidian distance between the given two vectors.
2200 % \end{descriptionbox}
2201 % \begin{equationbox}
2202 % \(o = \norm{\mathbf{v} - \mathbf{w}}\)
2203 % \end{equationbox}
2204 % \begin{examplebox}
2205 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2206 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
2207 % \textbackslash distVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2208 % \textbackslash distVecResult \(\mapsto{} TODO scalar\)
2209 % \end{examplebox}
2210 % \begin{warningbox}
2211 % When vector v and vector w do not have the same length
2212 % \end{warningbox}
2213
2214 % \setlabel{\textbackslash sqrDistVec}{macro:sqrDistVec}
2215 % \DescribeMacro{sqrDistVec}
2216 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2217 % \oarg{out}: var name to save the result (scalar) to, default: sqrDistVecResult\\
2218 % \marg{vector v}: the first vector\\
2219 % \marg{vector w}: the second vector
2220 % \begin{descriptionbox}
2221 % Calculates the squared euclidian distance between two vectors.
2222 % \end{descriptionbox}
2223 % \begin{equationbox}
2224 % \(o = \norm{\mathbf{v} - \mathbf{w}}^2\)
2225 % \end{equationbox}
2226 % \begin{examplebox}
2227 % \textbackslash newVec\{myNewVecA\}\{0.5, 1, 2\}\\
2228 % \textbackslash newVec\{myNewVecB\}\{0.5, 1, 2\}\\
2229 % \textbackslash sqrDistVec\{\textbackslash myNewVecA\}\{\textbackslash myNewVecB\}\\
2230 % \textbackslash sqrDistVecResult \(\mapsto{} TODO scalar\)
2231 % \end{examplebox}
2232 % \begin{warningbox}
2233 % When vector v and vector w do not have the same length
2234 % \end{warningbox}
2235
2236 % \setlabel{\textbackslash transformVec}{macro:transformVec}
2237 % \DescribeMacro{transformVec}
2238 % \oarg{out}\marg{matrix}\marg{vector}\\[1mm]
2239 % \oarg{out}: var name to save the result (vector) to, default: transformVecResult\\
2240 % \marg{matrix}: the matrix to transform the vetor with\\
2241 % \marg{vector}: the vector to transform
2242 % \begin{descriptionbox}
2243 % Multiply the given vector with a matrix (for transformation).
2244 % \end{descriptionbox}
2245 % \begin{equationbox}
2246 % \(o = \mathbf{M} \cdot \mathbf{v}\ \vert\ \mathbf{M} \in \R^{m\times n}, \mathbf{v} \in \R^n\)
2247 % \end{equationbox}
2248 % \begin{examplebox}
2249 % \textbackslash newVec\{myNewVec\}\{0.5, 1, 2\}\\
2250 % \textbackslash newMat\{myNewMatrix\}\{\{\{0.5, 1, 2\}\{4, 5, 6\}\{7, 8, 9\}\}\}\\
2251 % \textbackslash transformVec\{\textbackslash myNewMatrix\}\{\textbackslash myNewVec\}\\
2252 % \textbackslash transformVecResult \(\mapsto{} \begin{pmatrix} 5.25\\ 19\\ 29.5\end{pmatrix}\)\\
2253 % \textbackslash transformVec[resultName]\{\textbackslash myNewMatrix\}\{\textbackslash myNewVec\}\\
2254 % \textbackslash resultName \(\mapsto{} \begin{pmatrix} 5.25\\ 19\\ 29.5\end{pmatrix}\)
2255 % \end{examplebox}
2256 % \begin{warningbox}
2257 % When matrix and vector have a dimension mismatch
2258 % \end{warningbox}
2259
2260 % \setlabel{\textbackslash tensorVec}{macro:tensorVec}
2261 % \DescribeMacro{tensorVec}
2262 % \oarg{out}\marg{vector}\\[1mm]
2263 % \oarg{out}: var name to save the result (matrix) to, default: tensorVecResult\\
2264 % \marg{vector}: the vector to multiply with itself
2265 % \begin{descriptionbox}
2266 % Outer product: Multiply a vector (column) with itself (row) resulting in a matrix. (Dyadic product, Tensor product)
2267 % \end{descriptionbox}
2268 % \begin{equationbox}
2269 % \(o = \mathbf{v} \trans{\mathbf{v}} = \mathbf{v} \otimes \mathbf{v}\)
2270 % \end{equationbox}
2271 % \begin{warningbox}
2272 % When matrix and vector have a dimension mismatch
2273 % \end{warningbox}
2274
2275 % \setlabel{\textbackslash minVec}{macro:minVec}
2276 % \DescribeMacro{minVec}
2277 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2278 % \oarg{out}: var name to save the result (vector) to, default: minVecResult\\
2279 % \marg{vector v}: the first vector\\
2280 % \marg{vector w}: the second vector
2281 % \begin{descriptionbox}
2282 % Return the componentwise minimum of the given two vectors.
2283 % \end{descriptionbox}
2284 % \begin{equationbox}
2285 % \(o = \begin{pmatrix} \min(\mathbf{v}_1, \mathbf{w}_1)\\ \ldots\\ \min(\mathbf{v}_n, \mathbf{w}_n)\end{pmatrix}\)
2286 % \end{equationbox}
2287 % \begin{warningbox}
2288 % When vector v and vector w do not have the same length
2289 % \end{warningbox}
2290
2291 % \setlabel{\textbackslash maxVec}{macro:maxVec}
2292 % \DescribeMacro{maxVec}
2293 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2294 % \oarg{out}: var name to save the result (vector) to, default: maxVecResult\\
2295 % \marg{vector v}: the first vector\\
2296 % \marg{vector w}: the second vector
2297 % \begin{descriptionbox}
2298 % Return the componentwise maximum of the given two vectors.
2299 % \end{descriptionbox}
2300 % \begin{equationbox}
2301 % \(o = \begin{pmatrix} \max(\mathbf{v}_1, \mathbf{w}_1)\\ \ldots\\ \max(\mathbf{v}_n, \mathbf{w}_n)\end{pmatrix}\)
2302 % \end{equationbox}
2303 % \begin{warningbox}
2304 % When vector v and vector w do not have the same length
2305 % \end{warningbox}
2306
2307 % \setlabel{\textbackslash solveVecEQL}{macro:solveVecEQL}
2308 % \DescribeMacro{solveVecEQL}
2309 % \oarg{out}\marg{vector v}\marg{vector w}\\[1mm]
2310 % \oarg{out}: var name to save the result (scalar) to, default: solveVecEQLResult\\
2311 % \marg{vector v}: the first vector\\
2312 % \marg{vector w}: the second vector
2313 % \begin{descriptionbox}
2314 % Solve the equation \(vector v*x+vector w=0\) for \(x\).
2315 % The command expects the input to be two vectors of the same length.
2316 % The command iterates both vectors componentwise and solves the equation per component.
2317 % If the the result does not match across all components the equation can not be solved.
2318 % \end{descriptionbox}
2319 % \begin{equationbox}
2320 % \(o = \frac{-\mathbf{w}_1}{\mathbf{v}_1} = \ldots = \frac{-\mathbf{w}_n}{\mathbf{v}_n}\)
2321 % \end{equationbox}
2322
2323 % \section{Implementation}
2324
2325 % \iffalse
2326 %<*package>
2327 % \fi
2328 % \subsection{matrix}
2329 % \begin{center}
2330 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
2331 % \textbf{Command} & \textbf{Arguments} \\ \hline
2332 % \ref{macro:newMat_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalars}} \\
2333 % \ref{macro:newMatFromRow_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{row}} \\
2334 % \ref{macro:newMatFromRowVecs_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{rows}} \\
2335 % \ref{macro:newMatFromColVecs_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{columns}} \\
2336 % \ref{macro:newEmptyMat_impl} & \makecell[t{p{8cm}}]{\marg{out}} \\
2337 % \ref{macro:newDiagMat_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalars}} \\
2338 % \ref{macro:appendRowToMat_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{matrix}, \marg{vector r}} \\
2339 % \ref{macro:newTransMat_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector t}} \\
2340 % \ref{macro:newScaleMat_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector s}} \\
2341 % \ref{macro:newRotMatTwoD_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\rotMatResult} \\
2342 % \ref{macro:newRotMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\rotMatResult} \\
2343 % \ref{macro:newLookAtMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{right}, \marg{up}, \marg{dir}, \marg{pos}\\lookAtMatResult} \\
2344 % \ref{macro:newProjMat_impl} & \makecell[t{p{8cm}}]{\marg{out}} \\
2345 % \ref{macro:newProjMatGen_impl} & \makecell[t{p{8cm}}]{\marg{out}} \\
2346 % \ref{macro:newFrustumMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{fovx}, \marg{fovy}, \marg{near}, \marg{far}\\frustMatResult} \\
2347 % \ref{macro:printMat_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{matrix}\\0} \\
2348 % \ref{macro:printMatDiag_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{matrix}\\0} \\
2349 % \ref{macro:getMatHeight_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\matHeightResult} \\
2350 % \ref{macro:getMatWidth_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\matWidthResult} \\
2351 % \ref{macro:transposeMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\transposeMatResult} \\
2352 % \ref{macro:addMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{matrices}\\addMatResult} \\
2353 % \ref{macro:subMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{matrices}\\subMatResult} \\
2354 % \ref{macro:mulMatScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{scalar}\\mulMatScalarResult} \\
2355 % \ref{macro:mulMatVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{vector}\\mulMatVecResult} \\
2356 % \ref{macro:mulMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix M}, \marg{matrix N}\\mulMatResult} \\
2357 % \ref{macro:getMatTranslation_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\matTranslationResult} \\
2358 % \ref{macro:detMat_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}\\detMatResult} \\
2359 % \end{tabularx}
2360 % \end{center}
2361
2362
2363 % \setlabel{\textbackslash newMat}{macro:newMat_impl}
2364 % \begin{macro}{\newMat}
2365 % Create a new matrix from the given values.
2366 %
2367 % \#1 - out: var name to save the result (matrix) to\\
2368 % \#2 - scalars: matrix values that are assigned to \#1
2369 % \begin{macrocode}
2370 \newcommand\newMat[2]{
2371 \xintFor* ##1 in #2 \do {%
2372 \newVec{matRow}{##1}
2373 \xintifForFirst{%
2374 \newMatFromRow{#1}{\matRow}
2375 }{%
2376 \appendRowToMat{#1}{\csname #1\endcsname}{\matRow}
2377 }
2378 }
2379 }
2380 % \end{macrocode}
2381 % \end{macro}
2382
2383
2384 % \setlabel{\textbackslash newMatFromRow}{macro:newMatFromRow_impl}
2385 % \begin{macro}{\newMatFromRow}
2386 % Create a new matrix from the given row.
2387 %
2388 % \#1 - out: var name to save the result (matrix) to\\
2389 % \#2 - row: matrix row that is assigned to \#1
2390 % \begin{macrocode}
2391 \newcommand\newMatFromRow[2]{
2392 \newScalar{tmpWidth}{\expandafter\xintLength\expandafter{#2}}%
2393 \FPifeq{\tmpWidth}{1}
2394 \expandafter\edef\csname #1\endcsname{{\xintCSVtoList{\matRow}}}
2395 \else
2396 \expandafter\edef\csname #1\endcsname{\xintCSVtoList{\matRow}}
2397 \fi
2398 }
2399 % \end{macrocode}
2400 % \end{macro}
2401
2402
2403 % \setlabel{\textbackslash newMatFromRowVecs}{macro:newMatFromRowVecs_impl}
2404 % \begin{macro}{\newMatFromRowVecs}
2405 % Create a new matrix from the given row vectors.
2406 %
2407 % \#1 - out: var name to save the result (matrix) to\\
2408 % \#2 - rows: the rows that are used to construct the matrix
2409 % \begin{macrocode}
2410 \newcommand\newMatFromRowVecs[2]{%
2411 % TODO remove this?
2412 \FPset\numParam{\expandafter\xintLength{#2}}%
2413 \FPsub\numParam\numParam{1}
2414 \FPdiv\numParam\numParam{2}
2415 \FPadd\numParam\numParam{1}
2416 % In case only one item/row was given the
2417 % matrix-datastructure must be adjusted
2418 \FPifeq{\numParam}{1}
2419 \expandafter\edef\csname #1\endcsname{\xintCSVtoList{#2}}%
2420 \else
2421 \expandafter\edef\csname #1\endcsname{\xintCSVtoList{#2}}%
2422 \fi
2423 }
2424 % \end{macrocode}
2425 % \end{macro}
2426
2427
2428 % \setlabel{\textbackslash newMatFromColVecs}{macro:newMatFromColVecs_impl}
2429 % \begin{macro}{\newMatFromColVecs}
2430 % Create a new matrix from the given column vectors.
2431 %
2432 % \#1 - out: var name to save the result (matrix) to\\
2433 % \#2 - columns: the columns that are used to construct the matrix
2434 % \begin{macrocode}
2435 \newcommand\newMatFromColVecs[2]{%
2436 \edef\tmpVecList{\xintCSVtoList{#2}}%
2437 \copyVec[tmpHeightVec]{{\xintNthElt{1}{\tmpVecList}}}
2438 \getVecHeight[numRows]{\tmpHeightVec}
2439 \edef\numColumns{\expandafter\xintLength\expandafter{\tmpVecList}}
2440 \edef\colSequence{\xintSeq[+1]{+1}{\numColumns}}
2441 \edef\rowSequence{\xintSeq[+1]{+1}{\numRows}}
2442 \newEmptyMat{#1}
2443 \xintFor* ##1 in \colSequence \do {%
2444 \xintFor* ##2 in \rowSequence \do {%
2445 \newScalar{tmpValue}{\xintNthElt{##1}{\xintNthElt{##2}{\tmpVecList}}}
2446 \xintifForFirst{%
2447 \newVec{matRow}{\tmpValue}
2448 }{%
2449 \appendToVec{matRow}{\matRow}{\tmpValue}
2450 }
2451 }
2452 \appendRowToMat{#1}{\csname #1\endcsname}{\matRow}
2453 }
2454 }
2455 % \end{macrocode}
2456 % \end{macro}
2457
2458
2459 % \setlabel{\textbackslash newEmptyMat}{macro:newEmptyMat_impl}
2460 % \begin{macro}{\newEmptyMat}
2461 % Create a new empty matrix.
2462 % Obacht: It is not necessary to call this to create a new matrix before using any of the arithmetic commands.
2463 %
2464 % \#1 - out: var name to save the result (matrix) to
2465 % \begin{macrocode}
2466 \newcommand\newEmptyMat[1]{
2467 \expandafter\edef\csname #1\endcsname{}%
2468 }
2469 % \end{macrocode}
2470 % \end{macro}
2471
2472
2473 % \setlabel{\textbackslash newDiagMat}{macro:newDiagMat_impl}
2474 % \begin{macro}{\newDiagMat}
2475 % Create a new diagonal matrix from the given vector.
2476 %
2477 % \#1 - out: var name to save the result (matrix) to\\
2478 % \#2 - scalars: the values that define the diagonal of the matrix
2479 % \begin{macrocode}
2480 \newcommand\newDiagMat[2]{
2481 \if\noexpand#1\relax
2482 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of newDiagMat seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
2483 \else
2484 \edef\tmpVector{\xintCSVtoList{#2}}%
2485 \newVec{rowA}{\xintNthElt{1}{\tmpVector}, 0, 0}
2486 \newVec{rowB}{0, \xintNthElt{2}{\tmpVector}, 0}
2487 \newVec{rowC}{0, 0, \xintNthElt{3}{\tmpVector}}
2488 \newMatFromRowVecs{#1}{\rowA, \rowB, \rowC}
2489 \fi
2490 }
2491 % \end{macrocode}
2492 % \end{macro}
2493
2494
2495 % \setlabel{\textbackslash appendRowToMat}{macro:appendRowToMat_impl}
2496 % \begin{macro}{\appendRowToMat}
2497 % Append the given row to the given matrix.
2498 %
2499 % \#1 - out: var name to save the result (matrix) to\\
2500 % \#2 - matrix: the matrix to append the vector to\\
2501 % \#3 - vector r: the row vector that should be appended to the matrix
2502 % \begin{macrocode}
2503 \newcommand\appendRowToMat[3]{
2504 \newScalar{tmpWidth}{\expandafter\xintLength\expandafter{#3}}%
2505 \FPifeq{\tmpWidth}{1}
2506 \expandafter\edef\csname #1\endcsname{#2 {\xintCSVtoList{#3}}}%
2507 \else
2508 \expandafter\edef\csname #1\endcsname{#2 \xintCSVtoList{#3}}%
2509 \fi
2510 }
2511 % \end{macrocode}
2512 % \end{macro}
2513
2514
2515 % \setlabel{\textbackslash newTransMat}{macro:newTransMat_impl}
2516 % \begin{macro}{\newTransMat}
2517 % Create translation matrix from the given vector.
2518 %
2519 % \#1 - out: var name to save the result (matrix) to\\
2520 % \#2 - vector t: the translation vector to construct the matrix from
2521 % \begin{macrocode}
2522 \newcommand\newTransMat[2]{%
2523 \edef\vecLength{\expandafter\xintLength\expandafter{#2 1}}
2524 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}+1}}
2525 \xintFor* ##1 in \innersequence \do {%
2526 \xintifForFirst{%
2527 \xintFor* ##2 in \innersequence \do {%
2528 \newScalar{tmp}{0}
2529 \FPifeq{##2}{\vecLength}
2530 \setScalar{tmp}{\xintNthElt{##1}{#2}}
2531 \else
2532 \fi
2533 \FPifeq{##1}{##2}
2534 \setScalar{tmp}{1}
2535 \else
2536 \fi
2537 \xintifForFirst{%
2538 \newVec{matRow}{\tmp}
2539 }{%
2540 \appendToVec{matRow}{\matRow}{\tmp}
2541 }
2542 }
2543 \newMatFromRow{#1}{\matRow}
2544 }{%
2545 \xintFor* ##2 in \innersequence \do {%
2546 \newScalar{tmp}{0}
2547 \FPifeq{##2}{\vecLength}
2548 \setScalar{tmp}{\xintNthElt{##1}{#2}}
2549 \else
2550 \fi
2551 \FPifeq{##1}{##2}
2552 \setScalar{tmp}{1}
2553 \else
2554 \fi
2555 \xintifForFirst{%
2556 \newVec{matRow}{\tmp}
2557 }{%
2558 \appendToVec{matRow}{\matRow}{\tmp}
2559 }
2560 }
2561 \appendRowToMat{#1}{\csname #1\endcsname}{\matRow}
2562 }
2563 }
2564 }
2565 % \end{macrocode}
2566 % \end{macro}
2567
2568
2569 % \setlabel{\textbackslash newScaleMat}{macro:newScaleMat_impl}
2570 % \begin{macro}{\newScaleMat}
2571 % Create scaling matrix from the given vector.
2572 %
2573 % \#1 - out: var name to save the result (matrix) to\\
2574 % \#2 - vector s: the scaling vector to construct the matrix from
2575 % \begin{macrocode}
2576 \newcommand\newScaleMat[2]{%
2577 \edef\vecLength{\expandafter\xintLength\expandafter{#2 1}}
2578 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}+1}}
2579 \xintFor* ##1 in \innersequence \do {%
2580 \xintifForFirst{%
2581 \xintFor* ##2 in \innersequence \do {%
2582 \FPiflt{##2}{\vecLength}
2583 \setScalar{tmp}{\xintNthElt{##1}{#2}}
2584 \else
2585 \setScalar{tmp}{1}
2586 \fi
2587 \FPifeq{##1}{##2}
2588 \else
2589 \setScalar{tmp}{0}
2590 \fi
2591 \xintifForFirst{%
2592 \newVec{matRow}{\tmp}
2593 }{%
2594 \appendToVec{matRow}{\matRow}{\tmp}
2595 }
2596 }
2597 \newMatFromRow{#1}{\matRow}
2598 }{%
2599 \xintFor* ##2 in \innersequence \do {%
2600 \FPiflt{##2}{\vecLength}
2601 \setScalar{tmp}{\xintNthElt{##1}{#2}}
2602 \else
2603 \setScalar{tmp}{1}
2604 \fi
2605 \FPifeq{##1}{##2}
2606 \else
2607 \setScalar{tmp}{0}
2608 \fi
2609 \xintifForFirst{%
2610 \newVec{matRow}{\tmp}
2611 }{%
2612 \appendToVec{matRow}{\matRow}{\tmp}
2613 }
2614 }
2615 \appendRowToMat{#1}{\csname #1\endcsname}{\matRow}
2616 }
2617 }
2618 }
2619 % \end{macrocode}
2620 % \end{macro}
2621
2622
2623 % \setlabel{\textbackslash newRotMatTwoD}{macro:newRotMatTwoD_impl}
2624 % \begin{macro}{\newRotMatTwoD}
2625 % Create rotation matrix from the given scalar (2D).
2626 %
2627 % \#1 - out: var name to save the result (matrix) to\\
2628 % \#2 - scalar: the rotation value
2629 % \begin{macrocode}
2630 \newcommand\newRotMatTwoD[2][rotMatResult]{%
2631 \FPcos\tmpCos{#2}
2632 \FPsin\tmpSin{#2}
2633 \newVec{rowB}{\tmpSin, \tmpCos, 0}
2634 \FPmul\tmpSin\tmpSin{-1}
2635 \newVec{rowA}{\tmpCos, \tmpSin, 0}
2636 \newVec{rowC}{0, 0, 1}
2637 \newMatFromRowVecs{#1}{\rowA, \rowB, \rowC}
2638 }
2639 % \end{macrocode}
2640 % \end{macro}
2641
2642
2643 % \setlabel{\textbackslash newRotMat}{macro:newRotMat_impl}
2644 % \begin{macro}{\newRotMat}
2645 % Create a rotation matrix using the rodrigues’ matrix
2646 %
2647 % \#1 - out: var name to save the result (matrix) to\\
2648 % \#2 - vector: the axis to rotate around\\
2649 % \#3 - scalar: the angle in degree to rotate with (counterclockwise)
2650 % \begin{macrocode}
2651 \newcommand\newRotMat[3][rotMatResult]{%
2652 \normalizeVec[normalizedAxis]{#2}
2653 \toRadian[angleInRadian]{#3}
2654 \FPcos\tmpCos{\angleInRadian}
2655 \FPsin\tmpSin{\angleInRadian}
2656 \subScalar[tmpCosMOne]{1}{\tmpCos}
2657 \mulScalar[xsquared]{\xintNthElt{1}{\normalizedAxis}}{\xintNthElt{1}{\normalizedAxis}}
2658 \mulScalar[xy]{\xintNthElt{1}{\normalizedAxis}}{\xintNthElt{2}{\normalizedAxis}}
2659 \mulScalar[xz]{\xintNthElt{1}{\normalizedAxis}}{\xintNthElt{2}{\normalizedAxis}}
2660 \mulScalar[ysquared]{\xintNthElt{2}{\normalizedAxis}}{\xintNthElt{2}{\normalizedAxis}}
2661 \mulScalar[yz]{\xintNthElt{2}{\normalizedAxis}}{\xintNthElt{3}{\normalizedAxis}}
2662 \mulScalar[zsquared]{\xintNthElt{3}{\normalizedAxis}}{\xintNthElt{3}{\normalizedAxis}}
2663 %
2664 \mulScalar[xsin]{\xintNthElt{1}{\normalizedAxis}}{\tmpSin}
2665 \mulScalar[ysin]{\xintNthElt{2}{\normalizedAxis}}{\tmpSin}
2666 \mulScalar[zsin]{\xintNthElt{3}{\normalizedAxis}}{\tmpSin}
2667 %
2668 \mulScalar[oneone]{\xsquared}{\tmpCosMOne}
2669 \addScalar[oneone]{\oneone}{\tmpCos}
2670 \mulScalar[onetwo]{\xy}{\tmpCosMOne}
2671 \subScalar[onetwo]{\onetwo}{\zsin}
2672 \mulScalar[onethree]{\xz}{\tmpCosMOne}
2673 \addScalar[onethree]{\onethree}{\ysin}
2674 %
2675 \mulScalar[twoone]{\xsquared}{\tmpCosMOne}
2676 \addScalar[twoone]{\twoone}{\zsin}
2677 \mulScalar[twotwo]{\xy}{\tmpCosMOne}
2678 \addScalar[twotwo]{\twotwo}{\tmpCos}
2679 \mulScalar[twothree]{\xz}{\tmpCosMOne}
2680 \subScalar[twothree]{\twothree}{\xsin}
2681 %
2682 \mulScalar[threeone]{\xsquared}{\tmpCosMOne}
2683 \subScalar[threeone]{\threeone}{\ysin}
2684 \mulScalar[threetwo]{\xy}{\tmpCosMOne}
2685 \addScalar[threetwo]{\threetwo}{\xsin}
2686 \mulScalar[threethree]{\xz}{\tmpCosMOne}
2687 \addScalar[threethree]{\threethree}{\tmpCos}
2688 %
2689 \newVec{rowA}{\oneone, \onetwo, \onethree}
2690 \newVec{rowB}{\twoone, \twotwo, \twothree}
2691 \newVec{rowC}{\threeone, \threetwo, \threethree}
2692 \newMatFromRowVecs{#1}{\rowA, \rowB, \rowC}
2693 }
2694 % \end{macrocode}
2695 % \end{macro}
2696
2697
2698 % \setlabel{\textbackslash newLookAtMat}{macro:newLookAtMat_impl}
2699 % \begin{macro}{\newLookAtMat}
2700 % Create a new lookAt matrix.
2701 %
2702 % \#1 - out: var name to save the result (matrix) to\\
2703 % \#2 - right: the right vector\\
2704 % \#3 - up: the up vector\\
2705 % \#4 - dir: the direction vector\\
2706 % \#5 - pos: the camera position vector
2707 % \begin{macrocode}
2708 \newcommand\newLookAtMat[5][lookAtMatResult]{%
2709 \dotVec[scalarRC]{#2}{#5}
2710 \mulScalar[scalarRC]{\scalarRC}{-1}
2711 \copyVec[tmpVecA]{#2}
2712 \appendToVec{tmpVecA}{\tmpVecA}{\scalarRC}
2713 % \printVec[1]{\tmpVecA}
2714 %
2715 \dotVec[scalarUC]{#3}{#5}
2716 \mulScalar[scalarUC]{\scalarUC}{-1}
2717 \copyVec[tmpVecB]{#3}
2718 \appendToVec{tmpVecB}{\tmpVecB}{\scalarUC}
2719 %
2720 \dotVec[scalarDC]{#4}{#5}
2721 \copyVec[tmpVecC]{#4}
2722 \negateVec[tmpVecC]{\tmpVecC}
2723 \appendToVec{tmpVecC}{\tmpVecC}{\scalarDC}
2724 %
2725 \newVec{tmpVecD}{0, 0, 0, 1}
2726 \newMatFromRowVecs{#1}{\tmpVecA, \tmpVecB, \tmpVecC, \tmpVecD}
2727 }
2728 % \end{macrocode}
2729 % \end{macro}
2730
2731
2732 % \setlabel{\textbackslash newProjMat}{macro:newProjMat_impl}
2733 % \begin{macro}{\newProjMat}
2734 % Create a new default projection matrix.
2735 %
2736 % \#1 - out: var name to save the result (matrix) to
2737 % \begin{macrocode}
2738 \newcommand\newProjMat[1]{%
2739 \newVec{tmpVecA}{1, 0, 0, 0}
2740 \newVec{tmpVecB}{0, 1, 0, 0}
2741 \newVec{tmpVecC}{0, 0, 1, 0}
2742 \newVec{tmpVecD}{0, 0, -1, 0}
2743 \newMatFromRowVecs{#1}{\tmpVecA, \tmpVecB, \tmpVecC, \tmpVecD}
2744 }
2745 % \end{macrocode}
2746 % \end{macro}
2747
2748
2749 % \setlabel{\textbackslash newProjMatGen}{macro:newProjMatGen_impl}
2750 % \begin{macro}{\newProjMatGen}
2751 % Create a new projection matrix from normal and distance from origin.
2752 %
2753 % \#1 - out: var name to save the result (matrix) to
2754 % \begin{macrocode}
2755 \newcommand\newProjMatGen[3]{%
2756 \divScalar[glmNxDelta]{\xintNthElt{1}{#2}}{#3}
2757 \divScalar[glmNyDelta]{\xintNthElt{2}{#2}}{#3}
2758 \divScalar[glmNzDelta]{\xintNthElt{3}{#2}}{#3}
2759 \newVec{tmpVecA}{1, 0, 0, 0}
2760 \newVec{tmpVecB}{0, 1, 0, 0}
2761 \newVec{tmpVecC}{0, 0, 1, 0}
2762 \newVec{tmpVecD}{\glmNxDelta, \glmNyDelta, \glmNzDelta, 0}
2763 \newMatFromRowVecs{#1}{\tmpVecA, \tmpVecB, \tmpVecC, \tmpVecD}
2764 }
2765 % \end{macrocode}
2766 % \end{macro}
2767
2768
2769 % \setlabel{\textbackslash newFrustumMat}{macro:newFrustumMat_impl}
2770 % \begin{macro}{\newFrustumMat}
2771 % Create a new frustum matrix.
2772 %
2773 % \#1 - out: var name to save the result (matrix) to\\
2774 % \#2 - fovx: the fovx scalar\\
2775 % \#3 - fovy: the fovy scalar\\
2776 % \#4 - near: the position of the near plane (scalar)\\
2777 % \#5 - far: the psition of the far lane (scalar)
2778 % \begin{macrocode}
2779 \newcommand\newFrustumMat[5][frustMatResult]{%
2780 \FPdiv\tmp{#2}{2}
2781 \FPtan\frustumRight\tmp
2782 \FPmul\frustumRight{#4}\frustumRight
2783 \FPmul\frustumLeft\frustumRight{-1}
2784 \FPdiv\tmp{#3}{2}
2785 \FPtan\frustumTop\tmp
2786 \FPmul\frustumTop{#4}\frustumTop
2787 \FPmul\frustumBottom\frustumTop{-1}
2788 %
2789 \FPmul\cellAA{2}{#4} % AA
2790 \FPsub\tmp\frustumRight\frustumLeft
2791 \FPdiv\cellAA\cellAA\tmp
2792 \FPadd\cellAC\frustumRight\frustumLeft % AC
2793 \FPdiv\cellAC\cellAC\tmp
2794 \FPmul\cellBB{2}{#4} % BB
2795 \FPsub\tmp\frustumTop\frustumBottom
2796 \FPdiv\cellBB\cellBB\tmp
2797 \FPadd\cellBC\frustumTop\frustumBottom % BC
2798 \FPdiv\cellBC\cellBC\tmp
2799 \FPmul\cellCC{#5}{-1} % CC
2800 \FPsub\cellCC\cellCC{#4}
2801 \FPsub\tmp{#5}{#4}
2802 \FPdiv\cellCC\cellCC\tmp
2803 \FPmul\cellCD{#5}{#4} % CD
2804 \FPmul\cellCD{-2}\cellCD
2805 \FPdiv\cellCD\cellCD\tmp
2806 %
2807 \newVec{rowA}{\cellAA, 0, \cellAC, 0}
2808 \newVec{rowB}{0, \cellBB, \cellBC, 0}
2809 \newVec{rowC}{0, 0, \cellCC, \cellCD}
2810 \newVec{rowD}{0, 0, -1, 0}
2811 \newMatFromRowVecs{#1}{\rowA, \rowB, \rowC, \rowD}
2812 }
2813 % \end{macrocode}
2814 % \end{macro}
2815
2816
2817 % \setlabel{\textbackslash printMat}{macro:printMat_impl}
2818 % \begin{macro}{\printMat}
2819 % Print the values of this matrix variable.
2820 %
2821 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
2822 % \#2 - matrix: the matrix that should be printed
2823 % \begin{macrocode}
2824 \newcommand\printMat[2][0]{%
2825 \ensuremath{%
2826 \begin{bmatrix}
2827 \xintFor* ##1 in #2 \do {%
2828 \xintFor* ##2 in {##1} \do {%
2829 \xintifForLast{%
2830 \xintifForFirst{}{&}
2831 \FPifeq{#1}{0}
2832 \roundScalar{##2}
2833 \scalarRoundResult
2834 \else
2835 \numToFractionA{##2}
2836 \fi
2837 \\
2838 }{%
2839 \xintifForFirst{}{&}
2840 \FPifeq{#1}{0}
2841 \roundScalar{##2}
2842 \scalarRoundResult
2843 \else
2844 \numToFractionA{##2}
2845 \fi
2846 }
2847 }
2848 }
2849 \end{bmatrix}
2850 }
2851 }
2852 % \end{macrocode}
2853 % \end{macro}
2854
2855
2856 % \setlabel{\textbackslash printMatDiag}{macro:printMatDiag_impl}
2857 % \begin{macro}{\printMatDiag}
2858 % Print only the diagonal values of this matrix variable.
2859 %
2860 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
2861 % \#2 - matrix: the matrix that should be printed
2862 % \begin{macrocode}
2863 \newcommand\printMatDiag[2][0]{%
2864 \ensuremath{%
2865 \text{diag}\left(
2866 \xintNthElt{1}{\xintNthElt{1}{#2}},
2867 \xintNthElt{2}{\xintNthElt{2}{#2}},
2868 \xintNthElt{3}{\xintNthElt{3}{#2}}
2869 \right)
2870 }
2871 }
2872 % \end{macrocode}
2873 % \end{macro}
2874
2875
2876 % \setlabel{\textbackslash getMatHeight}{macro:getMatHeight_impl}
2877 % \begin{macro}{\getMatHeight}
2878 % Get the height of the given matrix.
2879 %
2880 % \#1 - out: var name to save the result (scalar) to\\
2881 % \#2 - matrix: the matrix from which to get the height
2882 % \begin{macrocode}
2883 \newcommand\getMatHeight[2][matHeightResult]{%
2884 \newScalar{#1}{\expandafter\xintLength\expandafter{#2}}%
2885 }
2886 % \end{macrocode}
2887 % \end{macro}
2888
2889
2890 % \setlabel{\textbackslash getMatWidth}{macro:getMatWidth_impl}
2891 % \begin{macro}{\getMatWidth}
2892 % Get the width of the given matrix.
2893 %
2894 % \#1 - out: var name to save the result (scalar) to\\
2895 % \#2 - matrix: the matrix from which to get the width
2896 % \begin{macrocode}
2897 \newcommand\getMatWidth[2][matWidthResult]{%
2898 \edef\rowElements{\xintNthElt{1}{#2}}%
2899 \newScalar{#1}{\expandafter\xintLength\expandafter{\rowElements}}%
2900 }
2901 % \end{macrocode}
2902 % \end{macro}
2903
2904
2905 % \setlabel{\textbackslash transposeMat}{macro:transposeMat_impl}
2906 % \begin{macro}{\transposeMat}
2907 % Transpose a given Matrix. The parameter can also be a vector,
2908 % but the result will be a matrix.
2909 %
2910 % \#1 - out: var name to save the result (matrix) to\\
2911 % \#2 - matrix: the matrix to transpose
2912 % \begin{macrocode}
2913 \newcommand\transposeMat[2][transposeMatResult]{%
2914 \getMatWidth{#2}
2915 \getMatHeight{#2}
2916 \edef\widthSequence{\xintSeq[+1]{+1}{\matWidthResult}}
2917 \edef\heightSequence{\xintSeq[+1]{+1}{\matHeightResult}}
2918 \newEmptyMat{#1}
2919 \xintFor* ##1 in \widthSequence \do {%
2920 \xintFor* ##2 in \heightSequence \do {%
2921 \FPset\tmpValue{\xintNthElt{##1}{\xintNthElt{##2}{#2}}}
2922 \xintifForFirst{%
2923 \newVec{rowVec}{\tmpValue}
2924 }{%
2925 \appendToVec{rowVec}{\rowVec}{\tmpValue}
2926 }
2927 }
2928 \appendRowToMat{#1}{\csname #1\endcsname}{\rowVec}
2929 }
2930 }
2931 % \end{macrocode}
2932 % \end{macro}
2933
2934
2935 % \setlabel{\textbackslash addMat}{macro:addMat_impl}
2936 % \begin{macro}{\addMat}
2937 % Add two or more matrices.
2938 %
2939 % \#1 - out: var name to save the result (matrix) to\\
2940 % \#2 - matrix: the matrix to add to\\
2941 % \#3 - matrices: the matrizes to add
2942 % \begin{macrocode}
2943 \newcommand\addMat[3][addMatResult]{%
2944 \if\noexpand#1\relax
2945 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of addMat seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
2946 \else
2947 \fi
2948 \if\noexpand#2\relax
2949 \else
2950 \PackageError{glmatrix package}{argument mismatch}{argument 2 of addMat does not seem to be a command}
2951 \fi
2952 % TODO this does not work if it is a list
2953 % \if\noexpand#3\relax
2954 % \else
2955 % \PackageError{glmatrix package}{argument mismatch}{argument 3 of addMat does not seem to be a command}
2956 % \fi
2957 \def\matlist{\xintCSVtoList{#3}}
2958 \edef\elemsRow{\xintNthElt{1}{\xintNthElt{1}{\matlist}}}
2959 \edef\widthsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsRow}}}%
2960 \edef\elemsMat{\xintNthElt{1}{\matlist}}
2961 \edef\heightsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsMat}}}%
2962 %
2963 \newEmptyMat{#1}
2964 \xintFor* ##2 in \heightsequence \do {%
2965 \xintFor* ##3 in \widthsequence \do {%
2966 \FPset\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{#2}}}
2967 \xintifForFirst{%
2968 \xintFor* ##1 in \matlist \do {%
2969 \FPadd\tmpValue\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{##1}}}
2970 }
2971 \newVec{rowVec}{\tmpValue}
2972 }{%
2973 % \xintifForLast{
2974 % }{
2975 \xintFor* ##1 in \matlist \do {%
2976 \FPadd\tmpValue\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{##1}}}
2977 }
2978 \appendToVec{rowVec}{\rowVec}{\tmpValue}
2979 % }
2980 }
2981 }
2982 \appendRowToMat{#1}{\csname #1\endcsname}{\rowVec}
2983 }
2984 }
2985 % \end{macrocode}
2986 % \end{macro}
2987
2988
2989 % \setlabel{\textbackslash subMat}{macro:subMat_impl}
2990 % \begin{macro}{\subMat}
2991 % Subtract two or more matrices.
2992 %
2993 % \#1 - out: var name to save the result (matrix) to\\
2994 % \#2 - matrix: the matrix to subtract from\\
2995 % \#3 - matrices: the matrizes to subtract
2996 % \begin{macrocode}
2997 \newcommand\subMat[3][subMatResult]{%
2998 % \getMatWidth{#2}
2999 % \edef\widthsequence{\xintSeq[+1]{+1}{\matWidthResult}}%
3000 \getMatHeight{#2}
3001 \edef\heightsequence{\xintSeq[+1]{+1}{\matHeightResult}}%
3002 %
3003 \def\matlist{\xintCSVtoList{#3}}
3004 \edef\elemsRow{\xintNthElt{1}{\xintNthElt{1}{\matlist}}}
3005 \edef\widthsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsRow}}}%
3006 % \edef\elemsMat{\xintNthElt{1}{\matlist}}
3007 % \edef\heightsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsMat}}}%
3008 %
3009 \newEmptyMat{#1}
3010 \xintFor* ##2 in \heightsequence \do {%
3011 \xintFor* ##3 in \widthsequence \do {%
3012 \FPset\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{#2}}}
3013 \xintifForFirst{%
3014 \xintFor* ##1 in \matlist \do {%
3015 \FPsub\tmpValue\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{##1}}}
3016 }
3017 \newVec{rowVec}{\tmpValue}
3018 }{%
3019 \xintFor* ##1 in \matlist \do {%
3020 \FPsub\tmpValue\tmpValue{\xintNthElt{##3}{\xintNthElt{##2}{##1}}}
3021 }
3022 \appendToVec{rowVec}{\rowVec}{\tmpValue}
3023 }
3024 }
3025 \appendRowToMat{#1}{\csname #1\endcsname}{\rowVec}
3026 }
3027 }
3028 % \end{macrocode}
3029 % \end{macro}
3030
3031
3032 % \setlabel{\textbackslash mulMatScalar}{macro:mulMatScalar_impl}
3033 % \begin{macro}{\mulMatScalar}
3034 % Multiply the given matrix with a scalar.
3035 %
3036 % \#1 - out: var name to save the result (matrix) to\\
3037 % \#2 - matrix: the matrix to multiply\\
3038 % \#3 - scalar: the scalar to multiply with
3039 % \begin{macrocode}
3040 \newcommand\mulMatScalar[3][mulMatScalarResult]{%
3041 \if\noexpand#1\relax
3042 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of mulMatScalar seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
3043 \else
3044 \fi
3045 \if\noexpand#2\relax
3046 \else
3047 \PackageError{glmatrix package}{argument mismatch}{argument 2 of mulMatScalar does not seem to be a command}
3048 \fi
3049 \edef\elemOne{\xintNthElt{1}{#2}}
3050 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemOne}}}%
3051 %
3052 \newEmptyMat{#1}
3053 \xintFor* ##1 in #2 \do {%
3054 \xintFor* ##2 in \innersequence \do {%
3055 \FPset\elem{\xintNthElt{##2}{##1}}
3056 \FPmul\elem\elem{#3}
3057 \xintifForFirst{%
3058 \newVec{rowVec}{\elem}
3059 }{%
3060 \appendToVec{rowVec}{\rowVec}{\elem}
3061 }
3062 }
3063 \appendRowToMat{#1}{\csname #1\endcsname}{\rowVec}
3064 }
3065 }
3066 % \end{macrocode}
3067 % \end{macro}
3068
3069
3070 % \setlabel{\textbackslash mulMatVec}{macro:mulMatVec_impl}
3071 % \begin{macro}{\mulMatVec}
3072 % Multiply the given matrix with a vector (for transformation).
3073 %
3074 % \#1 - out: var name to save the result (vector) to\\
3075 % \#2 - matrix: the matrix to transform the vetor with\\
3076 % \#3 - vector: the vector to transform
3077 % \begin{macrocode}
3078 \newcommand\mulMatVec[3][mulMatVecResult]{%
3079 \if\noexpand#1\relax
3080 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of transformVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
3081 \else
3082 \fi
3083 \if\noexpand#2\relax
3084 \else
3085 \PackageError{glmatrix package}{argument mismatch}{argument 2 of transformVec does not seem to be a command}
3086 \fi
3087 \if\noexpand#3\relax
3088 \else
3089 \PackageError{glmatrix package}{argument mismatch}{argument 3 of transformVec does not seem to be a command}
3090 \fi
3091 \getVecHeight{#3}%
3092 \getMatHeight{#2}%
3093 \getMatWidth{#2}%
3094 % Check that matrix and vector can be multiplied
3095 \FPifeq{\matWidthResult}{\vecHeightResult}
3096 \else
3097 \PackageError{glmatrix package}{Dimension mismatch for matrix and vector, could not multiply}{width (\matWidthResult) of matrix #2 and height (\vecHeightResult) of vector #3 do not match}
3098 \fi
3099 % Create iterator sequences from height of vector and matrix
3100 \edef\vecHeightSequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
3101 \edef\matHeightSequence{\xintSeq[+1]{+1}{\matHeightResult}}%
3102 % Iterate all rows of the matrix
3103 \xintFor* ##2 in \matHeightSequence \do {%
3104 \FPset\cellVal{0}
3105 % Differentiate between first and other entries to create the new vector variable
3106 \xintifForFirst{%
3107 % Now iterate each entry of the current row
3108 % Use this indec to access the entry in the matrix and in the vector
3109 \xintFor* ##3 in \vecHeightSequence \do {%
3110 \FPmul\tmp{%
3111 \xintNthElt{##3}{\xintNthElt{##2}{#2}}%
3112 }{%
3113 \xintNthElt{##3}{#3}%
3114 }
3115 % Add to storage variable
3116 \FPadd\cellVal\cellVal\tmp
3117 }
3118 \FPclip\cellVal\cellVal
3119 \newVec{#1}{\cellVal}
3120 }{
3121 \xintFor* ##3 in \vecHeightSequence \do {%
3122 \FPmul\tmp{%
3123 \xintNthElt{##3}{\xintNthElt{##2}{#2}}%
3124 }{%
3125 \xintNthElt{##3}{#3}%
3126 }
3127 \FPadd\cellVal\cellVal\tmp
3128 }
3129 \FPclip\cellVal\cellVal
3130 \appendToVec{#1}{\csname #1\endcsname}{\cellVal}
3131 }
3132 }
3133 % Test if width and height is correct
3134 \expandafter\getVecHeight\expandafter{\csname #1\endcsname}%
3135 \FPifeq{\matHeightResult}{\vecHeightResult}
3136 \else
3137 \PackageError{glmatrix package}{Vector height does not match expectation}{height of vector is \vecHeightResult but should be \matHeightResult}
3138 \fi
3139 }
3140 % \end{macrocode}
3141 % \end{macro}
3142
3143
3144 % \setlabel{\textbackslash mulMat}{macro:mulMat_impl}
3145 % \begin{macro}{\mulMat}
3146 % Multiply the given matrix with another matrix.
3147 %
3148 % \#1 - out: var name to save the result (matrix) to\\
3149 % \#2 - matrix M: the matrix to multiply\\
3150 % \#3 - matrix N: the matrix to multiply with
3151 % \begin{macrocode}
3152 \newcommand\mulMat[3][mulMatResult]{%
3153 \edef\elemsRow{\xintNthElt{1}{#3}}
3154 \edef\widthsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsRow}}}%
3155 %
3156 % TODO remove one of these
3157 \edef\elemsMat{#2}
3158 \edef\heightsequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsMat}}}%
3159 %
3160 \edef\elemsMat{#3}
3161 \edef\heightsequenceB{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{\elemsMat}}}%
3162 %
3163 \edef\elemsRowTmp{\xintNthElt{1}{#2}}
3164 \FPset\widthMatA{\expandafter\xintLength\expandafter{\elemsRowTmp}}%
3165 \FPset\heightMatB{\expandafter\xintLength\expandafter{\elemsMat}}%
3166 % TODO check this
3167 \FPifeq{\widthMatA}{\heightMatB}
3168 \else
3169 \PackageError{glmatrix package}{Dimension mismatch for matrix, could not multiply}{width (\widthMatA) of matrix #2 and height (\heightMatB) of matrix #3 do not match}
3170 \fi
3171 %
3172 \newEmptyMat{#1}
3173 \xintFor* ##2 in \heightsequence \do {%
3174 \xintFor* ##3 in \widthsequence \do {%
3175 \FPset\tmpValue{0}
3176 \xintifForFirst{%
3177 \xintFor* ##4 in \heightsequenceB \do {%
3178 \FPmul\tmptmp{%
3179 \xintNthElt{##4}{\xintNthElt{##2}{#2}}%
3180 }{%
3181 \xintNthElt{##3}{\xintNthElt{##4}{#3}}%
3182 }
3183 \FPadd\tmpValue\tmpValue\tmptmp
3184 }
3185 \newVec{rowVec}{\tmpValue}
3186 }{%
3187 \xintFor* ##4 in \heightsequenceB \do {%
3188 \FPmul\tmptmp{%
3189 \xintNthElt{##4}{\xintNthElt{##2}{#2}}%
3190 }{%
3191 \xintNthElt{##3}{\xintNthElt{##4}{#3}}%
3192 }
3193 \FPadd\tmpValue\tmpValue\tmptmp
3194 }
3195 \appendToVec{rowVec}{\rowVec}{\tmpValue}
3196 }
3197 }
3198 \appendRowToMat{#1}{\csname #1\endcsname}{\rowVec}
3199 }
3200 % Test if width and height is correct
3201 \edef\expectedheight{\expandafter\xintLength\expandafter{#2}}%
3202 \edef\elemsRow{\xintNthElt{1}{#3}}
3203 \edef\expectedwidth{\expandafter\xintLength\expandafter{\elemsRow}}%
3204 %
3205 \edef\elemsRow{\xintNthElt{1}{\csname #1\endcsname}}
3206 \edef\actualwidth{\expandafter\xintLength\expandafter{\elemsRow}}%
3207 \edef\elemsMat{\csname #1\endcsname}
3208 \edef\actualheight{\expandafter\xintLength\expandafter{\elemsMat}}%
3209 %
3210 \FPifeq{\expectedwidth}{\actualwidth}
3211 \else
3212 \PackageError{glmatrix package}{Matrix width does not match expectation}{width seems to be incorrect}
3213 \fi
3214 \FPifeq{\expectedheight}{\actualheight}
3215 \else
3216 \PackageError{glmatrix package}{Matrix height does not match expectation}{height seems to be incorrect}
3217 \fi
3218 }
3219 % \end{macrocode}
3220 % \end{macro}
3221
3222
3223 % \setlabel{\textbackslash getMatTranslation}{macro:getMatTranslation_impl}
3224 % \begin{macro}{\getMatTranslation}
3225 % Get the translation component from the given matrix.
3226 %
3227 % \#1 - out: var name to save the result (vector) to\\
3228 % \#2 - matrix: the matrix to extract the translation from
3229 % \begin{macrocode}
3230 \newcommand\getMatTranslation[2][matTranslationResult]{%
3231 \getMatWidth{#2}
3232 \getMatHeight{#2}
3233 \edef\sequence{\xintSeq[+1]{+1}{\matHeightResult}}
3234 \xintFor* ##1 in \sequence \do {%
3235 \FPset\tmpValue{\xintNthElt{\matWidthResult}{\xintNthElt{##1}{#2}}}
3236 \xintifForFirst{%
3237 \newVec{#1}{\tmpValue}
3238 }{%
3239 \xintifForLast{}{
3240 \appendToVec{#1}{\csname #1\endcsname}{\tmpValue}
3241 }
3242 }
3243 }
3244 }
3245 % \end{macrocode}
3246 % \end{macro}
3247
3248
3249 % \setlabel{\textbackslash detMat}{macro:detMat_impl}
3250 % \begin{macro}{\detMat}
3251 % Get the determinate of the given matrix.
3252 %
3253 % \#1 - out: var name to save the result (scalar) to\\
3254 % \#2 - matrix: the matrix to calculate the determinate for
3255 % \begin{macrocode}
3256 \newcommand\detMat[2][detMatResult]{%
3257 \getMatWidth{#2}
3258 \getMatHeight{#2}
3259 \FPifgt{\matWidthResult}{2}
3260 \PackageError{glmatrix package}{Function not yet implemented}{Determinante can only be calculated for \(2 \times 2\) matrices}
3261 \else
3262 \fi
3263 \FPifgt{\matHeightResult}{2}
3264 \PackageError{glmatrix package}{Function not yet implemented}{Determinante can only be calculated for \(2 \times 2\) matrices}
3265 \else
3266 \fi
3267 %
3268 \mulScalar[tmpAD]{\xintNthElt{1}{\xintNthElt{1}{#2}}}{\xintNthElt{2}{\xintNthElt{2}{#2}}}
3269 \mulScalar[tmpBC]{\xintNthElt{1}{\xintNthElt{2}{#2}}}{\xintNthElt{2}{\xintNthElt{1}{#2}}}
3270 \subScalar[#1]{\tmpAD}{\tmpBC}
3271 }
3272 % \end{macrocode}
3273 % \end{macro}
3274
3275 % \subsection{scalar}
3276 % \begin{center}
3277 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
3278 % \textbf{Command} & \textbf{Arguments} \\ \hline
3279 % \ref{macro:newScalar_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
3280 % \ref{macro:newScalarPi_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
3281 % \ref{macro:newScalarFraction_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar n}, \marg{scalar d}} \\
3282 % \ref{macro:randomScalar_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{lower bound}, \marg{upper bound}} \\
3283 % \ref{macro:copyScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\scalarCopyResult} \\
3284 % \ref{macro:setScalar_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{scalar}} \\
3285 % \ref{macro:zeroScalar_impl} & \makecell[t{p{8cm}}]{\marg{out}} \\
3286 % \ref{macro:printScalar_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\0} \\
3287 % \ref{macro:printScalarAsPi_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\0} \\
3288 % \ref{macro:printPiScalarInDegree_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{scalar}\\0} \\
3289 % \ref{macro:printScalarRounded_impl} & \makecell[t{p{8cm}}]{\oarg{digits}, \marg{scalar}\\4} \\
3290 % \ref{macro:roundScalar_impl} & \makecell[t{p{8cm}}]{\oarg{digits}, \marg{scalar}\\4} \\
3291 % \ref{macro:ceilScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\scalarCeilResult} \\
3292 % \ref{macro:floorScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\scalarFloorResult} \\
3293 % \ref{macro:clipScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\clipScalarResult} \\
3294 % \ref{macro:radianToDegree_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\radianToDegreeResult} \\
3295 % \ref{macro:toRadian_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\degreeToRadianResult} \\
3296 % \ref{macro:addScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\scalarAddResult} \\
3297 % \ref{macro:subScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\scalarSubResult} \\
3298 % \ref{macro:mulScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\scalarMulResult} \\
3299 % \ref{macro:divScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\scalarDivResult} \\
3300 % \ref{macro:powScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\scalarPowResult} \\
3301 % \ref{macro:negateScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\scalarNegateResult} \\
3302 % \ref{macro:arccosScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}\\scalarArccosResult} \\
3303 % \ref{macro:mulAndAddScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}, \marg{scalar u}\\scalarMulAndAddResult} \\
3304 % \ref{macro:lerpScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar i}, \marg{scalar j}, \marg{scalar t}\\lerpScalarResult} \\
3305 % \ref{macro:minScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\minScalarResult} \\
3306 % \ref{macro:maxScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar s}, \marg{scalar t}\\maxScalarResult} \\
3307 % \ref{macro:betweenScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{scalar}, \marg{lower bound}, \marg{upper bound}\\betweenScalarResult} \\
3308 % \ref{macro:forEachScalar_impl} & \makecell[t{p{8cm}}]{\marg{input}, \marg{macro}, \marg{args}} \\
3309 % \end{tabularx}
3310 % \end{center}
3311
3312
3313 % \setlabel{\textbackslash newScalar}{macro:newScalar_impl}
3314 % \begin{macro}{\newScalar}
3315 % Create a new scalar and assign the given value.
3316 %
3317 % \#1 - out: var name to save the result (scalar) to\\
3318 % \#2 - scalar: scalar value that is assigned to out
3319 % \begin{macrocode}
3320 \newcommand\newScalar[2]{%
3321 \expandafter\edef\csname #1\endcsname{#2}%
3322 }
3323 % \end{macrocode}
3324 % \end{macro}
3325
3326
3327 % \setlabel{\textbackslash newScalarPi}{macro:newScalarPi_impl}
3328 % \begin{macro}{\newScalarPi}
3329 % Create a new scalar and assign the given value as a multiple of pi.
3330 %
3331 % \#1 - out: var name to save the result (scalar) to\\
3332 % \#2 - scalar: scalar value that is multiplied with pi and assigned to out
3333 % \begin{macrocode}
3334 \newcommand\newScalarPi[2]{
3335 \FPmul\divNumRes{\FPpi}{#2}
3336 \expandafter\edef\csname #1\endcsname{\divNumRes}%
3337 }
3338 % \end{macrocode}
3339 % \end{macro}
3340
3341
3342 % \setlabel{\textbackslash newScalarFraction}{macro:newScalarFraction_impl}
3343 % \begin{macro}{\newScalarFraction}
3344 % Create a scalar from a given fraction
3345 %
3346 % \#1 - out: var name to save the result (scalar) to\\
3347 % \#2 - scalar n: nominator\\
3348 % \#3 - scalar d: denominator
3349 % \begin{macrocode}
3350 \newcommand\newScalarFraction[3]{
3351 \FPdiv\divNumRes{#2}{#3}
3352 \expandafter\edef\csname #1\endcsname{\divNumRes}%
3353 }
3354 % \end{macrocode}
3355 % \end{macro}
3356
3357
3358 % \setlabel{\textbackslash randomScalar}{macro:randomScalar_impl}
3359 % \begin{macro}{\randomScalar}
3360 % Create a new scalar variable with a random value between lower and
3361 % upper bound. The value is obtained by creating a random value between 0 and 1
3362 % and then interpolating between lower and upper bound.
3363 %
3364 % \#1 - out: var name to save the result (scalar) to\\
3365 % \#2 - lower bound: scalar that limits the possible values at the bottom\\
3366 % \#3 - upper bound: scalar that limits the possible values at the top
3367 % \begin{macrocode}
3368 \newcommand\randomScalar[3]{%
3369 \FPrandom\tmp
3370 \lerpScalar[#1]{#2}{#3}{\tmp}
3371 }
3372 % \end{macrocode}
3373 % \end{macro}
3374
3375
3376 % \setlabel{\textbackslash copyScalar}{macro:copyScalar_impl}
3377 % \begin{macro}{\copyScalar}
3378 % Copy the value of one scalar variable to another.
3379 %
3380 % \#1 - out: var name to save the result (scalar) to\\
3381 % \#2 - scalar: scalar which value is assigned to out
3382 % \begin{macrocode}
3383 \newcommand\copyScalar[2][scalarCopyResult]{%
3384 \setScalar{#1}{#2}
3385 }
3386 % \end{macrocode}
3387 % \end{macro}
3388
3389
3390 % \setlabel{\textbackslash setScalar}{macro:setScalar_impl}
3391 % \begin{macro}{\setScalar}
3392 % Set the value of a given scalar.
3393 %
3394 % \#1 - out: var name to save the result (scalar) to\\
3395 % \#2 - scalar: scalar value that is assigned to out
3396 % \begin{macrocode}
3397 \newcommand\setScalar[2]{%
3398 \newScalar{#1}{#2}
3399 }
3400 % \end{macrocode}
3401 % \end{macro}
3402
3403
3404 % \setlabel{\textbackslash zeroScalar}{macro:zeroScalar_impl}
3405 % \begin{macro}{\zeroScalar}
3406 % Set or create a scalar with value 0.
3407 %
3408 % \#1 - out: var name to save the result (scalar) to
3409 % \begin{macrocode}
3410 \newcommand\zeroScalar[1]{%
3411 \expandafter\edef\csname #1\endcsname{0}%
3412 }
3413 % \end{macrocode}
3414 % \end{macro}
3415
3416
3417 % \setlabel{\textbackslash printScalar}{macro:printScalar_impl}
3418 % \begin{macro}{\printScalar}
3419 % Print the value of the given scalar.
3420 %
3421 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
3422 % \#2 - scalar: the scalar that should be printed
3423 % \begin{macrocode}
3424 \newcommand\printScalar[2][0]{%
3425 \FPifeq{#1}{0}%
3426 \roundScalar{#2}%
3427 \scalarRoundResult%
3428 \else%
3429 \numToFractionA{#2}%
3430 \fi%
3431 }
3432 % \end{macrocode}
3433 % \end{macro}
3434
3435
3436 % \setlabel{\textbackslash printScalarAsPi}{macro:printScalarAsPi_impl}
3437 % \begin{macro}{\printScalarAsPi}
3438 % Print the value of the given scalar as a multiple of Pi.
3439 %
3440 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
3441 % \#2 - scalar: the scalar that should be printed
3442 % \begin{macrocode}
3443 \newcommand\printScalarAsPi[2][0]{%
3444 \FPdiv\divNumRes{#2}{\FPpi}
3445 \FPifeq{#1}{0}
3446 \roundScalar{\divNumRes}
3447 \scalarRoundResult
3448 \else
3449 \numToFractionA{\divNumRes}
3450 \fi
3451 \pi
3452 }
3453 % \end{macrocode}
3454 % \end{macro}
3455
3456
3457 % \setlabel{\textbackslash printPiScalarInDegree}{macro:printPiScalarInDegree_impl}
3458 % \begin{macro}{\printPiScalarInDegree}
3459 % Print the value of the given scalar in degree.
3460 % This macro does do a conversion and therefore expects the input to be in radian.
3461 % A degree sign is automatically added.
3462 %
3463 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
3464 % \#2 - scalar: the value that schould be printed
3465 % \begin{macrocode}
3466 \newcommand\printPiScalarInDegree[2][0]{%
3467 \FPmul\tmp{#2}{180}
3468 \FPdiv\divNumRes{\tmp}{\FPpi}
3469 \FPifeq{#1}{0}
3470 \roundScalar{\divNumRes}
3471 \scalarRoundResult
3472 \else
3473 \numToFractionA{\divNumRes}
3474 \fi
3475 ^\circ
3476 }
3477 % \end{macrocode}
3478 % \end{macro}
3479
3480
3481 % \setlabel{\textbackslash printScalarRounded}{macro:printScalarRounded_impl}
3482 % \begin{macro}{\printScalarRounded}
3483 % Print the rounded value of the given scalar.
3484 %
3485 % \#1 - digits: number of digits after comma\\
3486 % \#2 - scalar: the value that schould be printed
3487 % \begin{macrocode}
3488 \newcommand\printScalarRounded[2][4]{%
3489 \FPround\tmp{#2}{#1}
3490 \FPclip\tmp\tmp
3491 \tmp
3492 }
3493 % \end{macrocode}
3494 % \end{macro}
3495
3496
3497 % \setlabel{\textbackslash roundScalar}{macro:roundScalar_impl}
3498 % \begin{macro}{\roundScalar}
3499 % Round the value ot the given scalar and save it.
3500 %
3501 % \#1 - digits: number of digits after comma\\
3502 % \#2 - scalar: the value that schould be rounded
3503 % \begin{macrocode}
3504 \newcommand\roundScalar[2][4]{%
3505 \FPround\tmp{#2}{#1}%
3506 \FPclip\tmp\tmp%
3507 \newScalar{scalarRoundResult}{\tmp}%
3508 }
3509 % \end{macrocode}
3510 % \end{macro}
3511
3512
3513 % \setlabel{\textbackslash ceilScalar}{macro:ceilScalar_impl}
3514 % \begin{macro}{\ceilScalar}
3515 % Ceil the value of the given scalar.
3516 %
3517 % \#1 - out: var name to save the result (scalar) to\\
3518 % \#2 - scalar: the scalar that schould be ceiled
3519 % \begin{macrocode}
3520 \newcommand\ceilScalar[2][scalarCeilResult]{
3521 \FPtrunc\tmp{#2}{0}
3522 \FPset\tmpSave{\tmp}
3523 %
3524 \FPifpos{#2}
3525 \FPadd\tmpSave{\tmp}{1}
3526 \else
3527 \fi
3528 \FPifint{#2}
3529 \FPset\tmpSave{\tmp}
3530 \else
3531 \fi
3532 \newScalar{#1}{\tmpSave}
3533 }
3534 % \end{macrocode}
3535 % \end{macro}
3536
3537
3538 % \setlabel{\textbackslash floorScalar}{macro:floorScalar_impl}
3539 % \begin{macro}{\floorScalar}
3540 % Floor the value of the given scalar.
3541 %
3542 % \#1 - out: var name to save the result (scalar) to\\
3543 % \#2 - scalar: the scalar that schould be floored
3544 % \begin{macrocode}
3545 \newcommand\floorScalar[2][scalarFloorResult]{
3546 \FPtrunc\tmp{#2}{0}
3547 \FPset\tmpSave{\tmp}
3548 %
3549 \FPifneg{#2}
3550 \FPsub\tmpSave{\tmp}{1}
3551 \else
3552 \fi
3553 \FPifint{#2}
3554 \FPset\tmpSave{\tmp}
3555 \else
3556 \fi
3557 \newScalar{#1}{\tmpSave}
3558 }
3559 % \end{macrocode}
3560 % \end{macro}
3561
3562
3563 % \setlabel{\textbackslash clipScalar}{macro:clipScalar_impl}
3564 % \begin{macro}{\clipScalar}
3565 % Remove all trailing zeros from the value of the given scalar.
3566 %
3567 % \#1 - out: var name to save the result (scalar) to\\
3568 % \#2 - scalar: the scalar from which the zeros should be removed
3569 % \begin{macrocode}
3570 \newcommand\clipScalar[2][clipScalarResult]{
3571 \FPclip\tmp{#2}
3572 \newScalar{#1}{\tmp}
3573 }
3574 % \end{macrocode}
3575 % \end{macro}
3576
3577
3578 % \setlabel{\textbackslash radianToDegree}{macro:radianToDegree_impl}
3579 % \begin{macro}{\radianToDegree}
3580 % Convert the value of the given scalar to degree.
3581 %
3582 % \#1 - out: var name to save the result (scalar) to\\
3583 % \#2 - scalar: the scalar which to convert
3584 % \begin{macrocode}
3585 \newcommand\radianToDegree[2][radianToDegreeResult]{
3586 \FPmul\tmp{#2}{180}
3587 \FPdiv\tmp{\tmp}{\FPpi}
3588 \newScalar{#1}{\tmp}
3589 }
3590 % \end{macrocode}
3591 % \end{macro}
3592
3593
3594 % \setlabel{\textbackslash toRadian}{macro:toRadian_impl}
3595 % \begin{macro}{\toRadian}
3596 % Convert the value of the given scalar to radian.
3597 %
3598 % \#1 - out: var name to save the result (scalar) to\\
3599 % \#2 - scalar: the scalar which to convert
3600 % \begin{macrocode}
3601 \newcommand\toRadian[2][degreeToRadianResult]{
3602 \FPdiv\tmp{#2}{180}
3603 \FPmul\tmp{\tmp}{\FPpi}
3604 \newScalar{#1}{\tmp}
3605 }
3606 % \end{macrocode}
3607 % \end{macro}
3608
3609
3610 % \setlabel{\textbackslash addScalar}{macro:addScalar_impl}
3611 % \begin{macro}{\addScalar}
3612 % Add the values of two scalars.
3613 %
3614 % \#1 - out: var name to save the result (scalar) to\\
3615 % \#2 - scalar s: the first scalar of the sum\\
3616 % \#3 - scalar t: the second scalar of the sum
3617 % \begin{macrocode}
3618 \newcommand\addScalar[3][scalarAddResult]{%
3619 \FPadd\tmp{#2}{#3}
3620 \newScalar{#1}{\tmp}
3621 }
3622 % \end{macrocode}
3623 % \end{macro}
3624
3625
3626 % \setlabel{\textbackslash subScalar}{macro:subScalar_impl}
3627 % \begin{macro}{\subScalar}
3628 % Subtract the values of two scalars.
3629 %
3630 % \#1 - out: var name to save the result (scalar) to\\
3631 % \#2 - scalar s: the scalar to subtract from\\
3632 % \#3 - scalar t: the scalar to subtract
3633 % \begin{macrocode}
3634 \newcommand\subScalar[3][scalarSubResult]{%
3635 \FPsub\tmp{#2}{#3}
3636 \newScalar{#1}{\tmp}
3637 }
3638 % \end{macrocode}
3639 % \end{macro}
3640
3641
3642 % \setlabel{\textbackslash mulScalar}{macro:mulScalar_impl}
3643 % \begin{macro}{\mulScalar}
3644 % Multiply the values of two scalars.
3645 %
3646 % \#1 - out: var name to save the result (scalar) to\\
3647 % \#2 - scalar s: the scalar to multiply\\
3648 % \#3 - scalar t: the scalar with which to multply
3649 % \begin{macrocode}
3650 \newcommand\mulScalar[3][scalarMulResult]{
3651 \FPmul\tmp{#2}{#3}
3652 \newScalar{#1}{\tmp}
3653 }
3654 % \end{macrocode}
3655 % \end{macro}
3656
3657
3658 % \setlabel{\textbackslash divScalar}{macro:divScalar_impl}
3659 % \begin{macro}{\divScalar}
3660 % Divide the values of two scalars.
3661 %
3662 % \#1 - out: var name to save the result (scalar) to\\
3663 % \#2 - scalar s: the scalar to divide\\
3664 % \#3 - scalar t: the scalar to divide with
3665 % \begin{macrocode}
3666 \newcommand\divScalar[3][scalarDivResult]{%
3667 \FPifeq{#3}{0}
3668 \PackageError{glmatrix package}{In divScalar function: division by zero}{parameter 3 is zero therefore you are trying to divide by 0}
3669 \else
3670 \fi
3671 \FPdiv\tmp{#2}{#3}
3672 \newScalar{#1}{\tmp}
3673 }
3674 % \end{macrocode}
3675 % \end{macro}
3676
3677
3678 % \setlabel{\textbackslash powScalar}{macro:powScalar_impl}
3679 % \begin{macro}{\powScalar}
3680 % Raise the values of one scalar by another.
3681 %
3682 % \#1 - out: var name to save the result (scalar) to\\
3683 % \#2 - scalar s: the scalar to raise\\
3684 % \#3 - scalar t: the scalar with which to raise
3685 % \begin{macrocode}
3686 \newcommand\powScalar[3][scalarPowResult]{%
3687 \FPpow\tmp{#2}{#3}
3688 \newScalar{#1}{\tmp}
3689 }
3690 % \end{macrocode}
3691 % \end{macro}
3692
3693
3694 % \setlabel{\textbackslash negateScalar}{macro:negateScalar_impl}
3695 % \begin{macro}{\negateScalar}
3696 % Negate the value of the given scalar.
3697 %
3698 % \#1 - out: var name to save the result (scalar) to\\
3699 % \#2 - scalar: the scalar to negate
3700 % \begin{macrocode}
3701 \newcommand\negateScalar[2][scalarNegateResult]{%
3702 \FPneg\tmp{#2}
3703 \newScalar{#1}{\tmp}
3704 }
3705 % \end{macrocode}
3706 % \end{macro}
3707
3708
3709 % \setlabel{\textbackslash arccosScalar}{macro:arccosScalar_impl}
3710 % \begin{macro}{\arccosScalar}
3711 % Get the arccos of the value of the given scalar.
3712 %
3713 % \#1 - out: var name to save the result (scalar) to\\
3714 % \#2 - scalar: the scalar to calculate the arccos for
3715 % \begin{macrocode}
3716 \newcommand\arccosScalar[2][scalarArccosResult]{%
3717 \FPround\tmp{#2}{10}
3718 \FPclip\tmp\tmp
3719 \FParccos\tmp\tmp
3720 \newScalar{#1}{\tmp}
3721 }
3722 % \end{macrocode}
3723 % \end{macro}
3724
3725
3726 % \setlabel{\textbackslash mulAndAddScalar}{macro:mulAndAddScalar_impl}
3727 % \begin{macro}{\mulAndAddScalar}
3728 % Adds two scalars after multiplying the second one by a scalar.
3729 %
3730 % \#1 - out: var name to save the result (scalar) to\\
3731 % \#2 - scalar s: the scalar to add to\\
3732 % \#3 - scalar t: the scalar that is multiplied and then added\\
3733 % \#4 - scalar u: the scalar that is the muliplier
3734 % \begin{macrocode}
3735 \newcommand\mulAndAddScalar[4][scalarMulAndAddResult]{%
3736 \FPmul\tmp{#3}{#4}
3737 \FPadd\tmp{#2}{\tmp}
3738 \newScalar{#1}{\tmp}
3739 }
3740 % \end{macrocode}
3741 % \end{macro}
3742
3743
3744 % \setlabel{\textbackslash lerpScalar}{macro:lerpScalar_impl}
3745 % \begin{macro}{\lerpScalar}
3746 % Lineraly interpolate between values of two scalars.
3747 %
3748 % \#1 - out: var name to save the result (scalar) to\\
3749 % \#2 - scalar i: the start scalar\\
3750 % \#3 - scalar j: the end scalar\\
3751 % \#4 - scalar t: interpolation amount range [0-1]
3752 % \begin{macrocode}
3753 \newcommand\lerpScalar[4][lerpScalarResult]{%
3754 \FPsub\tmpA{1}{#4}
3755 \FPmul\tmpA{#2}\tmpA
3756 \FPmul\tmpB{#3}{#4}
3757 \FPadd\tmpA\tmpA\tmpB
3758 \newScalar{#1}{\tmpA}
3759 }
3760 % \end{macrocode}
3761 % \end{macro}
3762
3763
3764 % \setlabel{\textbackslash minScalar}{macro:minScalar_impl}
3765 % \begin{macro}{\minScalar}
3766 % Return the minimum of two scalar values.
3767 %
3768 % \#1 - out: var name to save the result (scalar) to\\
3769 % \#2 - scalar s: the first scalar\\
3770 % \#3 - scalar t: the second scalar
3771 % \begin{macrocode}
3772 \newcommand\minScalar[3][minScalarResult]{%
3773 % TODO use \FPmin#1#2#3
3774 \FPiflt{#2}{#3}
3775 \expandafter\edef\csname #1\endcsname{#2}%
3776 \else
3777 \expandafter\edef\csname #1\endcsname{#3}%
3778 \fi
3779 }
3780 % \end{macrocode}
3781 % \end{macro}
3782
3783
3784 % \setlabel{\textbackslash maxScalar}{macro:maxScalar_impl}
3785 % \begin{macro}{\maxScalar}
3786 % Return the maximum of two scalar values.
3787 %
3788 % \#1 - out: var name to save the result (scalar) to\\
3789 % \#2 - scalar s: first scalar value\\
3790 % \#3 - scalar t: second scalar value
3791 % \begin{macrocode}
3792 \newcommand\maxScalar[3][maxScalarResult]{%
3793 % TODO use \FPmax#1#2#3
3794 \FPiflt{#2}{#3}
3795 \expandafter\edef\csname #1\endcsname{#3}%
3796 \else
3797 \expandafter\edef\csname #1\endcsname{#2}%
3798 \fi
3799 }
3800 % \end{macrocode}
3801 % \end{macro}
3802
3803
3804 % \setlabel{\textbackslash betweenScalar}{macro:betweenScalar_impl}
3805 % \begin{macro}{\betweenScalar}
3806 % Return whether a scalar lies between two other values.
3807 %
3808 % \#1 - out: var name to save the result (scalar) to (0 or 1)\\
3809 % \#2 - scalar: the scalar to test\\
3810 % \#3 - lower bound: \#2 needs to be greater then this for this macro to return 1\\
3811 % \#4 - upper bound: \#2 needs to be smaller than this for this macro to return 1
3812 % \begin{macrocode}
3813 \newcommand\betweenScalar[4][betweenScalarResult]{%
3814 \FPset\betweenScalarResult{0}
3815 \FPiflt{#2}{#3}
3816 \else
3817 \FPadd\betweenScalarResult\betweenScalarResult{1}
3818 \fi
3819 \FPifgt{#2}{#4}
3820 \else
3821 \FPadd\betweenScalarResult\betweenScalarResult{1}
3822 \fi
3823 % TODO
3824 \FPifeq{\betweenScalarResult}{2}
3825 % \FPset\betweenScalarResult{1}
3826 \expandafter\edef\csname #1\endcsname{1}%
3827 \else
3828 % \FPset\betweenScalarResult{0}
3829 \expandafter\edef\csname #1\endcsname{0}%
3830 \fi
3831 }
3832 % \end{macrocode}
3833 % \end{macro}
3834
3835
3836 % \setlabel{\textbackslash forEachScalar}{macro:forEachScalar_impl}
3837 % \begin{macro}{\forEachScalar}
3838 % Apply the given function to a list of variables.
3839 %
3840 % \#1 - input: list of commands (var names) that should be altered\\
3841 % \#2 - macro: the chosen function\\
3842 % \#3 - args: params for function
3843 % \begin{macrocode}
3844 \newcommand\forEachScalar[3]{
3845 \FPiflt{#2}{10}
3846 \else
3847 \PackageError{glmatrix package}{In forEach scalar}{selection function that is not implemented (chose between 1 to 9 for parameter 2)}
3848 \fi
3849 %
3850 \def\varList{\xintCSVtoList{#1}}
3851 \def\paramList{\xintCSVtoList{#3}}
3852 \xintFor* ##1 in \varList \do {%
3853 \FPifeq{#2}{1}
3854 \addScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}
3855 \else
3856 \fi
3857 \FPifeq{#2}{2}
3858 \subScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}
3859 \else
3860 \fi
3861 \FPifeq{#2}{3}
3862 \mulScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}
3863 \else
3864 \fi
3865 \FPifeq{#2}{4}
3866 \divScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}
3867 \else
3868 \fi
3869 \FPifeq{#2}{5}
3870 \powScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}
3871 \else
3872 \fi
3873 \FPifeq{#2}{6}
3874 \negateScalar[##1]{\csname ##1\endcsname}
3875 \else
3876 \fi
3877 \FPifeq{#2}{7}
3878 \lerpScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}{\xintNthElt{2}{\paramList}}
3879 \else
3880 \fi
3881 \FPifeq{#2}{8}
3882 \mulAndAddScalar[##1]{\csname ##1\endcsname}{\xintNthElt{1}{\paramList}}{\xintNthElt{2}{\paramList}}
3883 \else
3884 \fi
3885 \FPifeq{#2}{9}
3886 \arccosScalar[##1]{\csname ##1\endcsname}
3887 \else
3888 \fi
3889 }
3890 }
3891 % \end{macrocode}
3892 % \end{macro}
3893
3894
3895 % \setlabel{\textbackslash fractionToNum}{macro:fractionToNum_impl}
3896 % \begin{macro}{\fractionToNum}
3897 % Convert a fraction with root to a decimal number
3898 %
3899 % \begin{macrocode}
3900 \newcommand\fractionToNum[3]{%
3901 \FProot\tmpA{#3}{2}
3902 \FPmul\tmpA\tmpA{#2}
3903 \FPdiv\tmpB{#1}\tmpA
3904 \FPset\fractionNumRes{\tmpB}
3905 \ensuremath{
3906 \tmpB
3907 }
3908 }
3909 % \end{macrocode}
3910 % \end{macro}
3911
3912
3913 % \setlabel{\textbackslash solutionC}{macro:solutionC_impl}
3914 % \begin{macro}{\solutionC}
3915 % Convert a decimal number to a fraction with root
3916 %
3917 % \begin{macrocode}
3918 \newcommand\solutionC{%
3919 \FPset\finalmul{1}
3920 \FPset\tmptmptmptmp\tmptmptmp
3921 %
3922 \edef\innersequence{\xintSeq[+1]{+1}{+10}}%
3923 \xintFor* ##1 in \innersequence \do {%
3924 \FPtrunc\floored\tmptmptmptmp{0}
3925 \FPsub\remainder\tmptmptmptmp\floored
3926 \FPifgt{\remainder}{0.00001}
3927 \FPdiv\mulmul{1}{\remainder}
3928 \FPmul\finalmul\finalmul\mulmul
3929 \else
3930 \xintBreakFor
3931 \fi
3932 \FPset\tmptmptmptmp\mulmul
3933 }
3934 \FPround\finalmul\finalmul{8}
3935 \FPclip\finalmul\finalmul
3936 \FPset\finalmultmp\finalmul
3937 % The result will be a multiplicator that is able to round
3938 % the number to a whole number, but the result might not be a
3939 % nice number to root e.g. 8/sqrt(6), 0.09375 will result in 32
3940 % 0.09375 * 32 = 3, but sqrt(32) = 5,65.. but given this we know
3941 % that the searched for number must be a multiple of 32, in this case 64
3942 % Note: rounding to 6 & 36 does not work since 0.09375 * 36 = 3.375
3943 \xintFor* ##1 in \innersequence \do {%
3944 \FProot\finalmulsqrt\finalmultmp{2}
3945 \FPround\finalmulsqrt\finalmulsqrt{4}
3946 \FPclip\finalmulsqrt\finalmulsqrt
3947 \FPifint{\finalmulsqrt}
3948 \xintBreakFor
3949 \else
3950 \FPadd\finalmultmp\finalmultmp\finalmul
3951 \fi
3952 }
3953 \FPset\finalmul\finalmultmp
3954 \FProot\finalmulsqrt\finalmul{2}
3955 \FPround\finalmulsqrt\finalmulsqrt{4}
3956 \FPclip\finalmulsqrt\finalmulsqrt
3957 \FPmul\divisor\divisor\finalmul
3958 \FPmul\dividend\dividend\finalmulsqrt
3959 }
3960 % \end{macrocode}
3961 % \end{macro}
3962
3963
3964 % \setlabel{\textbackslash numToFraction}{macro:numToFraction_impl}
3965 % \begin{macro}{\numToFraction}
3966 %
3967 % \begin{macrocode}
3968 \newcommand\numToFraction[1]{%
3969 \FPset\dividend{1}
3970 \FPset\divisor{#1}
3971 \FPset\minusSign{1}
3972 \FPiflt{\divisor}{0}
3973 \FPset\minusSign{-1}
3974 \else
3975 \fi
3976 \ensuremath{
3977 % reverse fraction
3978 \FPdiv\divisor{1}{#1}
3979 % Reverse root
3980 % Use FPmul instead of FPpow to allow for neg values
3981 \FPmul\divisor\divisor\divisor
3982 \FPset\tmptmptmp\divisor
3983 \FPround\divisor\divisor{10}
3984 \FPclip\divisor\divisor
3985 \FPifint{\divisor}
3986 \else
3987 \solutionC
3988 \fi
3989 %
3990 \FPround\divisor\divisor{4}
3991 \FPclip\divisor\divisor
3992 \FPmul\dividend\dividend\minusSign
3993 \FPround\dividend\dividend{4}
3994 \FPclip\dividend\dividend
3995 % TODO this should not be necessary
3996 \FPset\outputVar{#1}
3997 % Create fraction from dividend and divisor
3998 \FPset\outputVar{\frac{\dividend}{\sqrt{\divisor}}}
3999 % If the sqrt can be resolved
4000 \FPset\tmpDivisor{\divisor}
4001 \FProot\tmpDivisor\tmpDivisor{2}
4002 \FPround\tmpDivisor\tmpDivisor{8}
4003 \FPclip\tmpDivisor\tmpDivisor
4004 \FPifint{\tmpDivisor}
4005 \FPset\outputVar{\frac{\dividend}{\tmpDivisor}}
4006 \else
4007 \fi
4008 %
4009 \FPset\inputVar{#1}
4010 \FPmul\inputVar\inputVar\inputVar
4011 \FPmul\inputVar\inputVar\minusSign
4012 \FPround\inputVar\inputVar{8}
4013 \FPclip\inputVar\inputVar
4014 \FPifint{\inputVar}
4015 \FPset\outputVar{\,\sqrt{\inputVar}}
4016 \else
4017 \fi
4018 % If #1 was an int all along
4019 \FPset\inputVarA{#1}
4020 \FPround\inputVarA\inputVarA{10}
4021 \FPclip\inputVarA\inputVarA
4022 \FPifint{\inputVarA}
4023 \FPset\outputVar{\inputVarA}
4024 \else
4025 \fi
4026 \outputVar
4027 }
4028 }
4029 % \end{macrocode}
4030 % \end{macro}
4031
4032
4033 % \setlabel{\textbackslash numToFractionA}{macro:numToFractionA_impl}
4034 % \begin{macro}{\numToFractionA}
4035 %
4036 % \begin{macrocode}
4037 \newcommand\numToFractionA[1]{%
4038 \FPset\inputVarA{#1}
4039 \FPround\inputVarA\inputVarA{10}
4040 \FPclip\inputVarA\inputVarA
4041 % Prevent division by 0
4042 \FPifint{\inputVarA}
4043 \FPset\outputVar{\inputVarA}
4044 \outputVar
4045 \else
4046 \numToFraction{#1}
4047 \fi
4048 }
4049 % \end{macrocode}
4050 % \end{macro}
4051
4052 % \subsection{vector}
4053 % \begin{center}
4054 % \begin{tabularx}{\textwidth}{l p{8cm}} \hline
4055 % \textbf{Command} & \textbf{Arguments} \\ \hline
4056 % \ref{macro:newVec_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{values}} \\
4057 % \ref{macro:newVecPi_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{values}} \\
4058 % \ref{macro:randomVec_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{dimensions}, \marg{lower bound}, \marg{upper bound}} \\
4059 % \ref{macro:copyVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\copyVecResult} \\
4060 % \ref{macro:zeroVec_impl} & \makecell[t{p{8cm}}]{\oarg{dims}, \marg{out}\\3} \\
4061 % \ref{macro:appendToVec_impl} & \makecell[t{p{8cm}}]{\marg{out}, \marg{vector}, \marg{scalar}} \\
4062 % \ref{macro:printVec_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\0} \\
4063 % \ref{macro:printVecT_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\0} \\
4064 % \ref{macro:printVecAsPoint_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\0} \\
4065 % \ref{macro:printVecAsPi_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\0} \\
4066 % \ref{macro:printVecAsPiT_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector}\\0} \\
4067 % \ref{macro:printVecContent_impl} & \makecell[t{p{8cm}}]{\marg{vector}} \\
4068 % \ref{macro:printVecContentXY_impl} & \makecell[t{p{8cm}}]{\marg{vector}} \\
4069 % \ref{macro:printVecContentXYZ_impl} & \makecell[t{p{8cm}}]{\marg{vector}} \\
4070 % \ref{macro:printVecContentXYZW_impl} & \makecell[t{p{8cm}}]{\marg{vector}} \\
4071 % \ref{macro:getVecHeight_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\vecHeightResult} \\
4072 % \ref{macro:printScalarPComp_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector v}, \marg{vector w}\\0} \\
4073 % \ref{macro:printCrossPComp_impl} & \makecell[t{p{8cm}}]{\oarg{fraction}, \marg{vector v}, \marg{vector w}\\0} \\
4074 % \ref{macro:roundVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{digits}\\roundVecResult} \\
4075 % \ref{macro:ceilVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\ceilVecResult} \\
4076 % \ref{macro:floorVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\floorVecResult} \\
4077 % \ref{macro:dehomogenVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\dehomogenVecResult} \\
4078 % \ref{macro:addVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\addVecResult} \\
4079 % \ref{macro:subVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\subVecResult} \\
4080 % \ref{macro:mulVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\mulVecResult} \\
4081 % \ref{macro:divVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{vectors}\\divVecResult} \\
4082 % \ref{macro:scaleVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\scaleVecResult} \\
4083 % \ref{macro:divVecScalar_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}, \marg{scalar}\\divVecScalarResult} \\
4084 % \ref{macro:negateVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\negateVecResult} \\
4085 % \ref{macro:scaleAndAddVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar}\\scaleAndAddVecResult} \\
4086 % \ref{macro:lerpVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar t}\\lerpVecResult} \\
4087 % \ref{macro:slerpVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}, \marg{scalar t}\\slerpVecResult} \\
4088 % \ref{macro:dotVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\dotVecResult} \\
4089 % \ref{macro:lenVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\lenVecResult} \\
4090 % \ref{macro:sqrLenVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\sqrLenVecResult} \\
4091 % \ref{macro:normalizeVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\normalizeVecResult} \\
4092 % \ref{macro:crossVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\crossVecResult} \\
4093 % \ref{macro:crossVecTwoD_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\crossVecResult} \\
4094 % \ref{macro:angleVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\angleVecResult} \\
4095 % \ref{macro:distVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\distVecResult} \\
4096 % \ref{macro:sqrDistVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\sqrDistVecResult} \\
4097 % \ref{macro:transformVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{matrix}, \marg{vector}\\transformVecResult} \\
4098 % \ref{macro:tensorVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector}\\tensorVecResult} \\
4099 % \ref{macro:minVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\minVecResult} \\
4100 % \ref{macro:maxVec_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\maxVecResult} \\
4101 % \ref{macro:solveVecEQL_impl} & \makecell[t{p{8cm}}]{\oarg{out}, \marg{vector v}, \marg{vector w}\\solveVecEQLResult} \\
4102 % \end{tabularx}
4103 % \end{center}
4104
4105
4106 % \setlabel{\textbackslash newVec}{macro:newVec_impl}
4107 % \begin{macro}{\newVec}
4108 % Create a new vector and assign the given values.
4109 %
4110 % \#1 - out: var name to save the result (vector) to\\
4111 % \#2 - values: values that are assigned to \#1
4112 % \begin{macrocode}
4113 \newcommand\newVec[2]{%
4114 \if\noexpand#1\relax
4115 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of newVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
4116 \else
4117 \expandafter\edef\csname #1\endcsname{\xintCSVtoList{#2}}%
4118 \fi
4119 }
4120 % \end{macrocode}
4121 % \end{macro}
4122
4123
4124 % \setlabel{\textbackslash newVecPi}{macro:newVecPi_impl}
4125 % \begin{macro}{\newVecPi}
4126 % Create a new vector and assign the given values as a multiple of pi.
4127 %
4128 % \#1 - out: var name to save the result (vector) to\\
4129 % \#2 - values: values that are multiplied with pi and assigned to \#1
4130 % \begin{macrocode}
4131 \newcommand\newVecPi[2]{%
4132 \def\tmpVec{\xintCSVtoList{#2}}
4133 \xintFor* ##1 in \tmpVec \do {%
4134 \newScalarPi{tmp}{##1}
4135 \xintifForFirst{%
4136 \newVec{#1}{\tmp}
4137 }{%
4138 \appendToVec{#1}{\csname #1\endcsname}{\tmp}
4139 }
4140 }
4141 }
4142 % \end{macrocode}
4143 % \end{macro}
4144
4145
4146 % \setlabel{\textbackslash randomVec}{macro:randomVec_impl}
4147 % \begin{macro}{\randomVec}
4148 % Create a new vector and assign random values between lower and
4149 % upper bound to its components.
4150 % The value is obtained by creating a random value between 0 and 1
4151 % and then interpolating between lower and upper bound.
4152 %
4153 % \#1 - out: var name to save the result (vector) to\\
4154 % \#2 - dimensions: scalar that defines the number of dimensions \#1 should have\\
4155 % \#3 - lower bound: scalar that limits the possible values at the bottom\\
4156 % \#4 - upper bound: scalar that limits the possible values at the top
4157 % \begin{macrocode}
4158 \newcommand\randomVec[4]{
4159 \edef\innersequence{\xintSeq[+1]{+1}{#2}}%
4160 \xintFor* ##1 in \innersequence \do {%
4161 \FPrandom\tmp
4162 \lerpScalar{#3}{#4}{\tmp}
4163 \xintifForFirst{%
4164 \newVec{#1}{\lerpScalarResult}
4165 }{%
4166 \appendToVec{#1}{\csname #1\endcsname}{\lerpScalarResult}
4167 }
4168 }
4169 }
4170 % \end{macrocode}
4171 % \end{macro}
4172
4173
4174 % \setlabel{\textbackslash copyVec}{macro:copyVec_impl}
4175 % \begin{macro}{\copyVec}
4176 % Copy values from one vector variable to another.
4177 %
4178 % \#1 - out: var name to save the result (vector) to\\
4179 % \#2 - vector: vector which values are assigned to \#1
4180 % \begin{macrocode}
4181 \newcommand\copyVec[2][copyVecResult]{
4182 \xintFor* ##1 in #2 \do {%
4183 \xintifForFirst{%
4184 \newVec{#1}{##1}
4185 }{%
4186 \appendToVec{#1}{\csname #1\endcsname}{##1}
4187 }
4188 }
4189 }
4190 % \end{macrocode}
4191 % \end{macro}
4192
4193
4194 % \setlabel{\textbackslash zeroVec}{macro:zeroVec_impl}
4195 % \begin{macro}{\zeroVec}
4196 % Create or override a vector with all its components being 0.
4197 % Obacht: It is not necessary to call this to create a new vector.
4198 % This is just for convenience when requiring a vector with initialized with zero.
4199 %
4200 % \#1 - dims: number of dimensions (rows)\\
4201 % \#2 - out: var name to save the result (vector) to
4202 % \begin{macrocode}
4203 \newcommand\zeroVec[2][3]{%
4204 \edef\sequence{\xintSeq[+1]{+1}{#1}}%
4205 \xintFor* ##1 in \sequence \do {%
4206 \xintifForFirst{%
4207 \newVec{#2}{0}
4208 }{%
4209 \appendToVec{#2}{\csname #2\endcsname}{0}
4210 }
4211 }
4212 }
4213 % \end{macrocode}
4214 % \end{macro}
4215
4216
4217 % \setlabel{\textbackslash appendToVec}{macro:appendToVec_impl}
4218 % \begin{macro}{\appendToVec}
4219 % Append a dimension with the given value to an already defined vector.
4220 %
4221 % \#1 - out: var name to save the result (vector) to\\
4222 % \#2 - vector: the currently present values\\
4223 % \#3 - scalar: the scalar to add to \#2
4224 % \begin{macrocode}
4225 \newcommand\appendToVec[3]{%
4226 \expandafter\edef\csname #1\endcsname{#2 \xintCSVtoList{#3}}%
4227 }
4228 % \end{macrocode}
4229 % \end{macro}
4230
4231
4232 % \setlabel{\textbackslash printVec}{macro:printVec_impl}
4233 % \begin{macro}{\printVec}
4234 % Print the values of the given vector in vector notation.
4235 %
4236 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4237 % \#2 - vector: the vector that should be printed
4238 % \begin{macrocode}
4239 \newcommand\printVec[2][0]{%
4240 \if\noexpand#2\relax
4241 \else
4242 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of printVec seems to be a string but must be a command.}
4243 \fi
4244 \ensuremath{%
4245 \begin{pmatrix}
4246 \xintFor* ##1 in {#2} \do {%
4247 \xintifForLast{
4248 \FPifeq{#1}{0}
4249 \roundScalar{##1}
4250 \scalarRoundResult
4251 \else
4252 \numToFractionA{##1}
4253 \fi
4254 }{%
4255 \FPifeq{#1}{0}
4256 \roundScalar{##1}
4257 \scalarRoundResult
4258 \else
4259 \numToFractionA{##1}
4260 \fi
4261 \\
4262 }
4263 }
4264 \end{pmatrix}
4265 }
4266 }
4267 % \end{macrocode}
4268 % \end{macro}
4269
4270
4271 % \setlabel{\textbackslash printVecT}{macro:printVecT_impl}
4272 % \begin{macro}{\printVecT}
4273 % Print the values of the given vector in transposed notation.
4274 %
4275 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4276 % \#2 - vector: the vector that should be printed
4277 % \begin{macrocode}
4278 \newcommand\printVecT[2][0]{%
4279 \if\noexpand#2\relax
4280 \else
4281 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of printVecT seems to be a string but must be a command.}
4282 \fi
4283 \ensuremath{\trans{\left(
4284 \xintFor* ##1 in {#2} \do {%
4285 \xintifForLast{
4286 \FPifeq{#1}{0}
4287 \roundScalar{##1}
4288 \scalarRoundResult
4289 \else
4290 \numToFractionA{##1}
4291 \fi
4292 }{%
4293 \FPifeq{#1}{0}
4294 \roundScalar{##1}
4295 \scalarRoundResult
4296 \else
4297 \numToFractionA{##1}
4298 \fi
4299 ,
4300 }
4301 }
4302 \right)}}%
4303 }
4304 % \end{macrocode}
4305 % \end{macro}
4306
4307
4308 % \setlabel{\textbackslash printVecAsPoint}{macro:printVecAsPoint_impl}
4309 % \begin{macro}{\printVecAsPoint}
4310 % Print the values of the given vector in point notation.
4311 %
4312 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4313 % \#2 - vector: the vector that should be printed
4314 % \begin{macrocode}
4315 \newcommand\printVecAsPoint[2][0]{%
4316 \ensuremath{%
4317 \begin{bmatrix}
4318 \xintFor* ##1 in {#2} \do {%
4319 \FPifeq{#1}{0}
4320 \roundScalar{##1}
4321 \scalarRoundResult
4322 \else
4323 \numToFractionA{##1}
4324 \fi
4325 \xintifForLast{}{%
4326 \\
4327 }
4328 }
4329 \end{bmatrix}
4330 }
4331 }
4332 % \end{macrocode}
4333 % \end{macro}
4334
4335
4336 % \setlabel{\textbackslash printVecAsPi}{macro:printVecAsPi_impl}
4337 % \begin{macro}{\printVecAsPi}
4338 % Print the values of the given vector as a multiple of \(\pi\) in vector notation.
4339 %
4340 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4341 % \#2 - vector: the vector that should be printed
4342 % \begin{macrocode}
4343 \newcommand\printVecAsPi[2][0]{%
4344 \ensuremath{%
4345 \begin{pmatrix}
4346 \xintFor* ##1 in #2 \do {%
4347 \printScalarAsPi[#1]{##1}
4348 % \FPifeq{#1}{0}
4349 % \roundScalar{##1}
4350 % \scalarRoundResult
4351 % \else
4352 % \numToFractionA{##1}
4353 % \fi
4354 \xintifForLast{}{%
4355 \\
4356 }
4357 }
4358 \end{pmatrix}
4359 }
4360 }
4361 % \end{macrocode}
4362 % \end{macro}
4363
4364
4365 % \setlabel{\textbackslash printVecAsPiT}{macro:printVecAsPiT_impl}
4366 % \begin{macro}{\printVecAsPiT}
4367 % Print the values of the given vector as a multiple of Pi in transposed notation.
4368 %
4369 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4370 % \#2 - vector: the vector that should be printed
4371 % \begin{macrocode}
4372 \newcommand\printVecAsPiT[2][0]{%
4373 \ensuremath{\trans{\left(
4374 \xintFor* ##1 in #2 \do {%
4375 \printScalarAsPi[#1]{##1}
4376 \xintifForLast{}{%
4377 ,
4378 }
4379 }
4380 \right)}}
4381 }
4382 % \end{macrocode}
4383 % \end{macro}
4384
4385
4386 % \setlabel{\textbackslash printVecContent}{macro:printVecContent_impl}
4387 % \begin{macro}{\printVecContent}
4388 % Print the values of the given vector comma separated.
4389 %
4390 % \#1 - vector: the vector which values should be printed
4391 % \begin{macrocode}
4392 \newcommand\printVecContent[1]{%
4393 \xintNthElt{1}{#1},\xintNthElt{3}{#1},\xintNthElt{2}{#1}%
4394 }
4395 % \end{macrocode}
4396 % \end{macro}
4397
4398
4399 % \setlabel{\textbackslash printVecContentXY}{macro:printVecContentXY_impl}
4400 % \begin{macro}{\printVecContentXY}
4401 % Returns the x and y component of the given vector.
4402 %
4403 % \#1 - vector: the vector which values should be printed
4404 % \begin{macrocode}
4405 \newcommand\printVecContentXY[1]{%
4406 \xintNthElt{1}{#1}, \xintNthElt{2}{#1}
4407 }
4408 % \end{macrocode}
4409 % \end{macro}
4410
4411
4412 % \setlabel{\textbackslash printVecContentXYZ}{macro:printVecContentXYZ_impl}
4413 % \begin{macro}{\printVecContentXYZ}
4414 % Returns the x, y and z component of the given vector.
4415 %
4416 % \#1 - vector: the vector which values should be printed
4417 % \begin{macrocode}
4418 \newcommand\printVecContentXYZ[1]{%
4419 \xintNthElt{1}{#1}, \xintNthElt{2}{#1}, \xintNthElt{3}{#1}%
4420 }
4421 % \end{macrocode}
4422 % \end{macro}
4423
4424
4425 % \setlabel{\textbackslash printVecContentXYZW}{macro:printVecContentXYZW_impl}
4426 % \begin{macro}{\printVecContentXYZW}
4427 % Returns the x, y, z and w component of the given vector
4428 %
4429 % \#1 - vector: the vector which values should be printed
4430 % \begin{macrocode}
4431 \newcommand\printVecContentXYZW[1]{%
4432 \xintNthElt{1}{#1}, \xintNthElt{2}{#1}, \xintNthElt{3}{#1}, \xintNthElt{4}{#1}
4433 }
4434 % \end{macrocode}
4435 % \end{macro}
4436
4437
4438 % \setlabel{\textbackslash getVecHeight}{macro:getVecHeight_impl}
4439 % \begin{macro}{\getVecHeight}
4440 % Returns the number of components that given vector has (number of dimensions).
4441 %
4442 % \#1 - out: var name to save the result (scalar) to\\
4443 % \#2 - vector: the vector of which to return the height
4444 % \begin{macrocode}
4445 \newcommand\getVecHeight[2][vecHeightResult]{%
4446 \newScalar{#1}{\expandafter\xintLength\expandafter{#2}}
4447 }
4448 % \end{macrocode}
4449 % \end{macro}
4450
4451
4452 % \setlabel{\textbackslash printScalarPComp}{macro:printScalarPComp_impl}
4453 % \begin{macro}{\printScalarPComp}
4454 % Print the intermediate components of the scalarproduct calculation.
4455 %
4456 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4457 % \#2 - vector v: the first vector\\
4458 % \#3 - vector w: the second vector
4459 % \begin{macrocode}
4460 \newcommand\printScalarPComp[3][0] {%
4461 \FPifeq{\expandafter\xintLength\expandafter{#2}}{\expandafter\xintLength\expandafter{#3}}
4462 \else
4463 \PackageError{glmatrix package}{In scalar product}{vector A and B do not have same length}
4464 \fi
4465 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}}}%
4466 \ensuremath{
4467 \xintFor* ##1 in \innersequence \do {%
4468 \FPifeq{#1}{0}
4469 \printScalarRounded{\xintNthElt{##1}{#2}}*\printScalarRounded{\xintNthElt{##1}{#3}}
4470 \else
4471 \numToFractionA{\xintNthElt{##1}{#2}}*\numToFractionA{\xintNthElt{##1}{#3}}
4472 \fi
4473 \xintifForLast{}{%
4474 +
4475 }
4476 }
4477 }
4478 }
4479 % \end{macrocode}
4480 % \end{macro}
4481
4482
4483 % \setlabel{\textbackslash printCrossPComp}{macro:printCrossPComp_impl}
4484 % \begin{macro}{\printCrossPComp}
4485 % Print the intermediate components of the crossproduct calculation.
4486 %
4487 % \#1 - fraction: whether or not the value should be printed as a fraction (val=1)\\
4488 % \#2 - vector v: the first vector\\
4489 % \#3 - vector w: the second vector
4490 % \begin{macrocode}
4491 \newcommand\printCrossPComp[3][0] {%
4492 \FPifeq{\expandafter\xintLength\expandafter{#2}}{3}
4493 \else
4494 \PackageError{glmatrix package}{In cross product}{vector A is not of length 3}
4495 \fi
4496 \FPifeq{\expandafter\xintLength\expandafter{#3}}{3}
4497 \else
4498 \PackageError{glmatrix package}{In cross product}{vector A is not of length 3}
4499 \fi
4500 \FPset\aa{\xintNthElt{1}{#2}}
4501 \FPset\ab{\xintNthElt{2}{#2}}
4502 \FPset\ac{\xintNthElt{3}{#2}}
4503 \FPset\ba{\xintNthElt{1}{#3}}
4504 \FPset\bb{\xintNthElt{2}{#3}}
4505 \FPset\bc{\xintNthElt{3}{#3}}
4506 %
4507 \ensuremath{
4508 \FPifeq{#1}{0}
4509 \begin{pmatrix}
4510 \printScalarRounded{\ab}*\printScalarRounded{\bc} - \printScalarRounded{\ac}*\printScalarRounded{\bb}\\
4511 \printScalarRounded{\ac}*\printScalarRounded{\ba} - \printScalarRounded{\aa}*\printScalarRounded{\bc}\\
4512 \printScalarRounded{\aa}*\printScalarRounded{\bb} - \printScalarRounded{\ab}*\printScalarRounded{\ba}
4513 \end{pmatrix}
4514 \else
4515 \begin{pmatrix}
4516 \numToFractionA{\ab}*\numToFractionA{\bc} - \numToFractionA{\ac}*\numToFractionA{\bb}\\
4517 \numToFractionA{\ac}*\numToFractionA{\ba} - \numToFractionA{\aa}*\numToFractionA{\bc}\\
4518 \numToFractionA{\aa}*\numToFractionA{\bb} - \numToFractionA{\ab}*\numToFractionA{\ba}
4519 \end{pmatrix}
4520 \fi
4521 }
4522 }
4523 % \end{macrocode}
4524 % \end{macro}
4525
4526
4527 % \setlabel{\textbackslash roundVec}{macro:roundVec_impl}
4528 % \begin{macro}{\roundVec}
4529 % Round the values ot the given vector.
4530 %
4531 % \#1 - out: var name to save the result (vector) to\\
4532 % \#2 - vector: the vector that schould be rounded\\
4533 % \#3 - digits: number of digits after comma
4534 % \begin{macrocode}
4535 \newcommand\roundVec[3][roundVecResult]{%
4536 \xintFor* ##3 in #2 \do {%
4537 \FPround\tmp{##3}{#3}
4538 \xintifForFirst{%
4539 \newVec{#1}{\tmp}
4540 }{%
4541 \appendToVec{#1}{\csname #1\endcsname}{\tmp}
4542 }
4543 }
4544 }
4545 % \end{macrocode}
4546 % \end{macro}
4547
4548
4549 % \setlabel{\textbackslash ceilVec}{macro:ceilVec_impl}
4550 % \begin{macro}{\ceilVec}
4551 % Ceil the values of the given vector.
4552 %
4553 % \#1 - out: var name to save the result (vector) to\\
4554 % \#2 - vector: the vector that should be ceiled
4555 % \begin{macrocode}
4556 \newcommand\ceilVec[2][ceilVecResult]{
4557 \xintFor* ##1 in #2 \do {%
4558 \ceilScalar[tmp]{##1}
4559 \xintifForFirst{%
4560 \newVec{#1}{\tmp}
4561 }{%
4562 \appendToVec{#1}{\csname #1\endcsname}{\tmp}
4563 }
4564 }
4565 }
4566 % \end{macrocode}
4567 % \end{macro}
4568
4569
4570 % \setlabel{\textbackslash floorVec}{macro:floorVec_impl}
4571 % \begin{macro}{\floorVec}
4572 % Floor the values of the given vector.
4573 %
4574 % \#1 - out: var name to save the result (vector) to\\
4575 % \#2 - vector: the vector that should be floored
4576 % \begin{macrocode}
4577 \newcommand\floorVec[2][floorVecResult]{
4578 \xintFor* ##1 in #2 \do {%
4579 \floorScalar[tmp]{##1}
4580 \xintifForFirst{%
4581 \newVec{#1}{\tmp}
4582 }{%
4583 \appendToVec{#1}{\csname #1\endcsname}{\tmp}
4584 }
4585 }
4586 }
4587 % \end{macrocode}
4588 % \end{macro}
4589
4590
4591 % \setlabel{\textbackslash dehomogenVec}{macro:dehomogenVec_impl}
4592 % \begin{macro}{\dehomogenVec}
4593 % Dehomogenize the values of the given vector. This divides all vector components by the last component.
4594 %
4595 % \#1 - out: var name to save the result (vector) to\\
4596 % \#2 - vector: the vector that should be dehomogenized
4597 % \begin{macrocode}
4598 \newcommand\dehomogenVec[2][dehomogenVecResult]{
4599 \getVecHeight{#2}
4600 \FPset\tmpDiv{\xintNthElt{\vecHeightResult}{#2}}
4601 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4602 \xintFor* ##1 in \sequence \do {%
4603 \xintifForFirst{%
4604 \FPdiv\divResult{\xintNthElt{##1}{#2}}{\tmpDiv}
4605 \newVec{tmpVec}{\divResult}
4606 }{%
4607 % \xintifForLast{
4608 % }{
4609 \FPdiv\divResult{\xintNthElt{##1}{#2}}{\tmpDiv}
4610 \appendToVec{tmpVec}{\tmpVec}{\divResult}
4611 % }
4612 }
4613 }
4614 \copyVec[#1]{\tmpVec}
4615 }
4616 % \end{macrocode}
4617 % \end{macro}
4618
4619
4620 % \setlabel{\textbackslash addVec}{macro:addVec_impl}
4621 % \begin{macro}{\addVec}
4622 % Add the values of \(1\) to \(m\) vectors to the values of the given vector.
4623 %
4624 % \#1 - out: var name to save the result (vector) to\\
4625 % \#2 - vector: the vector to add to\\
4626 % \#3 - vectors: the list of vectors with which to add
4627 % \begin{macrocode}
4628 \newcommand\addVec[3][addVecResult]{%
4629 \def\vecList{\xintCSVtoList{#3}}
4630 \getVecHeight{#2}
4631 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4632 % Iterate each row / dimension
4633 \xintFor* ##1 in \sequence \do {%
4634 % Assign value of start vector (param #2)
4635 \FPset\sumValue{\xintNthElt{##1}{#2}}%
4636 % If this is the first iteration create a new vector
4637 \xintifForFirst{%
4638 % Iterate all vectors that are part of param #3
4639 \xintFor* ##2 in \vecList \do {%
4640 % Multiply with row value of current vector
4641 \FPadd\sumValue\sumValue{\xintNthElt{##1}{##2}}%
4642 }
4643 \newVec{#1}{\sumValue}
4644 }{%
4645 \xintFor* ##2 in \vecList \do {%
4646 \FPadd\sumValue\sumValue{\xintNthElt{##1}{##2}}%
4647 }
4648 \appendToVec{#1}{\csname #1\endcsname}{\sumValue}
4649 }
4650 }
4651 }
4652 % \end{macrocode}
4653 % \end{macro}
4654
4655
4656 % \setlabel{\textbackslash subVec}{macro:subVec_impl}
4657 % \begin{macro}{\subVec}
4658 % Subract the values of \(1\) to \(m\) vectors from the values of the given vector.
4659 %
4660 % \#1 - out: var name to save the result (vector) to\\
4661 % \#2 - vector: the vector to subtract from\\
4662 % \#3 - vectors: the list of vectors with which to subtract
4663 % \begin{macrocode}
4664 \newcommand\subVec[3][subVecResult]{%
4665 \if\noexpand#1\relax
4666 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of subVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
4667 \else
4668 \fi
4669 \if\noexpand#2\relax
4670 \else
4671 \PackageError{glmatrix package}{argument mismatch}{argument 2 of subVec does not seem to be a command}
4672 \fi
4673 % TODO does not work on list of commands
4674 % \if\noexpand#3\relax
4675 % \else
4676 % \PackageError{glmatrix package}{argument mismatch}{argument 3 of subVec does not seem to be a command}
4677 % \fi
4678 %
4679 \def\vecList{\xintCSVtoList{#3}}
4680 \getVecHeight{#2}
4681 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4682 % Iterate each row / dimension
4683 \xintFor* ##1 in \sequence \do {%
4684 % Assign value of start vector (param #2)
4685 \FPset\subValue{\xintNthElt{##1}{#2}}%
4686 % If this is the first iteration create a new vector
4687 \xintifForFirst{%
4688 % Iterate all vectors that are part of param #3
4689 \xintFor* ##2 in \vecList \do {%
4690 % Multiply with row value of current vector
4691 \FPsub\subValue\subValue{\xintNthElt{##1}{##2}}%
4692 }
4693 \newVec{#1}{\subValue}
4694 }{%
4695 \xintFor* ##2 in \vecList \do {%
4696 \FPsub\subValue\subValue{\xintNthElt{##1}{##2}}%
4697 }
4698 \appendToVec{#1}{\csname #1\endcsname}{\subValue}
4699 }
4700 }
4701 }
4702 % \end{macrocode}
4703 % \end{macro}
4704
4705
4706 % \setlabel{\textbackslash mulVec}{macro:mulVec_impl}
4707 % \begin{macro}{\mulVec}
4708 % Multiply the values of \(1\) to \(m\) vectors with the values of the given vector.
4709 % See Hadamard product (element-wise product) for more information.
4710 %
4711 % \#1 - out: var name to save the result (vector) to\\
4712 % \#2 - vector: the vector to multiply\\
4713 % \#3 - vectors: the list of vectors with which to multiply
4714 % \begin{macrocode}
4715 \newcommand\mulVec[3][mulVecResult]{
4716 \def\vecList{\xintCSVtoList{#3}}
4717 \getVecHeight{#2}
4718 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4719 % Iterate each row / dimension
4720 \xintFor* ##1 in \sequence \do {%
4721 % Assign value of start vector (param #2)
4722 \FPset\mulValue{\xintNthElt{##1}{#2}}%
4723 % If this is the first iteration create a new vector
4724 \xintifForFirst{%
4725 % Iterate all vectors that are part of param #3
4726 \xintFor* ##2 in \vecList \do {%
4727 % Multiply with row value of current vector
4728 \FPmul\mulValue\mulValue{\xintNthElt{##1}{##2}}%
4729 }
4730 \newVec{#1}{\mulValue}
4731 }{%
4732 \xintFor* ##2 in \vecList \do {%
4733 \FPmul\mulValue\mulValue{\xintNthElt{##1}{##2}}%
4734 }
4735 \appendToVec{#1}{\csname #1\endcsname}{\mulValue}
4736 }
4737 }
4738 }
4739 % \end{macrocode}
4740 % \end{macro}
4741
4742
4743 % \setlabel{\textbackslash divVec}{macro:divVec_impl}
4744 % \begin{macro}{\divVec}
4745 % Divide the values of the given vector by the values of \(1\) to \(m\) vectors (element-wise division).
4746 %
4747 % \#1 - out: var name to save the result (vector) to\\
4748 % \#2 - vector: the vector to divide\\
4749 % \#3 - vectors: the list of vectors to divide with
4750 % \begin{macrocode}
4751 \newcommand\divVec[3][divVecResult]{
4752 \def\vecList{\xintCSVtoList{#3}}
4753 \getVecHeight{#2}
4754 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4755 % Iterate each row / dimension
4756 \xintFor* ##1 in \sequence \do {%
4757 % Assign value of start vector (param #2)
4758 \FPset\divValue{\xintNthElt{##1}{#2}}%
4759 % If this is the first iteration create a new vector
4760 \xintifForFirst{%
4761 % Iterate all vectors that are part of param #3
4762 \xintFor* ##2 in \vecList \do {%
4763 \FPifeq{\xintNthElt{##1}{##2}}{0}
4764 \PackageError{glmatrix package}{In divVec function: division by zero}{you are trying to divide by 0}
4765 \else
4766 \fi
4767 % Divide with row value of current vector
4768 \FPdiv\divValue\divValue{\xintNthElt{##1}{##2}}%
4769 }
4770 \newVec{#1}{\divValue}
4771 }{%
4772 \xintFor* ##2 in \vecList \do {%
4773 \FPifeq{\xintNthElt{##1}{##2}}{0}
4774 \PackageError{glmatrix package}{In divVec function: division by zero}{you are trying to divide by 0}
4775 \else
4776 \fi
4777 \FPdiv\divValue\divValue{\xintNthElt{##1}{##2}}%
4778 }
4779 \appendToVec{#1}{\csname #1\endcsname}{\divValue}
4780 }
4781 }
4782 }
4783 % \end{macrocode}
4784 % \end{macro}
4785
4786
4787 % \setlabel{\textbackslash scaleVec}{macro:scaleVec_impl}
4788 % \begin{macro}{\scaleVec}
4789 % Multiply the values of the given vector by a scalar.
4790 %
4791 % \#1 - out: var name to save the result (vector) to\\
4792 % \#2 - vector: the vector to scale\\
4793 % \#3 - scalar: the scalar to scale with
4794 % \begin{macrocode}
4795 \newcommand\scaleVec[3][scaleVecResult] {%
4796 \xintFor* ##1 in #2 \do {%
4797 \FPmul\tmpVal{##1}{#3}
4798 \xintifForFirst{%
4799 \newVec{#1}{\tmpVal}
4800 }{%
4801 \appendToVec{#1}{\csname #1\endcsname}{\tmpVal}
4802 }
4803 }
4804 }
4805 % \end{macrocode}
4806 % \end{macro}
4807
4808
4809 % \setlabel{\textbackslash divVecScalar}{macro:divVecScalar_impl}
4810 % \begin{macro}{\divVecScalar}
4811 % Divide the values of the given vector by a scalar.
4812 %
4813 % \#1 - out: var name to save the result (vector) to\\
4814 % \#2 - vector: the vector to divide\\
4815 % \#3 - scalar: the scalar to divide with
4816 % \begin{macrocode}
4817 \newcommand\divVecScalar[3][divVecScalarResult] {%
4818 \if\noexpand#1\relax
4819 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of divVecScalar seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
4820 \else
4821 \fi
4822 \if\noexpand#2\relax
4823 \else
4824 \PackageError{glmatrix package}{argument mismatch}{argument 2 of divVecScalar does not seem to be a command}
4825 \fi
4826 \FPifeq{#3}{0}
4827 \PackageError{glmatrix package}{In div vector by scalar}{divisor is 0}
4828 \else
4829 \fi
4830 \xintFor* ##1 in #2 \do {%
4831 \FPdiv\divNumRes{##1}{#3}
4832 \xintifForFirst{%
4833 \newVec{#1}{\divNumRes}
4834 }{%
4835 \appendToVec{#1}{\csname #1\endcsname}{\divNumRes}
4836 }
4837 }
4838 }
4839 % \end{macrocode}
4840 % \end{macro}
4841
4842
4843 % \setlabel{\textbackslash negateVec}{macro:negateVec_impl}
4844 % \begin{macro}{\negateVec}
4845 % Negate the values of the given vector.
4846 %
4847 % \#1 - out: var name to save the result (vector) to\\
4848 % \#2 - vector: the vector to negate
4849 % \begin{macrocode}
4850 \newcommand\negateVec[2][negateVecResult]{
4851 \xintFor* ##1 in #2 \do {%
4852 \FPneg\tmp{##1}
4853 \xintifForFirst{%
4854 \newVec{#1}{\tmp}
4855 }{%
4856 \appendToVec{#1}{\csname #1\endcsname}{\tmp}
4857 }
4858 }
4859 }
4860 % \end{macrocode}
4861 % \end{macro}
4862
4863
4864 % \setlabel{\textbackslash scaleAndAddVec}{macro:scaleAndAddVec_impl}
4865 % \begin{macro}{\scaleAndAddVec}
4866 % Adds two vectors after multiplying the second one by a scalar.
4867 %
4868 % \#1 - out: var name to save the result (vector) to\\
4869 % \#2 - vector v: the vector to add to\\
4870 % \#3 - vector w: the vector that is multiplied and then added\\
4871 % \#4 - scalar: the scalar that is the muliplier
4872 % \begin{macrocode}
4873 \newcommand\scaleAndAddVec[4][scaleAndAddVecResult]{
4874 \scaleVec{#3}{#4}
4875 \addVec[#1]{#2}{\scaleVecResult}
4876 }
4877 % \end{macrocode}
4878 % \end{macro}
4879
4880
4881 % \setlabel{\textbackslash lerpVec}{macro:lerpVec_impl}
4882 % \begin{macro}{\lerpVec}
4883 % Lineraly interpolate between the values of two vectors (element-wise interpolation).
4884 %
4885 % \#1 - out: var name to save the result (vector) to\\
4886 % \#2 - vector v: the start vector\\
4887 % \#3 - vector w: the end vector\\
4888 % \#4 - scalar t: interpolation amount range [0-1]
4889 % \begin{macrocode}
4890 \newcommand\lerpVec[4][lerpVecResult]{
4891 % \def\vecList{\xintCSVtoList{#3}}
4892 \getVecHeight{#2}
4893 \edef\sequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
4894 % Iterate each row / dimension
4895 \xintFor* ##1 in \sequence \do {%
4896 % Assign value of start vector (param #2)
4897 % \FPset\divValue{\xintNthElt{##1}{#2}}%
4898 % If this is the first iteration create a new vector
4899 \xintifForFirst{%
4900 \lerpScalar{\xintNthElt{##1}{#2}}{\xintNthElt{##1}{#3}}{#4}
4901 \newVec{#1}{\lerpScalarResult}
4902 }{%
4903 \lerpScalar{\xintNthElt{##1}{#2}}{\xintNthElt{##1}{#3}}{#4}
4904 \appendToVec{#1}{\csname #1\endcsname}{\lerpScalarResult}
4905 }
4906 }
4907 }
4908 % \end{macrocode}
4909 % \end{macro}
4910
4911
4912 % \setlabel{\textbackslash slerpVec}{macro:slerpVec_impl}
4913 % \begin{macro}{\slerpVec}
4914 % Performs a spherical linear interpolation between two vectors.
4915 % This expects vector v and vector w to be normalized.
4916 %
4917 % \#1 - out: var name to save the result (vector) to\\
4918 % \#2 - vector v: the start vector\\
4919 % \#3 - vector w: the end vector\\
4920 % \#4 - scalar t: interpolation amount range [0-1]
4921 % \begin{macrocode}
4922 \newcommand\slerpVec[4][slerpVecResult] {%
4923 \angleVec{#2}{#3}
4924 \FPifeq{\angleVecResult}{0}
4925 \lerpVec[#1]{#2}{#3}{#4}
4926 \else
4927 \FPsin\angleTotal{\angleVecResult}
4928 \FPsub\ratioA{1}{#4}
4929 \FPmul\ratioA\ratioA{\angleVecResult}
4930 \FPsin\ratioA\ratioA
4931 \FPdiv\ratioA\ratioA\angleTotal
4932 \FPmul\ratioB{#4}{\angleVecResult}
4933 \FPsin\ratioB\ratioB
4934 \FPdiv\ratioB\ratioB\angleTotal
4935 \scaleVec[tmpA]{#2}{\ratioA}
4936 \scaleVec[tmpB]{#3}{\ratioB}
4937 \addVec[#1]{\tmpA}{\tmpB}
4938 \fi
4939 }
4940 % \end{macrocode}
4941 % \end{macro}
4942
4943
4944 % \setlabel{\textbackslash dotVec}{macro:dotVec_impl}
4945 % \begin{macro}{\dotVec}
4946 % Calculate the dotproduct of the given two vectors.
4947 % Other names for this operation are inner product and scalarproduct.
4948 %
4949 % \#1 - out: var name to save the result (scalar) to\\
4950 % \#2 - vector v: the first vector\\
4951 % \#3 - vector w: the second vector
4952 % \begin{macrocode}
4953 \newcommand\dotVec[3][dotVecResult] {%
4954 \if\noexpand#1\relax
4955 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of dotVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
4956 \else
4957 \fi
4958 \if\noexpand#2\relax
4959 \else
4960 \PackageError{glmatrix package}{argument mismatch}{argument 2 of dotVec does not seem to be a command}
4961 \fi
4962 \if\noexpand#3\relax
4963 \else
4964 \PackageError{glmatrix package}{argument mismatch}{argument 3 of dotVec does not seem to be a command}
4965 \fi
4966 \FPifeq{\expandafter\xintLength\expandafter{#2}}{\expandafter\xintLength\expandafter{#3}}
4967 \else
4968 \PackageError{glmatrix package}{In dot product}{vector A and B do not have same length}
4969 \fi
4970 \FPset\res{0}
4971 \FPset\tmp{0}
4972 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}}}%
4973 \xintFor* ##1 in \innersequence \do {%
4974 \FPset\valueA{\xintNthElt{##1}{#2}}
4975 \FPset\valueB{\xintNthElt{##1}{#3}}
4976 \FPmul\tmp\valueA\valueB
4977 \FPadd\res\res\tmp
4978 }
4979 \newScalar{#1}{\res}
4980 }
4981 % \end{macrocode}
4982 % \end{macro}
4983
4984
4985 % \setlabel{\textbackslash lenVec}{macro:lenVec_impl}
4986 % \begin{macro}{\lenVec}
4987 % Calculate the length of the given vector.
4988 %
4989 % \#1 - out: var name to save the result (scalar) to\\
4990 % \#2 - vector: the vector for which to calculate the length
4991 % \begin{macrocode}
4992 \newcommand\lenVec[2][lenVecResult] {%
4993 \if\noexpand#1\relax
4994 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of lenVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
4995 \else
4996 \fi
4997 \if\noexpand#2\relax
4998 \else
4999 \PackageError{glmatrix package}{argument mismatch}{argument 2 of lenVec does not seem to be a command}
5000 \fi
5001 \FPset\normTotal{0}
5002 \FPset\iterVal{0}
5003 % Iterate each value, multiply it with itself and sum up
5004 \xintFor* ##1 in #2 \do {%
5005 % No idea why this needs to be abs,
5006 % but negative values are a problem here
5007 \FPabs\iterVal{##1}
5008 \FPpow\tmpNormB\iterVal{2}
5009 \FPadd\normTotal\normTotal\tmpNormB
5010 }
5011 % Evaluate root for numbered result
5012 \FProot\normRooted\normTotal{2}
5013 % Set output var
5014 \newScalar{#1}{\normRooted}
5015 }
5016 % \end{macrocode}
5017 % \end{macro}
5018
5019
5020 % \setlabel{\textbackslash sqrLenVec}{macro:sqrLenVec_impl}
5021 % \begin{macro}{\sqrLenVec}
5022 % Calculate the squared length of the given vector.
5023 %
5024 % \#1 - out: var name to save the result (scalar) to\\
5025 % \#2 - vector: the vector for which to calculate the squared length
5026 % \begin{macrocode}
5027 \newcommand\sqrLenVec[2][sqrLenVecResult] {%
5028 \FPset\normTotal{0}
5029 \FPset\iterVal{0}
5030 % Iterate each value, multiply it with itself and sum up
5031 \xintFor* ##1 in #2 \do {%
5032 % No idea why this needs to be abs,
5033 % but negative values are a problem here
5034 \FPabs\iterVal{##1}
5035 \FPpow\tmpNormB\iterVal{2}
5036 \FPadd\normTotal\normTotal\tmpNormB
5037 }
5038 % Set output var
5039 \newScalar{#1}{\normTotal}
5040 }
5041 % \end{macrocode}
5042 % \end{macro}
5043
5044
5045 % \setlabel{\textbackslash normalizeVec}{macro:normalizeVec_impl}
5046 % \begin{macro}{\normalizeVec}
5047 % Divide all components of the vector by its length.
5048 %
5049 % \#1 - out: var name to save the result (vector) to\\
5050 % \#2 - vector: the vector which to normalize
5051 % \begin{macrocode}
5052 \newcommand\normalizeVec[2][normalizeVecResult] {%
5053 \if\noexpand#1\relax
5054 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of normalizeVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
5055 \else
5056 \fi
5057 \if\noexpand#2\relax
5058 \else
5059 \PackageError{glmatrix package}{argument mismatch}{argument 2 of normalizeVec does not seem to be a command}
5060 \fi
5061 \lenVec{#2}
5062 \divVecScalar[#1]{#2}{\lenVecResult}
5063 }
5064 % \end{macrocode}
5065 % \end{macro}
5066
5067
5068 % \setlabel{\textbackslash crossVec}{macro:crossVec_impl}
5069 % \begin{macro}{\crossVec}
5070 % Calculate crossproduct for the two given vectors.
5071 %
5072 % \#1 - out: var name to save the result (vector) to\\
5073 % \#2 - vector v: the first vector\\
5074 % \#3 - vector w: the second vector
5075 % \begin{macrocode}
5076 \newcommand\crossVec[3][crossVecResult] {%
5077 \FPifeq{\expandafter\xintLength\expandafter{#2}}{3}
5078 \else
5079 \PackageError{glmatrix package}{In cross product}{vector A is not of length 3}
5080 \fi
5081 \FPifeq{\expandafter\xintLength\expandafter{#3}}{3}
5082 \else
5083 \PackageError{glmatrix package}{In cross product}{vector A is not of length 3}
5084 \fi
5085 \FPset\aa{\xintNthElt{1}{#2}}
5086 \FPset\ab{\xintNthElt{2}{#2}}
5087 \FPset\ac{\xintNthElt{3}{#2}}
5088 \FPset\ba{\xintNthElt{1}{#3}}
5089 \FPset\bb{\xintNthElt{2}{#3}}
5090 \FPset\bc{\xintNthElt{3}{#3}}
5091 \FPset\tmp{0}
5092 % x component
5093 \FPset\scalarX{0}
5094 \FPmul\scalarX\ab\bc
5095 \FPmul\tmp\ac\bb
5096 \FPsub\scalarX\scalarX\tmp
5097 % y component
5098 \FPset\scalarY{0}
5099 \FPmul\scalarY\ac\ba
5100 \FPmul\tmp\aa\bc
5101 \FPsub\scalarY\scalarY\tmp
5102 % z component
5103 \FPset\scalarZ{0}
5104 \FPmul\scalarZ\aa\bb
5105 \FPmul\tmp\ab\ba
5106 \FPsub\scalarZ\scalarZ\tmp
5107 \newVec{#1}{\scalarX,\scalarY,\scalarZ}
5108 }
5109 % \end{macrocode}
5110 % \end{macro}
5111
5112
5113 % \setlabel{\textbackslash crossVecTwoD}{macro:crossVecTwoD_impl}
5114 % \begin{macro}{\crossVecTwoD}
5115 % Calculate crossproduct for the two given vectors.
5116 %
5117 % \#1 - out: var name to save the result (vector) to\\
5118 % \#2 - vector v: the first vector\\
5119 % \#3 - vector w: the second vector
5120 % \begin{macrocode}
5121 \newcommand\crossVecTwoD[3][crossVecResult] {%
5122 \FPifeq{\expandafter\xintLength\expandafter{#2}}{2}
5123 \else
5124 \PackageError{glmatrix package}{In cross product}{vector A is not of length 2}
5125 \fi
5126 \FPifeq{\expandafter\xintLength\expandafter{#3}}{2}
5127 \else
5128 \PackageError{glmatrix package}{In cross product}{vector A is not of length 2}
5129 \fi
5130 \FPset\aa{\xintNthElt{1}{#2}}
5131 \FPset\ab{\xintNthElt{2}{#2}}
5132 \FPset\ba{\xintNthElt{1}{#3}}
5133 \FPset\bb{\xintNthElt{2}{#3}}
5134 \FPmul\scalarUxVy{\xintNthElt{1}{#2}}{\xintNthElt{2}{#3}}
5135 \FPmul\scalarUyVx{\xintNthElt{2}{#2}}{\xintNthElt{1}{#3}}
5136 \FPsub\scalarResult{\scalarUxVy}{\scalarUyVx}
5137 \newScalar{#1}{\scalarResult}
5138 }
5139 % \end{macrocode}
5140 % \end{macro}
5141
5142
5143 % \setlabel{\textbackslash angleVec}{macro:angleVec_impl}
5144 % \begin{macro}{\angleVec}
5145 % Get the angle between the given two vectors in radian.
5146 %
5147 % \#1 - out: var name to save the result (scalar) to\\
5148 % \#2 - vector v: the first vector\\
5149 % \#3 - vector w: the second vector
5150 % \begin{macrocode}
5151 \newcommand\angleVec[3][angleVecResult] {%
5152 \dotVec[dotVW]{#2}{#3}
5153 \lenVec[normV]{#2}
5154 \lenVec[normW]{#3}
5155 \mulScalar[mulNormVW]{\normV}{\normW}
5156 \divScalar{\dotVW}{\mulNormVW}
5157 \arccosScalar[#1]{\scalarDivResult}
5158 }
5159 % \end{macrocode}
5160 % \end{macro}
5161
5162
5163 % \setlabel{\textbackslash distVec}{macro:distVec_impl}
5164 % \begin{macro}{\distVec}
5165 % Calculates the euclidian distance between the given two vectors.
5166 %
5167 % \#1 - out: var name to save the result (scalar) to\\
5168 % \#2 - vector v: the first vector\\
5169 % \#3 - vector w: the second vector
5170 % \begin{macrocode}
5171 \newcommand\distVec[3][distVecResult] {%
5172 \sqrDistVec{#2}{#3}
5173 \FProot\res\sqrDistVecResult{2}
5174 \newScalar{#1}{\res}
5175 }
5176 % \end{macrocode}
5177 % \end{macro}
5178
5179
5180 % \setlabel{\textbackslash sqrDistVec}{macro:sqrDistVec_impl}
5181 % \begin{macro}{\sqrDistVec}
5182 % Calculates the squared euclidian distance between two vectors.
5183 %
5184 % \#1 - out: var name to save the result (scalar) to\\
5185 % \#2 - vector v: the first vector\\
5186 % \#3 - vector w: the second vector
5187 % \begin{macrocode}
5188 \newcommand\sqrDistVec[3][sqrDistVecResult] {%
5189 \getVecHeight[getVecHeightA]{#2}
5190 \getVecHeight[getVecHeightB]{#3}
5191 \FPifeq{\getVecHeightA}{\getVecHeightB}
5192 \else
5193 \PackageError{glmatrix package}{In sqrt distance}{vector #2 and #3 do not have same length}
5194 \fi
5195 \FPset\res{0}
5196 \FPset\tmp{0}
5197 \edef\sequence{\xintSeq[+1]{+1}{\getVecHeightA}}%
5198 \xintFor* ##1 in \sequence \do {%
5199 \FPset\valueA{\xintNthElt{##1}{#2}}
5200 \FPset\valueB{\xintNthElt{##1}{#3}}
5201 \FPsub\tmp\valueA\valueB
5202 \FPmul\tmp\tmp\tmp
5203 \FPadd\res\res\tmp
5204 }
5205 \newScalar{#1}{\res}
5206 }
5207 % \end{macrocode}
5208 % \end{macro}
5209
5210
5211 % \setlabel{\textbackslash transformVec}{macro:transformVec_impl}
5212 % \begin{macro}{\transformVec}
5213 % Multiply the given vector with a matrix (for transformation).
5214 %
5215 % \#1 - out: var name to save the result (vector) to\\
5216 % \#2 - matrix: the matrix to transform the vetor with\\
5217 % \#3 - vector: the vector to transform
5218 % \begin{macrocode}
5219 \newcommand\transformVec[3][transformVecResult] {%
5220 \if\noexpand#1\relax
5221 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of transformVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
5222 \else
5223 \fi
5224 \if\noexpand#2\relax
5225 \else
5226 \PackageError{glmatrix package}{argument mismatch}{argument 2 of transformVec does not seem to be a command}
5227 \fi
5228 \if\noexpand#3\relax
5229 \else
5230 \PackageError{glmatrix package}{argument mismatch}{argument 3 of transformVec does not seem to be a command}
5231 \fi
5232 \getVecHeight{#3}%
5233 \getMatHeight{#2}%
5234 \getMatWidth{#2}%
5235 % Check that matrix and vector can be multiplied
5236 \FPifeq{\matWidthResult}{\vecHeightResult}
5237 \else
5238 \PackageError{glmatrix package}{Dimension mismatch for matrix and vector, could not multiply}{width (\matWidthResult) of matrix #2 and height (\vecHeightResult) of vector #3 do not match}
5239 \fi
5240 % Create iterator sequences from height of vector and matrix
5241 \edef\vecHeightSequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
5242 \edef\matHeightSequence{\xintSeq[+1]{+1}{\matHeightResult}}%
5243 % Iterate all rows of the matrix
5244 \xintFor* ##2 in \matHeightSequence \do {%
5245 \FPset\cellVal{0}
5246 % Differentiate between first and other entries to create the new vector variable
5247 \xintifForFirst{%
5248 % Now iterate each entry of the current row
5249 % Use this indec to access the entry in the matrix and in the vector
5250 \xintFor* ##3 in \vecHeightSequence \do {%
5251 \FPmul\tmp{%
5252 \xintNthElt{##3}{\xintNthElt{##2}{#2}}%
5253 }{%
5254 \xintNthElt{##3}{#3}%
5255 }
5256 % Add to storage variable
5257 \FPadd\cellVal\cellVal\tmp
5258 }
5259 \FPclip\cellVal\cellVal
5260 \newVec{#1}{\cellVal}
5261 }{
5262 \xintFor* ##3 in \vecHeightSequence \do {%
5263 \FPmul\tmp{%
5264 \xintNthElt{##3}{\xintNthElt{##2}{#2}}%
5265 }{%
5266 \xintNthElt{##3}{#3}%
5267 }
5268 \FPadd\cellVal\cellVal\tmp
5269 }
5270 \FPclip\cellVal\cellVal
5271 \appendToVec{#1}{\csname #1\endcsname}{\cellVal}
5272 }
5273 }
5274 % Test if width and height is correct
5275 \expandafter\getVecHeight\expandafter{\csname #1\endcsname}%
5276 \FPifeq{\matHeightResult}{\vecHeightResult}
5277 \else
5278 \PackageError{glmatrix package}{Vector height does not match expectation}{height of vector is \vecHeightResult but should be \matHeightResult}
5279 \fi
5280 }
5281 % \end{macrocode}
5282 % \end{macro}
5283
5284
5285 % \setlabel{\textbackslash tensorVec}{macro:tensorVec_impl}
5286 % \begin{macro}{\tensorVec}
5287 % Outer product: Multiply a vector (column) with itself (row) resulting in a matrix. (Dyadic product, Tensor product)
5288 %
5289 % \#1 - out: var name to save the result (matrix) to\\
5290 % \#2 - vector: the vector to multiply with itself
5291 % \begin{macrocode}
5292 \newcommand\tensorVec[2][tensorVecResult]{%
5293 \newMatFromRowVecs{rowMatrix}{#2}
5294 \newMatFromColVecs{colMatrix}{#2}
5295 \mulMat[#1]{\colMatrix}{\rowMatrix}
5296 }
5297 % \end{macrocode}
5298 % \end{macro}
5299
5300
5301 % \setlabel{\textbackslash minVec}{macro:minVec_impl}
5302 % \begin{macro}{\minVec}
5303 % Return the componentwise minimum of the given two vectors.
5304 %
5305 % \#1 - out: var name to save the result (vector) to\\
5306 % \#2 - vector v: the first vector\\
5307 % \#3 - vector w: the second vector
5308 % \begin{macrocode}
5309 \newcommand\minVec[3][minVecResult]{
5310 \if\noexpand#1\relax
5311 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of minVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
5312 \else
5313 \fi
5314 \FPifeq{\expandafter\xintLength\expandafter{#2}}{\expandafter\xintLength\expandafter{#3}}
5315 \else
5316 \PackageError{glmatrix package}{incompatible size}{vector A and B of minVec do not have same length}
5317 \fi
5318 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}}}%
5319 \xintFor* ##1 in \innersequence \do {%
5320 \minScalar{\xintNthElt{##1}{#2}}{\xintNthElt{##1}{#3}}
5321 \xintifForFirst{%
5322 \newVec{#1}{\minScalarResult}
5323 }{%
5324 \appendToVec{#1}{\csname #1\endcsname}{\minScalarResult}
5325 }
5326 }
5327 }
5328 % \end{macrocode}
5329 % \end{macro}
5330
5331
5332 % \setlabel{\textbackslash maxVec}{macro:maxVec_impl}
5333 % \begin{macro}{\maxVec}
5334 % Return the componentwise maximum of the given two vectors.
5335 %
5336 % \#1 - out: var name to save the result (vector) to\\
5337 % \#2 - vector v: the first vector\\
5338 % \#3 - vector w: the second vector
5339 % \begin{macrocode}
5340 \newcommand\maxVec[3][maxVecResult]{
5341 \if\noexpand#1\relax
5342 \PackageError{glmatrix package}{argument mismatch}{Argument 1 of maxVec seems to be a command but must be a string. If it is not a command you might have used two identical letter at the beginning of the argument, please change that.}
5343 \else
5344 \fi
5345 \FPifeq{\expandafter\xintLength\expandafter{#2}}{\expandafter\xintLength\expandafter{#3}}
5346 \else
5347 \PackageError{glmatrix package}{incompatible size}{vector A and B of maxVec do not have same length}
5348 \fi
5349 \edef\innersequence{\xintSeq[+1]{+1}{\expandafter\xintLength\expandafter{#2}}}%
5350 \xintFor* ##1 in \innersequence \do {%
5351 \maxScalar{\xintNthElt{##1}{#2}}{\xintNthElt{##1}{#3}}
5352 \xintifForFirst{%
5353 \newVec{#1}{\maxScalarResult}
5354 }{%
5355 \appendToVec{#1}{\csname #1\endcsname}{\maxScalarResult}
5356 }
5357 }
5358 }
5359 % \end{macrocode}
5360 % \end{macro}
5361
5362
5363 % \setlabel{\textbackslash solveVecEQL}{macro:solveVecEQL_impl}
5364 % \begin{macro}{\solveVecEQL}
5365 % Solve the equation \(vector v*x+vector w=0\) for \(x\).
5366 % The command expects the input to be two vectors of the same length.
5367 % The command iterates both vectors componentwise and solves the equation per component.
5368 % If the the result does not match across all components the equation can not be solved.
5369 %
5370 % \#1 - out: var name to save the result (scalar) to\\
5371 % \#2 - vector v: the first vector\\
5372 % \#3 - vector w: the second vector
5373 % \begin{macrocode}
5374 \newcommand\solveVecEQL[3][solveVecEQLResult]{
5375 \getVecHeight{#3}%
5376 \edef\vecHeightSequence{\xintSeq[+1]{+1}{\vecHeightResult}}%
5377 \xintFor* ##1 in \vecHeightSequence \do {%
5378 % \FPneg\tmpVar{\xintNthElt{##1}{#3}}
5379 \FPlsolve\glCurSol{\xintNthElt{##1}{#2}}{\xintNthElt{##1}{#3}}
5380 \xintifForFirst{%
5381 \setScalar{#1}{\glCurSol}
5382 }{%
5383 \FPifeq{\csname #1\endcsname}{\glCurSol}
5384 \else
5385 \PackageError{glmatrix package}{Could not solve equation}{varying results for different dimensions}
5386 \fi
5387 }
5388 }
5389 }% \end{macrocode}
5390 % \end{macro}
5391
5392 % \iffalse
5393 %<*package>
5394 % \fi