Skip to content

Commit

Permalink
Documentation added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Jenni committed Sep 9, 2020
1 parent fb777fd commit 4583b98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 43 deletions.
Binary file modified lua-physical.pdf
Binary file not shown.
46 changes: 3 additions & 43 deletions lua-physical.tex
Original file line number Diff line number Diff line change
Expand Up @@ -219,49 +219,9 @@ \section{Loading}
)
}%
}


% print a physical quantity in scientific notation
\newcommand{\qs}[1]{%
\directlua{
tex.print(
physical.Quantity.tosiunitx(
#1,
"scientific-notation=true,exponent-to-prefix=false,
round-integer-to-decimal=true"
)
)
}%
}


% print the numeric part of a physical quantity
\newcommand{\qm}[1]{%
\directlua{
tex.print(
physical.Quantity.__tonumber(#1)
)
}%
}


% print the unit of a physical quantity
\newcommand{\qu}[1]{%
\directlua{
tex.print(
physical.Quantity.tosiunitx(
#1,
nil,
physical.Quantity.SIUNITX_si
)
)
}%
}
\end{lstlisting}


\pagebreak

\subsection{License}
This code is freely distributable under the terms of the MIT license.\\

Expand Down Expand Up @@ -320,7 +280,7 @@ \section{Usage}
%------------------------------------------------------------
\subsection{Unit conversion}

Very often, the result of a calculation has to be converted to another unit. In listing~\ref{lst:Volume of Cuboid} the task is to calculate the volume of a cuboid. The length of the edges are given in different units. The volume is calculated by multipling all three lengths, the unit of the result is \si{\cm\mm\m}. If the unit \si{\cm\cubed} is preferred, it has to be converted explicitly. The conversion function is called |to()| and is available on all physical quantitiy instances. At first this looks a bit cumbersome. The reason of this behaviour is, that the software is not able to guess the unit of the result. In many cases, like in the example here, it's not clear what unit the result sould have. Therefore the user has always to give the target unit explicitly. With the |\qu{}| macro of the basic preamble, the unit of a physical quantity can be printed.
Very often, the result of a calculation has to be converted to another unit. In listing~\ref{lst:Volume of Cuboid} the task is to calculate the volume of a cuboid. The length of the edges are given in different units. The volume is calculated by multipling all three lengths, the unit of the result is \si{\cm\mm\m}. If the unit \si{\cm\cubed} is preferred, it has to be converted explicitly. The conversion function is called |to()| and is available on all physical quantitiy instances. At first this looks a bit cumbersome. The reason of this behaviour is, that the software is not able to guess the unit of the result. In many cases, like in the example here, it's not clear what unit the result sould have. Therefore the user has always to give the target unit explicitly.

\pagebreak

Expand All @@ -334,7 +294,7 @@ \subsection{Unit conversion}
\end{luacode}

Find the volume of a rectangular cuboid with lengths $\q{a}$,
$\q{b}$ and $\q{c}$. Convert the result to $\qu{_dm^3}$.
$\q{b}$ and $\q{c}$.
%
\begin{equation*}
V= a \cdot b \cdot c
Expand All @@ -353,7 +313,7 @@ \subsection{Unit conversion}
\end{luacode}

\leftbar
Find the volume of a rectangular cuboid with lengths $\q{a}$, $\q{b}$ and $\q{c}$. Convert the result to $\qu{_dm^3}$.
Find the volume of a rectangular cuboid with lengths $\q{a}$, $\q{b}$ and $\q{c}$.
%
\begin{equation*}
V= a \cdot b \cdot c
Expand Down

0 comments on commit 4583b98

Please sign in to comment.