texlive[71309] Master/texmf-dist: liftarm (20may24)
commits+karl at tug.org
commits+karl at tug.org
Mon May 20 22:13:23 CEST 2024
Revision: 71309
https://tug.org/svn/texlive?view=revision&revision=71309
Author: karl
Date: 2024-05-20 22:13:23 +0200 (Mon, 20 May 2024)
Log Message:
-----------
liftarm (20may24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/liftarm/README.md
trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.pdf
trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex
trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty
Modified: trunk/Master/texmf-dist/doc/latex/liftarm/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/liftarm/README.md 2024-05-19 23:41:38 UTC (rev 71308)
+++ trunk/Master/texmf-dist/doc/latex/liftarm/README.md 2024-05-20 20:13:23 UTC (rev 71309)
@@ -1,20 +1,20 @@
-# liftarm
+# `liftarm`
-Draw liftarms with TikZ
+## Geometric constructions with liftarms using Ti*k*Z and LaTeX3
-Version 2.0 (2022/04/07)
+Version 3.0 (2024/05/20)
-This package is based on the package TikZ and can be used to draw liftarms with TikZ. It provides several options for the appearance of the liftarms, a command which connects two liftarms, an environment to describe a construction and a method to animate a construction with one or more traces.
+This package is based on the package [Ti*k*Z](https://ctan.org/pkg/pgf) and can be used to draw geometric constructions with liftarms using Ti*k*Z. There are several options for the appearance of the liftarms. It provides an environment to connect multiple liftarms using the Newton-Raphson method and LU decomposition. It also provides an environment to describe a construction and a method to animate a construction with one or more traces.
%% README.md
%% Copyright 2022 Matthias Floré
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
+% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
Modified: trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex 2024-05-19 23:41:38 UTC (rev 71308)
+++ trunk/Master/texmf-dist/doc/latex/liftarm/liftarm.tex 2024-05-20 20:13:23 UTC (rev 71309)
@@ -1,12 +1,12 @@
%% liftarm.tex
-%% Copyright 2022 Matthias Floré
+%% Copyright 2022-2024 Matthias Floré
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
+% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
@@ -20,37 +20,42 @@
\usepackage{graphicx}
\usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry}
\usepackage{parskip}
+\usepackage{iftex}
+\ifluatex
+\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
+\fi
\usepackage{mathtools}
\usepackage{amssymb}
\allowdisplaybreaks
-\usepackage{multicol}
+\usepackage{pdflscape}
\usepackage{animate}
\usepackage{liftarm}
\input{pgfmanual-en-macros.tex}
-\usepackage[page]{totalcount}
+\usepackage{codehigh}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
-\cfoot{\iftotalpages\begin{tikzpicture}\liftarm[mark holes=\thepage-1]{0,0}{\totalpages-2}{0}\end{tikzpicture}\fi}%\liftarm{0,0}{\thepage}{0}
\fancyhead{}
+\fancyfoot[C]{\IfRefUndefinedExpandable{Thesourcecode}{}{\begin{tikzpicture}\liftarm[mark holes=\thepage -1]{0,0}{\getpagerefnumber{Thesourcecode}-2}{0}\end{tikzpicture}}}%\liftarm{0,0}{\thepage}{0}
+\usepackage[nottoc]{tocbibind}
\usepackage{imakeidx}
\makeindex[program=makeindex,columns=2,intoc=true]
\indexsetup{othercode={\thispagestyle{fancy}}}
\usepackage[linktoc=all,pdfstartview=FitH,colorlinks=true,linkcolor=Mahogany,citecolor=ForestGreen,urlcolor=MidnightBlue,bookmarksnumbered=true]{hyperref}
-\hypersetup{pdftitle={The liftarm package},pdfauthor={Matthias Flor\'e},pdfsubject={Manual},pdfkeywords={liftarm}}
+\hypersetup{pdftitle={The liftarm package},pdfauthor={Matthias Floré},pdfsubject={Manual},pdfkeywords={liftarm}}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{2}
\DeclareMathOperator{\atan}{atan}
-\title{The \texttt{liftarm} package\\[12pt]\large Draw liftarms with \tikzname}
-\author{Matthias Flor\'e}
-\date{Version 2.0 (2022/04/07)}%\\[12pt]
+\title{The \texttt{liftarm} package\\[12pt]\large Geometric constructions with liftarms using \tikzname{} and \LaTeX3}
+\author{Matthias Floré}
+\date{Version 3.0 (2024/05/20)}%\\[12pt]
\begin{document}
\maketitle
\thispagestyle{fancy}
\begin{abstract}
-\noindent This package is based on the package |tikz| (see \cite{TtTaPGFp}) and can be used to draw liftarms with \tikzname. It provides several options for the appearance of the liftarms, a command which connects two liftarms, an environment to describe a construction and a method to animate a construction with one or more traces.% This is the manual for version .
+\noindent This package is based on the package |tikz| (see \cite{TtTaPGFp}) and can be used to draw geometric constructions with liftarms using \tikzname. There are several options for the appearance of the liftarms. It provides an environment to connect multiple liftarms using the Newton-Raphson method and LU decomposition. It also provides an environment to describe a construction and a method to animate a construction with one or more traces.% This is the manual for version .
\end{abstract}
\tableofcontents
\section{Usage}
@@ -58,7 +63,7 @@
\begin{codeexample}[code only]
\usepackage{liftarm}
\end{codeexample}
-The package |liftarm| loads the packages |etoolbox|, |xcolor| with the option |dvipsnames|, |tikz| and the \tikzname{} library |calc|. Since |xcolor| is loaded with the option |dvipsnames|, packages such as |pgfplots| and |tcolorbox| must be loaded \emph{after} |liftarm|.
+The package |liftarm| loads the package |xcolor| with the option |dvipsnames|, the package |tikz| and the \tikzname{} library |calc|. Since |xcolor| is loaded with the option |dvipsnames|, packages such as |pgfplots| and |tcolorbox| must be loaded \emph{after} |liftarm|.
\section{Drawing liftarms}
\begin{command}{\liftarm\opt{\oarg{options}}\marg{point}\marg{length}\marg{angle}}
This command can be placed inside a |tikzpicture| environment. It draws a liftarm of \meta{length} starting at \meta{point}. The angle between the liftarm and the $x$-axis can be specified by \meta{angle} in degrees. The distance between the holes is $1$.
@@ -84,53 +89,25 @@
\end{tikzpicture}
\end{codeexample}
\end{key}
-\begin{key}{/liftarm/color=\marg{name}}
-This key defines the color of the liftarm. The color can also be specified without key.
-\begin{codeexample}[width=10cm]
-\begin{tikzpicture}
-\liftarm[color=Green]{0,1}{4}{0}
-\liftarm[Blue]{0,2}{3}{0}
-\end{tikzpicture}
-\end{codeexample}
+\begin{key}{/liftarm/color=\marg{number}\marg{color}}
+This key defines the color of liftarms of length \meta{number}.
+
+Initially, the colors |Gray|, |darkgray|, |Yellow|, |Orange|, |Red|, |Green|, |Blue| and |Brown| are defined for respectively the lengths |0| till |7|.
\end{key}
-\begin{key}{/liftarm/color 0=\marg{name} (initially Gray)}
-\end{key}
-\begin{key}{/liftarm/color 1=\marg{name} (initially darkgray)}
-\end{key}
-\begin{key}{/liftarm/color 2=\marg{name} (initially Yellow)}
-\end{key}
-\begin{key}{/liftarm/color 3=\marg{name} (initially Orange)}
-\end{key}
-\begin{key}{/liftarm/color 4=\marg{name} (initially Red)}
-\end{key}
-\begin{key}{/liftarm/color 5=\marg{name} (initially Green)}
-\end{key}
-\begin{key}{/liftarm/color 6=\marg{name} (initially Blue)}
-\end{key}
-\begin{key}{/liftarm/color 7=\marg{name} (initially Brown)}
-These keys define the colors of the liftarms which have as their length the number following |color|.
-\end{key}
\begin{key}{/liftarm/color modulo=\marg{number} (initially 8)}
-The default colors of the liftarms are determined by computing the length of the liftarm modulo the value of this key and selecting the color from the previous keys.
+The default colors of the liftarms are determined by computing the length of the liftarm modulo the value of this key and selecting the color defined by the key |color|.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}[scale=0.5]
-\foreach\n in {0,...,16}{
- \liftarm{0,-\n}{\n}{0}
-}
-\end{tikzpicture}
-\end{codeexample}
-\begin{codeexample}[width=10cm]
-\begin{tikzpicture}[scale=0.5]
\pgfkeys{
- /liftarm,
- color 0=Yellow,
- color 1=Red,
- color 2=Green,
- color 3=Blue,
- color modulo=4
+ /liftarm,
+ color={0}{Yellow},
+ color={1}{Red},
+ color={2}{Green},
+ color={3}{Blue},
+ color modulo=4
}
\foreach\n in {0,...,8}{
- \liftarm{0,-\n}{\n}{0}
+ \liftarm{0,-\n}{\n}{0}
}
\end{tikzpicture}
\end{codeexample}
@@ -144,12 +121,28 @@
\end{tikzpicture}
\end{codeexample}
\end{key}
-\begin{key}{/liftarm/coordinate=\marg{number 1/name 1}\dots}
+\begin{stylekey}{/liftarm/contour style=\marg{options} (initially \normalfont empty)}
+The style of the contour is determined as follows. First, the color is defined as \meta{initial color of the liftarm}|!75!black|. Then the option |ultra thick| is added. Thereafter, the style of the key |contour style| is added.
+
+The style |contour style| only applies to the border of the liftarm. The style |liftarm style| also applies to the holes of the liftarm.
+\begin{codeexample}[width=10cm]
+\begin{tikzpicture}
+\liftarm[
+ contour,
+ contour style={dashed,black}
+]{0,1}{4}{0}
+\liftarm[
+ liftarm style={draw=black,thick}
+]{0,2}{4}{0}
+\end{tikzpicture}
+\end{codeexample}
+\end{stylekey}
+\begin{key}{/liftarm/coordinate=\marg{number 1/name 1,\dots}}
This key defines coordinates with name \meta{name i} at hole \meta{number i} of the liftarm.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
\liftarm[
- coordinate={1/A,3/B}
+ coordinate={1/A,3/B}
]{0,1}{6}{40}
\liftarm{A}{3}{0}
\liftarm{B}{2}{180}
@@ -164,40 +157,46 @@
\end{tikzpicture}
\end{codeexample}
\end{key}
+\begin{stylekey}{/liftarm/liftarm style=\marg{options} (initially \normalfont empty)}
+The style of the liftarm is determined as follows. First, the color is defined by the keys |color| and |color modulo|. Thereafter, the style of the key |liftarm style| is added.
+\end{stylekey}
\begin{key}{/liftarm/liftarm thickness=\marg{value} (initially 0.92)}
The \meta{value} of this key, multiplied with the \meta{value} of the key |scalefactor| defines the thickness of the liftarm.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
\liftarm[
- hole radius=0.1,
- liftarm thickness=0.3
+ hole radius=0.1,
+ liftarm thickness=0.3
]{0,0}{5}{0}
\end{tikzpicture}
\end{codeexample}
\end{key}
-\begin{key}{/liftarm/mark color=\marg{name} (initially Black)}
+\begin{key}{/liftarm/mark holes=\marg{values}}
\end{key}
-\begin{key}{/liftarm/mark holes=\marg{values}}
-The key |mark holes| defines the holes in the liftarm which will be marked. The key |mark color| defines the color of these marks.
+\begin{key}{/liftarm/mark radius=\marg{factor} (initially 1)}
+\end{key}
+\begin{stylekey}{/liftarm/mark style=\marg{options} (initially \normalfont empty)}
+The key |mark holes| defines the holes in the liftarm which will be marked. The radius is the product of the \meta{factor} given to the key |mark radius| and the value of the key |hole radius|. The style of these marks is determined as follows. First, the color is set to |black|. Thereafter, the style of the key |mark style| is added.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
\liftarm[
- mark holes={0,1,3}
+ mark holes={0,1,3}
]{0,0}{5}{0}
\liftarm[
- mark holes={1,2,4},
- mark color=Blue
+ mark holes={1,2,4},
+ mark radius=2/3,
+ mark style=Blue
]{0,1}{4}{0}
\end{tikzpicture}
\end{codeexample}
-\end{key}
+\end{stylekey}
\begin{key}{/liftarm/origin=\marg{number} (initially 0)}
This key defines the number of the hole which will be placed at the coordinate given as argument to the liftarm.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
\liftarm{-2,0}{4}{0}
-\liftarm[origin=1]{0,0}{6}{30}
-\liftarm[origin=2]{0,0}{5}{60}
+\liftarm[origin=1]{0,0}{3}{30}
+\liftarm[origin=2]{0,0}{5}{-20}
\end{tikzpicture}
\end{codeexample}
\end{key}
@@ -210,216 +209,254 @@
\end{tikzpicture}
\end{codeexample}
\end{key}
-\begin{key}{/liftarm/screw color=\marg{name} (initially Black)}
+\begin{key}{/liftarm/screw angle=\marg{angle} (initially 10)}
\end{key}
\begin{key}{/liftarm/screw holes=\marg{values}}
\end{key}
-\begin{key}{/liftarm/screw holes angle=\marg{angle} (initially 45)}
-The key |screw holes| defines the holes in the liftarm where a screw will be drawn. The key |screw color| defines the color of these screws. The key |screw holes angle| defines the angle in degrees around which the screws are drawn.
+\begin{key}{/liftarm/screw radius=\marg{factor} (initially 0.8)}
+\end{key}
+\begin{stylekey}{/liftarm/screw style=\marg{options} (initially \normalfont empty)}
+The key |screw holes| defines the holes in the liftarm where a screw will be drawn. The angle of these screws is determined by the key |screw angle| which is an angle in degrees. The radius is the product of the \meta{factor} given to the key |screw radius| and the value of the key |hole radius|. The style of these screws is determined as follows. First, the color is set to |black|. Then the option |rotate=45| is added. Thereafter, the style of the key |screw style| is added.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
\liftarm[
- screw holes={0,1,3}
+ screw holes={0,1,3}
]{0,0}{5}{0}
\liftarm[
- screw holes={1,2,4},
- screw color=Blue,
- screw holes angle=0
+ screw angle=15,
+ screw holes={1,2,4},
+ screw radius=0.7,
+ screw style={Blue,rotate=-45}
]{0,1}{4}{0}
\end{tikzpicture}
\end{codeexample}
+\end{stylekey}
+\begin{key}{/liftarm/type=\mchoice{liftarm,line segment} (initially liftarm)}
+\begin{description}
+\item[\texttt{liftarm}] In this case, the command |\liftarm| draws a liftarm.
+\item[\texttt{line segment}] In this case, the command |\liftarm| draws a line segment.
+\end{description}
\end{key}
\end{command}
\section{Connecting liftarms}
-\begin{command}{\liftarmconnect\opt{\oarg{options}}\marg{point1}\marg{length1}\marg{point2}\marg{length2}}
-This command can be placed inside a |tikzpicture| environment. It draws a liftarm of \meta{length1} starting at \meta{point1} and a liftarm of \meta{length2} starting at \meta{point2} in such a way that their last holes have the same coordinate in case that such a point exists. If such a point does not exist then nothing is drawn. In case that there exist 2 such points then this point is chosen counterclockwise. In that case, the other configuration of the 2 liftarms can be obtained by simply swapping \marg{point1}\marg{length1} and \marg{point2}\marg{length2}. The keys for the command |\liftarm| can be given to the \meta{options}. In this case these keys will be passed to both liftarms.
-\begin{codeexample}[width=9cm]
+\begin{environment}{{liftarmconnect}\opt{\oarg{options}}}
+This environment can be placed inside a |tikzpicture| environment. It can be used to connect liftarms where the angles are computed automatically. The \meta{options} can be a list of keys from the liftarm key family.
+
+The contents should consist only of commands |\liftarm| and spaces.
+
+The conditions to connect the liftarms are specified by the key |coordinate|. The resulting equations are determined automatically by the environment |liftarmconnect|. The number of liftarms needs to be equal to the number of equations. In the example below, there are 2 liftarms and 1 condition specified with the coordinate |A| resulting in 2 equations.
+\begin{codeexample}[width=10cm]
\begin{tikzpicture}
-\coordinate (A) at (0,0);
-\coordinate (B) at (4,2);
-\coordinate (C) at (1,-3);
-\coordinate (D) at (5,-1);
-\liftarmconnect[Yellow]{A}{2}{B}{3}
-\liftarmconnect[Red]{B}{3}{A}{2}
-\liftarmconnect[Green]{C}{3}{D}{2}
-\liftarmconnect[Blue]{D}{2}{C}{3}
-\foreach\coord in {A,B,C,D}{
- \node at (\coord) {{\small $\coord$}};
-}
+\coordinate (X) at (5,0);
+\begin{liftarmconnect}
+ \liftarm[coordinate=4/A]{0,0}{4}{60}
+ \liftarm[coordinate=4/A]{X}{4}{120}
+\end{liftarmconnect}
\end{tikzpicture}
\end{codeexample}
-Additionally, the \meta{options} can be given with the following keys.
-\begin{key}{/liftarm/connect coordinate=\marg{name}}
-This key defines a coordinate with name \meta{name} at the connection point of both liftarms.
-\begin{codeexample}[width=10cm]
+The similar code below does not work because the coordinate |A| is used as the starting point of the second liftarm but is unknown since it is used in a condition for the first liftarm and furthermore, there is no liftarm to complement the condition involving |A| in the first liftarm.
+\begin{codeexample}[code only]
\begin{tikzpicture}
-\liftarm{-3,0}{5}{0}
-\liftarmconnect[
- connect coordinate=A
-]{2,0}{2}{-2,0}{3}
-\liftarm{A}{4}{180}
+\coordinate (X) at (5,0);
+\begin{liftarmconnect}
+ \liftarm[coordinate=4/A]{0,0}{4}{60}
+ \liftarm[coordinate=4/X]{A}{4}{-60}
+\end{liftarmconnect}
\end{tikzpicture}
\end{codeexample}
+If the environment |liftarmconnect| consists of 2 liftarms then the law of cosines is used to compute the angles.
+
+If there are more than 2 liftarms then the set of equations is solved with the Newton-Raphson method. The initial values for the angles are given by the last arguments of the commands |\liftarm|. The Jacobian matrix is defined by the environment |liftarmconnect|. The resulting set of linear equations is solved with LU decomposition. The iteration stops if the condition determined by the key |connect stop| is satisfied.
+
+Since the \emph{let operation} from the \tikzname{} library |calc| is used, it is not possible to use the variable names |\n|, |\p|, |\x| and |\y| inside the starting point of a command |\liftarm| which is used in the environment |liftarmconnect|.
+\begin{key}{/liftarm/connect stop=\mchoice{1-norm,2-norm,iterations} (initially 1-norm)}
+\begin{description}
+\item[\texttt{1-norm}] In this case, the iteration stops if the 1-norm is smaller than the value given to this key. Its default value is $0.001$.
+\item[\texttt{2-norm}] In this case, the iteration stops if the 2-norm is smaller than the value given to this key. Its default value is $0.001$.
+\item[\texttt{iterations}] In this case, a number of iterations is executed where the number is the one given to this key. Its default value is $10$.
+\end{description}
\end{key}
-\begin{key}{/liftarm/connect reverse=\opt{\meta{boolean}} (default true, initially false)}
-If true, the first liftarm of |\liftarmconnect| will be drawn second and the second liftarm will be drawn first. This option can be used to change the appearance at the connection point of both liftarms.
\begin{codeexample}[width=10cm]
\begin{tikzpicture}
-\liftarmconnect{2,0}{1}{0,0}{2}
-\liftarmconnect[
- connect reverse
-]{5,0}{1}{3,0}{2}
+\begin{liftarmconnect}
+ \liftarm[coordinate=2/A]{0,0}{2}{70}
+ \liftarm[coordinate=3/A]{4,0}{3}{120}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=4/B]{4,0}{4}{200}
+ \liftarm[coordinate=1/B]{0,0}{1}{-90}
+\end{liftarmconnect}
+\node at (A) {\small $A$};
+\node at (B) {\small $B$};
\end{tikzpicture}
\end{codeexample}
-\end{key}
-\begin{stylekey}{/liftarm/liftarm 1=\marg{options} (initially \normalfont empty)}
-\end{stylekey}
-\begin{stylekey}{/liftarm/liftarm 2=\marg{options} (initially \normalfont empty)}
-These keys accept a list of keys which will be applied to the first respectively second liftarm. These lists of keys accept the same options as the command |\liftarm|. Additionally, the key |connect| below can be given.
-\begin{key}{/liftarm/connect=\marg{number}}
-This key defines the number of the hole which will be connected to the matching liftarm. If this key is not given then the last hole of the liftarm is taken as the connecting point.
-\begin{codeexample}[width=10cm]
+The example below shows the regular pentagon from \cite{Tmm1}. In the first environment |liftarmconnect| there are $4$ liftarms and $2$ conditions resulting in $4$ equations. Hence the Jacobian matrix has size $4\times 4$.
+\begin{codeexample}[width=7cm]
+\begin{tikzpicture}[scale=0.5]
+\pgfkeys{/liftarm,liftarm style={draw=black},scalefactor=1}
+\liftarm{0,0}{3}{0}
+\begin{liftarmconnect}
+ \liftarm[coordinate={3/A,4/B,12/C}]{0,0}{12}{100}
+ \liftarm[coordinate={3/D,4/E,12/F}]{3,0}{12}{80}
+ \liftarm[coordinate=11/F]{B}{11}{60}
+ \liftarm[coordinate=11/C]{E}{11}{120}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=3/G]{A}{3}{30}
+ \liftarm[coordinate=3/G]{D}{3}{150}
+\end{liftarmconnect}
+\end{tikzpicture}
+\end{codeexample}
+The example below shows iterations $0$ till $3$ of a construction with $6$ liftarms and $3$ conditions resulting in $6$ equations. Hence the Jacobian matrix has size $6\times 6$.
+\begin{codeexample}[]
\begin{tikzpicture}
-\liftarm{0,-7}{10}{90}
-\liftarmconnect[
- connect coordinate=A,
- liftarm 1={
- origin=1,
- connect=5
- },
- liftarm 2={
- origin=2,
- connect=6
- }
-]{0,2}{6}{0,0}{7}
-\liftarmconnect[
- liftarm 1={
- origin=2,
- connect=8
- },
- liftarm 2={
- origin=1,
- connect=5,
- coordinate=4/B
- }
-]{A}{9}{0,-6}{6}
-\liftarm[origin=1]{B}{4}{70}
+\liftarm{0,0}{15}{0}
+\liftarm{0,5}{15}{0}
+\foreach\k in {0,...,3}{
+ \begin{scope}[shift={(\k*4,0)}]
+ \begin{liftarmconnect}[connect stop={iterations=\k},liftarm style=ultra thick,type=line segment]
+ \liftarm[coordinate=3/A]{1,0}{3}{90}
+ \liftarm[coordinate=3/B]{3,0}{3}{90}
+ \liftarm[coordinate=1/B]{A}{1}{0}
+ \liftarm[coordinate=1/C]{A}{1}{70}
+ \liftarm[coordinate=1/C]{B}{1}{110}
+ \liftarm[coordinate=2/C]{0,5}{2}{0}
+ \end{liftarmconnect}
+ \node at (1.5,-1) {\texttt{iterations=\k}};
+ \end{scope}
+}
\end{tikzpicture}
\end{codeexample}
-\end{key}
-\end{stylekey}
+The example below shows the regular heptagon from \cite{Tmm1}. In the first environment |liftarmconnect| there are $8$ liftarms and $4$ conditions resulting in $8$ equations. Hence the Jacobian matrix has size $8\times 8$.
+\begin{codeexample}[width=8cm]
+\begin{tikzpicture}[scale=0.4]
+\pgfkeys{/liftarm,scalefactor=1}
+\liftarm{-4,0}{8}{0}
+\begin{liftarmconnect}
+ \liftarm[coordinate={1/A,7/B,8/G}]{-4,0}{8}{135}
+ \liftarm[coordinate=11/F]{A}{11}{50}
+ \liftarm[coordinate=11/F]{B}{11}{20}
+ \liftarm[coordinate={1/C,7/D,8/H}]{4,0}{8}{45}
+ \liftarm[coordinate=11/E]{C}{11}{130}
+ \liftarm[coordinate=11/E]{D}{11}{160}
+ \liftarm[coordinate=8/E]{G}{8}{30}
+ \liftarm[coordinate=8/F]{H}{8}{150}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=8/I]{E}{8}{70}
+ \liftarm[coordinate=8/I]{F}{8}{110}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=8/J]{G}{8}{70}
+ \liftarm[coordinate=8/J]{I}{8}{210}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=8/K]{H}{8}{110}
+ \liftarm[coordinate=8/K]{I}{8}{-30}
+\end{liftarmconnect}
+\end{tikzpicture}
+\end{codeexample}
+\end{environment}
+\section{Describing a construction}
+If a construction involves many liftarms then it is convenient to describe this construction in separate steps. Then the content of previous steps would need to be copied in each new step. This process can be automated by using the command |\liftarmconstruct| below.
+\begin{command}{\liftarmconstruct\marg{commands}}
+This command appends \meta{commands} to an internal token list. Then it uses this token list.
\end{command}
-\section{Describing a construction}
-If a construction involves many liftarms then it is convenient to describe this construction in separate steps and |tikzpicture|s. Then the content of previous |tikzpicture|s would need to be copied in each new |tikzpicture|. This process can be automated by using the |liftarmconstruction| environment and the command |\liftarmconstruct| below.
-\begin{environment}{{liftarmconstruction}\opt{\oarg{options}}}
-This environment is in fact an |enumerate| environment with the addition that it resets the content of the |tikzpicture| which is displayed by the command |\liftarmconstruct| below. Thus in particular, |\item| can be used inside the |liftarmconstruction| environment. The \meta{options} will be passed to each |tikzpicture| drawn by the command |\liftarmconstruct| inside this environment. The following command can be used inside this environment.
-\begin{command}{\liftarmconstruct\opt{\oarg{options}}\marg{text}\marg{commands}}
-This command starts an |\item| and shows \meta{text}. Then it displays a |tikzpicture| containing \meta{commands} and also the \meta{commands} of previous |\liftarmconstruct| commands inside the same |liftarmconstruction| environment. The \meta{options} will be added to this |tikzpicture| but \emph{only} in the current step.
+\begin{command}{\liftarmconstructclear}
+This command clears the token list which is used by the command |\liftarmconstruct|.
As an example, we describe below the construction of a regular pentagon from \cite{Tmm1}.
-\begin{codeexample}[width=10cm]
-\begin{minipage}{0.5\linewidth}%only for
-%usage in this manual%\linewidth-6pt
-%\begin{multicols}{2}%only for
-%usage in this manual
-\begin{liftarmconstruction}[scale=0.75]
-\liftarmconstruct[
- {\node[left,align=left]
- at (-0.5,-1.3)
- {Rectangular triangle.\\
- This text is only\\
- visible in this step.};}
-]{
- We start with 3 liftarms to form
- a rectangular triangle.
-}{
-\liftarm{-3,0}{4}{0}
-\liftarmconnect[
- liftarm 1={
- origin=2,
- mark holes={2,6}
- },
- liftarm 2={
- mark holes=0
- }
-]{0,0}{6}{-3,0}{5}}
-\item An |\item| can be added since this
- is an |enumerate| environment.
+\begin{codeexample}[width=7cm]
+\begin{minipage}{5.5cm}%only for usage in this manual
+\liftarmconstructclear
+\begin{enumerate}
+\item First we form a rectangular triangle with 3 liftarms.
+\begin{center}
+\begin{tikzpicture}[scale=0.7]
\liftarmconstruct{
- Now we add 2 liftarms of length $3$.
-}{\liftarmconnect[
- connect coordinate=A,
- liftarm 1={
- mark holes={0,3}
- },
- liftarm 2={
- mark holes=0
- }
-]{0,-2}{3}{0,2}{3}}
+ \liftarm[mark holes=3]{-3,0}{4}{0}
+ \begin{liftarmconnect}
+ \liftarm[coordinate=6/A,origin=2]{0,0}{6}{90}
+ \liftarm[coordinate=5/A,mark holes={0,5}]{-3,0}{5}{60}
+ \end{liftarmconnect}
+}
+\end{tikzpicture}
+\end{center}
+\item Then we add 2 liftarms of length $3$.
+\begin{center}
+\begin{tikzpicture}[scale=0.7]
\liftarmconstruct{
- In this step we construct the first
- side of the regular pentagon.
-}{\liftarmconnect[
- connect coordinate=B,
- liftarm 2={
- mark holes={0,2}
- }
-]{A}{2}{1,0}{2}}
+ \begin{liftarmconnect}
+ \liftarm[coordinate=3/B,mark holes={0,3}]{0,-2}{3}{45}
+ \liftarm[coordinate=3/B,mark holes=0]{0,2}{3}{-45}
+ \end{liftarmconnect}
+}
+\end{tikzpicture}
+\end{center}
+\item Here appears the first side of the regular pentagon.
+\begin{center}
+\begin{tikzpicture}[scale=0.7]
\liftarmconstruct{
- Now we finish the construction
- of the regular pentagon.
-}{\liftarmconnect[
- liftarm 2={
- mark holes={0,2}
- }
-]{B}{2}{-1,0}{2}
-\liftarmconnect[
- liftarm 1={
- mark holes=2
- }
-]{-1,0}{2}{A}{2}}
-\end{liftarmconstruction}
-%\end{multicols}
+ \begin{liftarmconnect}
+ \liftarm[coordinate=2/C]{B}{2}{100}
+ \liftarm[coordinate=2/C,mark holes={0,2}]{1,0}{2}{80}
+ \end{liftarmconnect}
+}
+\end{tikzpicture}
+\end{center}
+\item Now we end the construction of the regular pentagon.
+\begin{center}
+\begin{tikzpicture}[scale=0.7]
+\liftarmconstruct{
+ \begin{liftarmconnect}
+ \liftarm[coordinate=2/D]{C}{2}{180}
+ \liftarm[coordinate=2/D,mark holes={0,2}]{-1,0}{2}{80}
+ \end{liftarmconnect}
+ \begin{liftarmconnect}
+ \liftarm[coordinate=2/E,mark holes=2]{-1,0}{2}{-80}
+ \liftarm[coordinate=2/E]{B}{2}{210}
+ \end{liftarmconnect}
+}
+\end{tikzpicture}
+\end{center}
+\end{enumerate}
\end{minipage}
\end{codeexample}
\end{command}
-\end{environment}
\section{Animations}
\begin{command}{\liftarmanimate\opt{\oarg{options}}\marg{frame rate}\marg{list}\marg{command}}
-This command shows an animation using the |animateinline| environment of the package |animate|. The package |animate| is \emph{not} loaded by default and needs to be loaded to use the command |\liftarmanimate|. The \meta{options} are passed to the |animateinline| environment. The \meta{frame rate} of the animation is described in the documentation of the package |animate|. The \meta{command} must be a previously defined command with one mandatory argument. The \meta{list} is passed to a |\foreach| loop. The frames of the animation consist of the \meta{command} evaluated one by one in the result of the |\foreach| loop. The command |\liftarmanimate| creates a timeline which is used in the |animateinline| environment. This timeline is stored in the file |liftarm|\meta{number of the animation in the document}|.tln|. It requires two compiler runs to create and use this timeline correctly.
+This command shows an animation using the |animateinline| environment of the package |animate|. The package |animate| is \emph{not} loaded by default and needs to be loaded to use the command |\liftarmanimate|. The \meta{options} are passed to the |animateinline| environment. The \meta{frame rate} of the animation is described in the documentation of the package |animate|. The \meta{command} must be a previously defined command with one mandatory argument. The \meta{list} is passed to a |\foreach| loop. The frames of the animation consist of the \meta{command} evaluated one by one in the result of the |\foreach| loop. The command |\liftarmanimate| creates a timeline which is used in the |animateinline| environment. This timeline is stored in the file \meta{job name}\meta{number of the animation in the document}|.tln|. It requires two compiler runs to create and use this timeline correctly.
\begin{key}{/liftarm/trace=\marg{number/number of frames/code}\dots}
This key draws \meta{code} at hole \meta{number} of the liftarm on the frames of the animation determined by \meta{number of frames}.
If \meta{number of frames} is 0 then the \meta{code} is drawn starting at the current frame until the end of the animation. If \meta{number of frames} is an integer greater than or equal to 1 then the \meta{code} is drawn starting at the current frame and remaining during the next frames determined by \meta{number of frames}. If \meta{number of frames} is left empty then the \meta{code} is drawn starting at the beginning of the animation until the end of the animation.
-The \meta{code} can be some \tikzname{} code. In this \meta{code}, $(0,0)$ is positioned at hole \meta{number} of the liftarm. If \meta{code} is left empty then the following code is used.
-\begin{codeexample}[code only]
-\fill[Black] (0,0) circle[radius=0.66*\liftarm at holeradius];
-\end{codeexample}
+The \meta{code} can be some \tikzname{} code. In this \meta{code}, $(0,0)$ is positioned at hole \meta{number} of the liftarm. If \meta{code} is left empty then a black circle with radius $\frac{2}{3}$ times the |hole radius| is used.
+
A list of multiple triples \meta{number/number of frames/code} can be given to the key |trace|.
\begin{codeexample}[width=10cm,preamble={\usepackage{animate}}]
\newcommand{\exampleliftarmanimate}[1]{
- \liftarm[
- origin=1,
- mark holes=1,
- trace={
- 2/0/,
- 3//,
- 4/3/{\fill[Blue] (0,0)
- circle[radius=0.15];}
- }
- ]{0,0}{4}{#1}
+ \liftarm[
+ origin=1,
+ mark holes=1,
+ trace={
+ 2/0/,
+ 3//,
+ 4/3/{\fill[Blue] (0,0)
+ circle[radius=0.15];}
+ }
+ ]{0,0}{4}{#1}
}
\liftarmanimate[
- autoplay,
- controls,
- loop,
- begin={
- \begin{tikzpicture}
- \useasboundingbox (-4,-4)
- rectangle (4,4);
- },
- end={\end{tikzpicture}}
+ autoplay,
+ controls,
+ loop,
+ begin={
+ \begin{tikzpicture}
+ \useasboundingbox (-4,-4)
+ rectangle (4,4);
+ },
+ end={\end{tikzpicture}}
]
{5}
{0,30,...,330}
@@ -429,11 +466,14 @@
\end{command}
\section{Additional examples}
The following example shows a regular hexagon.
-\begin{codeexample}[width=9cm]
+\begin{codeexample}[width=8cm]
\begin{tikzpicture}
\def\r{3}
-\foreach\n in {1,...,6}{
- \liftarmconnect{0,0}{\r}{\n*60:\r}{\r}
+\foreach\m in {1,...,6}{
+ \begin{liftarmconnect}
+ \liftarm[coordinate=\r/A]{0,0}{\r}{(\m+1)*60}
+ \liftarm[coordinate=\r/A]{\m*60:\r}{\r}{(\m+2)*60}
+ \end{liftarmconnect}
}
\end{tikzpicture}
\end{codeexample}
@@ -448,18 +488,6 @@
\liftarm{2,1}{1}{90+atan(4/3)}
\end{tikzpicture}
\end{codeexample}
-Below is an example of an angled liftarm.
-\begin{codeexample}[width=9cm]
-\begin{tikzpicture}
-\pgfkeys{
- /liftarm,
- scalefactor=1,
- Blue
-}
-\liftarm[axle holes=0]{0,0}{3}{0}
-\liftarm[axle holes=5]{3,0}{5}{atan(4/3)}
-\end{tikzpicture}
-\end{codeexample}
The following example illustrates an angle bisection.
\begin{codeexample}[width=9cm]
\begin{tikzpicture}
@@ -468,15 +496,28 @@
\liftarm[mark holes={0,\r}]{0,0}{2*\r}{0}
\liftarm[mark holes=\r]{0,0}{2*\r}{\ang}
\liftarm[
- mark holes=\r,
- mark color=Red
+ mark holes=\r,
+ mark style=Red
]{\r,0}{\r}{\ang}
\liftarm{\ang:\r}{\r}{0}
\end{tikzpicture}
\end{codeexample}
+The following example illustrates that $7^{2}=3^{2}+8^{2}-2\cdot 3\cdot 8\cos(\frac{\pi}{3})$.
+\begin{codeexample}[width=9cm]
+\begin{tikzpicture}
+\begin{liftarmconnect}
+ \liftarm[coordinate=3/A]{0,0}{3}{80}
+ \liftarm[coordinate=3/A]{3,0}{3}{100}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=8/B]{0,0}{8}{0}
+ \liftarm[coordinate=7/B]{A}{7}{0}
+\end{liftarmconnect}
+\end{tikzpicture}
+\end{codeexample}
The following example illustrates that $7^{2}+4^{2}=8^{2}+1^{2}$.
\begin{codeexample}[width=9cm]
-\begin{tikzpicture}[scale=0.75]
+\begin{tikzpicture}
\def\a{4}
\def\b{7}
\def\c{1}
@@ -483,11 +524,17 @@
\def\d{8}
%\liftarm{0,0}{\b}{0}
%\liftarm{\b,0}{\a}{90}
-\liftarmconnect{0,0}{\b}{\b,\a}{\a}
+\begin{liftarmconnect}
+ \liftarm[coordinate=\b/A]{0,0}{\b}{0}
+ \liftarm[coordinate=\a/A]{\b,\a}{\a}{-90}
+\end{liftarmconnect}
\liftarm{4,0}{3}{90}
%\liftarm{\b,\a}{1}{atan(\a/\b)+atan(\c/\d)+90}
%\liftarm{0,0}{\d}{atan(\a/\b)+atan(\c/\d)}
-\liftarmconnect{\b,\a}{\c}{0,0}{\d}
+\begin{liftarmconnect}
+ \liftarm[coordinate=\d/B]{0,0}{\d}{45}
+ \liftarm[coordinate=\c/B]{\b,\a}{\c}{135}
+\end{liftarmconnect}
\end{tikzpicture}
\end{codeexample}
Below is an animation of the Peaucellier-Lipkin linkage, see e.g.~\cite{Koagmopermbl}.
@@ -497,31 +544,35 @@
\def\a{3}
\def\b{4}
\def\c{9}
-\pgfmathsetmacro{\x}{
- 2*\a+((\c^2-\b^2-(2*\a)^2)/(2*\a))
+\edef\l{
+ \fpeval{2*\a+(\c^2-\b^2-(2*\a)^2)/(2*\a)}
}
\useasboundingbox (-0.23,-6) rectangle
- ({\x+0.23},6);
-\draw (\x,-5)--(\x,5);
+ (\l+0.23,6);
+\draw (\l,-5)--(\l,5);
\liftarm{0,0}{\a}{0}
\liftarm[coordinate=\a/A]{\a,0}{\a}{#1}
-\liftarmconnect[
- connect coordinate=B,
- connect reverse
-]{A}{\b}{0,0}{\c}
-\liftarmconnect[
- connect coordinate=C
-]{0,0}{\c}{A}{\b}
-\liftarmconnect{C}{\b}{B}{\b}
+\begin{liftarmconnect}
+ \liftarm[coordinate=\c/B]{0,0}{\c}{0}
+ \liftarm[coordinate=\b/B]{A}{\b}{90}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=\c/C]{0,0}{\c}{0}
+ \liftarm[coordinate=\b/C]{A}{\b}{-90}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=\b/D]{C}{\b}{0}
+ \liftarm[coordinate=\b/D]{B}{\b}{0}
+\end{liftarmconnect}
\end{tikzpicture}
}
\begin{animateinline}[
- autoplay,
- controls,
- palindrome
+ autoplay,
+ controls,
+ palindrome
]{30}
\multiframe{80}{rAng=-40+1}{
- \PLlinkage{\rAng}
+ \PLlinkage{\rAng}
}
\end{animateinline}
\end{codeexample}
@@ -534,13 +585,19 @@
\liftarm[coordinate=12/B]{0,0}{27}{180-(#1)}
\liftarm[coordinate=18/C]{0,0}{27}{180-2*(#1)}
\liftarm[coordinate=27/D]{0,0}{27}{180-3*(#1)}
-\liftarmconnect{C}{27}{D}{18}
-\liftarmconnect[liftarm 2={connect=8}]{A}{12}{B}{18}
+\begin{liftarmconnect}
+ \liftarm[coordinate=27/E]{C}{27}{0}
+ \liftarm[coordinate=18/E]{D}{18}{0}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=12/F]{A}{12}{0}
+ \liftarm[coordinate=8/F]{B}{18}{0}
+\end{liftarmconnect}
\end{tikzpicture}
}
\begin{animateinline}[autoplay,controls,palindrome]{5}
\multiframe{20}{rAng=15+1}{
-\trisector{\rAng}
+ \trisector{\rAng}
}
\end{animateinline}
\end{codeexample}
@@ -549,41 +606,86 @@
\newcommand{\CL}[1]{
\liftarm{0,0}{4*\r}{0}
\liftarm[
- mark holes={0,2*\r}
+ mark holes={0,2*\r}
]{0,0}{2*\r}{#1}
-\liftarmconnect[
- liftarm 1={mark holes={0,5*\r}},
- liftarm 2={
- connect=5*\r,
- mark holes=10*\r,
- mark color=Red,
- trace={6*\r/0/,10*\r//}
- }
-]{4*\r,0}{5*\r}{#1:2*\r}{10*\r}
+\begin{liftarmconnect}
+ \liftarm[
+ coordinate=5*\r/A,
+ mark holes={0,5*\r}
+ ]{4*\r,0}{5*\r}{90}
+ \liftarm[
+ coordinate=5*\r/A,
+ mark holes=10*\r,
+ mark style=Red,
+ trace={6*\r/0/,10*\r//}
+ ]{#1:2*\r}{10*\r}{90}
+\end{liftarmconnect}
}
\liftarmanimate[
- autoplay,
- controls,
- loop,
- begin={
- \begin{tikzpicture}[scale=0.8]
- \def\r{1}
- \useasboundingbox
- (-2*\r-0.5,-2*\r-0.5)
- rectangle
- (10*\r-0.5,10*\r+0.5);
- },
- end={\end{tikzpicture}}
+ autoplay,
+ controls,
+ loop,
+ begin={
+ \begin{tikzpicture}[scale=0.8]
+ \def\r{1}
+ \useasboundingbox
+ (-2*\r-0.5,-2*\r-0.5)
+ rectangle
+ (10*\r-0.5,10*\r+0.5);
+ },
+ end={\end{tikzpicture}}
]
{20}
{0,5,...,355}
{\CL}
\end{codeexample}
+Below is an animation of a multilink steering mechanism.
+\begin{codeexample}[preamble={\usepackage{animate}}]
+\newcommand{\multilink}[1]{
+\begin{tikzpicture}[scale=0.9]
+\useasboundingbox (-8.5,-0.5) rectangle (8.5,5.7);
+\liftarm[brick,screw holes={0,6}]{-3,0}{6}{0}
+\liftarm[brick,screw holes={0,6}]{-3,3}{6}{0}
+\liftarm[coordinate={0/X,6/Y},screw holes={0,6}]{{-3+(#1)*0.1},4}{6}{0}
+\begin{liftarmconnect}
+ \liftarm[coordinate=3/A]{-3,0}{3}{160}
+ \liftarm[coordinate=3/B]{-3,3}{3}{200}
+ \liftarm[coordinate={1/B,4/C},screw holes={0,1,4}]{A}{4}{90}
+ \liftarm[coordinate=3/C]{X}{3}{180}
+\end{liftarmconnect}
+\begin{liftarmconnect}
+ \liftarm[coordinate=3/D]{3,0}{3}{20}
+ \liftarm[coordinate=3/E]{3,3}{3}{-20}
+ \liftarm[coordinate={1/E,4/F},screw holes={0,1,4}]{D}{4}{90}
+ \liftarm[coordinate=3/F]{Y}{3}{0}
+\end{liftarmconnect}
+\end{tikzpicture}
+}
+\begin{animateinline}[autoplay,controls,palindrome]{10}
+\multiframe{41}{rAng=-20+1}{
+ \multilink{\rAng}
+}
+\end{animateinline}
+\end{codeexample}
\section{Version history}
\begin{itemize}
\item[] \textbf{Version 1.0 (2022/03/08)} First version.
-\item[] \textbf{Version 2.0 (2022/04/07)} Removed some redundant |;| in the code.\footnote{Thanks to Denis Bitouz\'e for pointing this out.} Added the command |\liftarmanimate| and the key |trace|.
+\item[] \textbf{Version 2.0 (2022/04/07)} Removed some redundant |;| in the code.\footnote{Thanks to Denis Bitouzé for pointing this out.} Added the command |\liftarmanimate| and the key |trace|.
+\item[] \textbf{Version 3.0 (2024/05/20)}
+\begin{itemize}
+\item The package now mainly uses \LaTeX3 syntax. The package |etoolbox| is not loaded anymore.
+\item Improved the code for the key |axle holes|. In particular, the combinations with the keys |contour| and |hole radius| are fixed.
+\item Improved the path for the shape of a liftarm if the key |brick| is used.
+\item Changed the key |color| to accept two arguments. The color can no longer be specified without a key.
+\item Removed the keys |color 0|, |color 1|, |color 2|, |color 3|, |color 4|, |color 5|, |color 6| and |color 7|.
+\item In v2.0, the colors could only be defined up to length $7$. In v3.0, this is not a restriction anymore.
+\item Changed some initial colors from |Black| to |black|.
+\item Added the keys |contour style| and |liftarm style|.
+\item Removed the keys |mark color|, |screw color| and |screw holes angle|. Added the keys |mark radius|, |mark style|, |screw angle|, |screw radius| and |screw style|.
+\item Improved the algorithm to connect liftarms in multiple ways. In v2.0, transformations such as |x={(0.8,0.5)},y={(-0.6,1.2)}| were not taken into account correctly. This is fixed in v3.0. In v2.0, only 2 liftarms could be connected automatically. In v3.0, this is not a restriction anymore. Therefore the command |\liftarmconnect| and the keys |connect|, |connect coordinate|, |connect reverse|, |liftarm 1| and |liftarm 2| are removed. Instead, the environment |liftarmconnect| and the key |connect stop| were added in v3.0.
+\item Changed the command |\liftarmconstruct| to allow more customization. Removed the environment |liftarmconstruction| and added the command |\liftarmconstructclear|.
\end{itemize}
+\end{itemize}
\begin{thebibliography}{9}
\bibitem{Tmm1}
Gerard 't Hooft,
@@ -607,9 +709,16 @@
\bibitem{TtTaPGFp}
Till Tantau,
\emph{The \tikzname{} and {\upshape\pgfname} Packages},
-Manual for version 3.1.9a,
+Manual for version 3.1.10,
\url{https://ctan.org/pkg/pgf},
-2021.
+2023.
\end{thebibliography}
\printindex
+\newgeometry{left=2.25cm,right=2.25cm,top=2.25cm,bottom=2.25cm}
+\pagestyle{plain}
+\appendix
+\begin{landscape}
+\section{The source code}\label{Thesourcecode}
+\dochighinput[language=latex/latex3]{liftarm.sty}
+\end{landscape}
\end{document}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty 2024-05-19 23:41:38 UTC (rev 71308)
+++ trunk/Master/texmf-dist/tex/latex/liftarm/liftarm.sty 2024-05-20 20:13:23 UTC (rev 71309)
@@ -1,12 +1,12 @@
%% liftarm.sty
-%% Copyright 2022 Matthias Floré
+%% Copyright 2022-2024 Matthias Floré
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
+% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
@@ -16,321 +16,897 @@
% This work consists of the files liftarm.pdf, liftarm.sty,
% liftarm.tex and README.md.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{liftarm}[2022/04/07 v2.0 Draw liftarms with TikZ]
-\RequirePackage{etoolbox}
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{tikz}
\usetikzlibrary{calc}
-\newif\ifliftarm at animate
-\newif\ifliftarm at brick
-\newif\ifliftarm at connectreverse
-\newif\ifliftarm at contour
-\pgfkeys{
-/liftarm/.is family,
-/liftarm/.unknown/.code={\edef\liftarm at colorkey{\pgfkeyscurrentname}},
-/liftarm,
-axle holes/.store in=\liftarm at axleholes,
-brick/.is if=liftarm at brick,
-color/.store in=\liftarm at colorkey,
-color 0/.initial=Gray,
-color 1/.initial=darkgray,
-color 2/.initial=Yellow,
-color 3/.initial=Orange,
-color 4/.initial=Red,
-color 5/.initial=Green,
-color 6/.initial=Blue,
-color 7/.initial=Brown,
-color modulo/.initial=8,
-connect/.store in=\liftarm at connect,
-connect coordinate/.store in=\liftarm at connectcoordinate,
-connect reverse/.is if=liftarm at connectreverse,
-contour/.is if=liftarm at contour,
-coordinate/.store in=\liftarm at coordinate,
-globalize/.code n args={2}{\xdef#1{#2}},
-hole radius/.initial=0.3,
-liftarm 1/.style={liftarm 1 options/.style={#1}},
-liftarm 1 options/.style={},
-liftarm 2/.style={liftarm 2 options/.style={#1}},
-liftarm 2 options/.style={},
-liftarm thickness/.initial=0.92,
-mark color/.initial=Black,
-mark holes/.store in=\liftarm at markholes,
-origin/.initial=0,
-scalefactor/.initial=0.5,
-screw color/.initial=Black,
-screw holes/.store in=\liftarm at screwholes,
-screw holes angle/.initial=45,
-trace/.store in=\liftarm at trace,
-}
-\pgfmathsetmacro{\liftarm at axleholeangle}{14}%2*\liftarm at axleholeradius*sin(\liftarm at axleholeangle)=1.78/8
-\pgfmathsetmacro{\liftarm at screwholestartangle}{10}
-\newcommand{\liftarm}[4][]{
-\pgfmathsetmacro{\liftarm at length}{#3}
-\ifdim \liftarm at length pt<0 pt
-\PackageWarning{liftarm}{The length (\liftarm at length) of the liftarm is smaller than 0.}
-\else
-\pgfmathsetmacro{\liftarm at ang}{#4}
-\begin{scope}[shift={(#2)},rotate=\liftarm at ang]
-\pgfkeys{/liftarm,#1}
-\pgfmathsetmacro{\liftarm at origin}{\pgfkeysvalueof{/liftarm/origin}}
-\begin{scope}[shift={(-\liftarm at origin,0)}]
-\pgfmathsetmacro{\liftarm at halfthickness}{0.5*\pgfkeysvalueof{/liftarm/scalefactor}*\pgfkeysvalueof{/liftarm/liftarm thickness}}
-\pgfmathsetmacro{\liftarm at holeradius}{\pgfkeysvalueof{/liftarm/scalefactor}*\pgfkeysvalueof{/liftarm/hole radius}}
-\pgfmathsetmacro{\liftarm at halfstudwidth}{\pgfkeysvalueof{/liftarm/scalefactor}*0.3}
-\pgfmathsetmacro{\liftarm at studheight}{\pgfkeysvalueof{/liftarm/scalefactor}*0.2}
-\pgfmathsetmacro{\liftarm at halfplateheight}{\pgfkeysvalueof{/liftarm/scalefactor}*0.2}
-\pgfmathsetmacro{\liftarm at halfplatewidth}{\pgfkeysvalueof{/liftarm/scalefactor}*0.5}
-\pgfmathsetmacro{\liftarm at axleholeradius}{\liftarm at halfthickness}
-\pgfmathsetmacro{\liftarm at screwholeradius}{0.8*\liftarm at holeradius}
-\colorlet{liftarm at markcolor}{\pgfkeysvalueof{/liftarm/mark color}}
-\colorlet{liftarm at screwcolor}{\pgfkeysvalueof{/liftarm/screw color}}
-\pgfmathsetmacro{\liftarm at screwholesangle}{\pgfkeysvalueof{/liftarm/screw holes angle}}
-\ifcsname liftarm at colorkey\endcsname
-\colorlet{liftarm at color}{\liftarm at colorkey}
-\else
-\pgfmathsetmacro{\liftarm at colornumber}{int(mod(\liftarm at length,\pgfkeysvalueof{/liftarm/color modulo}))}
-\colorlet{liftarm at color}{\pgfkeysvalueof{/liftarm/color \liftarm at colornumber}}
-\fi
-\ifliftarm at brick
-\def\liftarm at shape{(-1,{-\liftarm at halfplatewidth-\liftarm at halfplateheight})--(-1,\liftarm at halfplatewidth)
-\foreach\liftarm at n in {-1,...,\liftarm at length}{
---({\liftarm at n+0.5-\liftarm at halfstudwidth},\liftarm at halfplatewidth)--({\liftarm at n+0.5-\liftarm at halfstudwidth},{\liftarm at halfplatewidth+\liftarm at studheight})--({\liftarm at n+0.5+\liftarm at halfstudwidth},{\liftarm at halfplatewidth+\liftarm at studheight})--({\liftarm at n+0.5+\liftarm at halfstudwidth},\liftarm at halfplatewidth)--({\liftarm at n+1},\liftarm at halfplatewidth)
-}
---({\liftarm at length+1},{-\liftarm at halfplatewidth-\liftarm at halfplateheight})--cycle}
-\else
-\def\liftarm at shape{(0,\liftarm at halfthickness) arc (90:270:\liftarm at halfthickness)--(\liftarm at length,-\liftarm at halfthickness) arc (-90:90:\liftarm at halfthickness)--cycle}
-\fi
-\fill[liftarm at color,even odd rule] \liftarm at shape
-\foreach\liftarm at n in {0,...,\liftarm at length}{
-(\liftarm at n,0) circle[radius=\liftarm at holeradius]
-};
-\ifliftarm at contour
-%\ifliftarm at brick
-%\else
-\draw[liftarm at color!75!Black,ultra thick] \liftarm at shape;
-%\fi
-\fi
-\ifcsname liftarm at axleholes\endcsname
-\foreach\liftarm at n in \liftarm at axleholes{
-\pgfmathsetmacro{\liftarm at axlehole}{\liftarm at n}
-\ifdim \liftarm at axlehole pt<0 pt
-\else
-\ifdim \liftarm at axlehole pt>\liftarm at length pt
-\else
-\foreach\liftarm at angle in {0,90,180,270}{
-\begin{scope}[shift={(\liftarm at axlehole,0)},rotate=\liftarm at angle]
-\fill[liftarm at color] (\liftarm at axleholeangle:\liftarm at axleholeradius) arc (\liftarm at axleholeangle:{90-\liftarm at axleholeangle}:\liftarm at axleholeradius)--({\liftarm at axleholeradius*sin(\liftarm at axleholeangle)},{\liftarm at axleholeradius*sin(\liftarm at axleholeangle)})--cycle;
-\end{scope}
-}
-\fi
-\fi
-}
-\fi
-\ifcsname liftarm at markholes\endcsname
-\foreach\liftarm at n in \liftarm at markholes{
-\pgfmathsetmacro{\liftarm at markhole}{\liftarm at n}
-\ifdim \liftarm at markhole pt<0 pt
-\else
-\ifdim \liftarm at markhole pt>\liftarm at length pt
-\else
-\fill[liftarm at markcolor] (\liftarm at markhole,0) circle[radius=\liftarm at holeradius];
-\fi
-\fi
-}
-\fi
-\ifcsname liftarm at screwholes\endcsname
-\foreach\liftarm at n in \liftarm at screwholes{
-\pgfmathsetmacro{\liftarm at screwhole}{\liftarm at n}
-\ifdim \liftarm at screwhole pt<0 pt
-\else
-\ifdim \liftarm at screwhole pt>\liftarm at length pt
-\else
-\begin{scope}[shift={(\liftarm at screwhole,0)},rotate=\liftarm at screwholesangle]
-\foreach\liftarm at n in {-1,1}{
-\fill[liftarm at screwcolor] ({\liftarm at screwholeradius*cos(\liftarm at screwholestartangle)},{\liftarm at n*\liftarm at screwholeradius*sin(\liftarm at screwholestartangle)}) arc ({\liftarm at n*\liftarm at screwholestartangle}:{\liftarm at n*(180-\liftarm at screwholestartangle)}:\liftarm at screwholeradius);
-}
-\end{scope}
-\fi
-\fi
-}
-\fi
-\ifcsname liftarm at coordinate\endcsname
-\foreach\liftarm at n/\liftarm at name in \liftarm at coordinate{
-\pgfmathsetmacro{\liftarm at value}{\liftarm at n}
-\coordinate (\liftarm at name) at (\liftarm at value,0);
-}
-\fi
-\ifcsname liftarm at trace\endcsname
-\ifliftarm at animate
-\foreach\liftarm at n/\liftarm at numberofframes/\liftarm at tracefigure in \liftarm at trace{
-\pgfmathsetmacro{\liftarm at value}{\liftarm at n}
-\gappto\liftarm at animateframestrace{\newframe\begin{scope}}
-\addtocounter{liftarm at animateframenumber}{1}
-\xappto\liftarm at animateframestrace{[shift={(#2)},rotate=\liftarm at ang]}
-\gappto\liftarm at animateframestrace{\begin{scope}}
-\xappto\liftarm at animateframestrace{[shift={(\liftarm at value-\liftarm at origin,0)}]}
-\ifdefempty{\liftarm at tracefigure}{
-\gappto\liftarm at animateframestrace{\fill[Black] (0,0) circle}
-\xappto\liftarm at animateframestrace{[radius=0.66*\liftarm at holeradius];}
-}
-{
-\xappto\liftarm at animateframestrace{\expandonce\liftarm at tracefigure}
-}
-\gappto\liftarm at animateframestrace{\end{scope}\end{scope}}
-\ifdefempty{\liftarm at numberofframes}{
-\csxappto{liftarm at animatetimeline0}{\theliftarm at animateframenumber x0,}
-}
-{
-\csxappto{liftarm at animatetimeline\theliftarm at animatestepnumber}{\theliftarm at animateframenumber x\liftarm at numberofframes,}
-}
-}
-\fi
-\fi
-\end{scope}
-\end{scope}
-\fi
-}
-\newcommand{\liftarmconnect}[5][]{
-\begin{scope}
-\pgfkeys{/liftarm,#1}
-\coordinate (liftarm at A) at (#2);
-\coordinate (liftarm at B) at (#4);
-\begin{scope}
-\pgfkeys{/liftarm,liftarm 1 options}
-\ifcsname liftarm at connect\endcsname
-\pgfmathsetmacro{\liftarm at connectlengthAtemp}{\liftarm at connect-\pgfkeysvalueof{/liftarm/origin}}
-\else
-\pgfmathsetmacro{\liftarm at connectlengthAtemp}{#3-\pgfkeysvalueof{/liftarm/origin}}
-\fi
-\xdef\liftarm at connectlengthA{\liftarm at connectlengthAtemp}
-\ifdim \liftarm at connectlengthA pt=0 pt
-\PackageWarning{liftarm}{The length of the first liftarm is 0.}
-\fi
-\end{scope}
-\begin{scope}
-\pgfkeys{/liftarm,liftarm 2 options}
-\ifcsname liftarm at connect\endcsname
-\pgfmathsetmacro{\liftarm at connectlengthBtemp}{\liftarm at connect-\pgfkeysvalueof{/liftarm/origin}}
-\else
-\pgfmathsetmacro{\liftarm at connectlengthBtemp}{#5-\pgfkeysvalueof{/liftarm/origin}}
-\fi
-\xdef\liftarm at connectlengthB{\liftarm at connectlengthBtemp}
-\ifdim \liftarm at connectlengthB pt=0 pt
-\PackageWarning{liftarm}{The length of the second liftarm is 0.}
-\fi
-\end{scope}
-\path
-let
-\p1=(liftarm at A),
-\p2=(liftarm at B),
-\n1={\x1/\pgf at xx},
-\n2={\y1/\pgf at yy},
-\n3={\x2/\pgf at xx},
-\n4={\y2/\pgf at yy}
-in
-[
-/liftarm/globalize={\liftarm at connectxalet}{\n3},
-/liftarm/globalize={\liftarm at connectyalet}{\n4},
-/liftarm/globalize={\liftarm at connectxblet}{\n1},
-/liftarm/globalize={\liftarm at connectyblet}{\n2}
-]
-;
-\pgfmathsetmacro{\liftarm at connectxa}{\liftarm at connectxalet}
-\pgfmathsetmacro{\liftarm at connectya}{\liftarm at connectyalet}
-\pgfmathsetmacro{\liftarm at connectxb}{\liftarm at connectxblet}
-\pgfmathsetmacro{\liftarm at connectyb}{\liftarm at connectyblet}
-\pgfmathsetmacro{\liftarm at absdiff}{abs(\liftarm at connectxa-\liftarm at connectxb)}
-\ifdim \liftarm at absdiff pt<0.001 pt
-\pgfmathsetmacro{\liftarm at connectanglegamma}{90}
-\ifdim \liftarm at connectya pt<\liftarm at connectyb pt
-\pgfmathsetmacro{\liftarm at connectangleshift}{0}
-\else
-\pgfmathsetmacro{\liftarm at connectangleshift}{180}
-\fi
-\else
-\pgfmathsetmacro{\liftarm at connectanglegamma}{atan((\liftarm at connectyb-\liftarm at connectya)/(\liftarm at connectxb-\liftarm at connectxa))}
-\ifdim \liftarm at connectxa pt<\liftarm at connectxb pt
-\pgfmathsetmacro{\liftarm at connectangleshift}{0}
-\else
-\pgfmathsetmacro{\liftarm at connectangleshift}{180}
-\fi
-\fi
-\pgfmathsetmacro{\liftarm at connectlength}{sqrt((\liftarm at connectyb-\liftarm at connectya)^2+(\liftarm at connectxb-\liftarm at connectxa)^2)}
-\ifdim \liftarm at connectlength pt=0 pt
-\PackageWarning{liftarm}{The length between the origins of the liftarms is 0.}
-\fi
-\pgfmathsetmacro{\liftarm at connectabsconnectlengthAminusconnectlengthB}{abs(\liftarm at connectlengthA-\liftarm at connectlengthB)}
-\ifdim \liftarm at connectabsconnectlengthAminusconnectlengthB pt>\liftarm at connectlength pt
-\PackageWarning{liftarm}{The liftarms can not be connected.}
-\fi
-\pgfmathsetmacro{\liftarm at connectconnectlengthAplusconnectlengthB}{\liftarm at connectlengthA+\liftarm at connectlengthB}
-\ifdim \liftarm at connectconnectlengthAplusconnectlengthB pt<\liftarm at connectlength pt
-\PackageWarning{liftarm}{The liftarms can not be connected.}
-\fi
-\pgfmathsetmacro{\liftarm at connectanglealpha}{acos(((\liftarm at connectlengthB)^2+(\liftarm at connectlength)^2-(\liftarm at connectlengthA)^2)/(2*(\liftarm at connectlength)*(\liftarm at connectlengthB)))}
-\pgfmathsetmacro{\liftarm at connectanglebeta}{acos(((\liftarm at connectlength)^2+(\liftarm at connectlengthA)^2-(\liftarm at connectlengthB)^2)/(2*\liftarm at connectlength*(\liftarm at connectlengthA)))}
-\pgfmathsetmacro{\liftarm at connectangledelta}{\liftarm at connectangleshift+180+\liftarm at connectanglegamma-\liftarm at connectanglebeta}
-\def\liftarm at liftarmA{\liftarm[liftarm 1 options]{#2}{#3}{\liftarm at connectangledelta}}
-\def\liftarm at liftarmB{\liftarm[liftarm 2 options]{#4}{#5}{\liftarm at connectangleshift+\liftarm at connectanglegamma+\liftarm at connectanglealpha}}
-\ifliftarm at connectreverse
-\liftarm at liftarmB
-\liftarm at liftarmA
-\else
-\liftarm at liftarmA
-\liftarm at liftarmB
-\fi
-\ifcsname liftarm at connectcoordinate\endcsname
-\coordinate (\liftarm at connectcoordinate) at ($(#2)+(\liftarm at connectangledelta:\liftarm at connectlengthA)$);
-\fi
-\end{scope}
-}
-\newcommand{\liftarm at construction}[2][]{\begin{tikzpicture}[#1]
-\liftarm at constructfigure
-#2
-\end{tikzpicture}}
-\newcommand{\liftarmconstruct}[3][]{\item #2\nopagebreak
+\ProvidesExplPackage{liftarm}{2024/05/20}{3.0}{Geometric constructions with liftarms using TikZ and LaTeX3}
-\gappto\liftarm at constructfigure{#3}
-\expandafter\liftarm at construction\expandafter[\liftarm at constructoptions]{#1}
-}
-\newenvironment{liftarmconstruction}[1][]{\def\liftarm at constructoptions{#1}\def\liftarm at constructfigure{}\begin{enumerate}}{\end{enumerate}}
-\newcounter{liftarm at animatenumberofsteps}
-\newcounter{liftarm at animateframenumber}
-\newcounter{liftarm at animatestepnumber}
-\newwrite\liftarm at animatewritetimeline
-\newcounter{liftarm at animatenumberofanimation}
-\newcommand{\liftarmanimate}[4][]{%
-\liftarm at animatetrue%
-\addtocounter{liftarm at animatenumberofanimation}{1}%
-\setcounter{liftarm at animatenumberofsteps}{-1}%
-\gdef\liftarm at animateframes{}%
-\gdef\liftarm at animateframestrace{}%
-\setcounter{liftarm at animatestepnumber}{-1}%
-\foreach\liftarm at n in {#3}{%
-\addtocounter{liftarm at animatenumberofsteps}{1}%
-\gappto\liftarm at animateframes{\newframe\addtocounter{liftarm at animatestepnumber}{1}#4}%
-\xappto\liftarm at animateframes{{\liftarm at n}}%
-}%
-\patchcmd{\liftarm at animateframes}{\newframe}{}{}{}%
-\csgdef{liftarm at animatetimeline0}{c,}%
-\foreach\liftarm at n in {1,...,\theliftarm at animatenumberofsteps}{%
-\csgdef{liftarm at animatetimeline\liftarm at n}{}%
-}%
-\setcounter{liftarm at animateframenumber}{\theliftarm at animatenumberofsteps}%
-\IfFileExists{\jobname\theliftarm at animatenumberofanimation.tln}{}{%
-\immediate\openout\liftarm at animatewritetimeline=\jobname\theliftarm at animatenumberofanimation.tln%
-\immediate\write\liftarm at animatewritetimeline{::c,0}%
-\immediate\closeout\liftarm at animatewritetimeline%
-}%
-\begin{animateinline}[#1,timeline=\jobname\theliftarm at animatenumberofanimation.tln]{#2}%
-\liftarm at animateframes%
-\liftarm at animateframestrace%
-\end{animateinline}%
-\immediate\openout\liftarm at animatewritetimeline=\jobname\theliftarm at animatenumberofanimation.tln%
-\foreach\liftarm at n in {0,...,\theliftarm at animatenumberofsteps}{%
-\immediate\write\liftarm at animatewritetimeline{::\csname liftarm at animatetimeline\liftarm at n\endcsname\liftarm at n}%
-}%
-\immediate\closeout\liftarm at animatewritetimeline%
-\liftarm at animatefalse%
-}
+%%> \subsection{Variables}
+
+\newcounter { g__liftarm_animate_frame_number_counter }
+\newcounter { g__liftarm_animate_number_of_animation_counter }
+\newcounter { g__liftarm_animate_number_of_steps_counter }
+\newcounter { g__liftarm_animate_step_number_counter }
+
+\bool_new:N \l__liftarm_animate_bool
+\bool_new:N \l__liftarm_brick_bool
+\bool_new:N \l__liftarm_contour_bool
+\bool_new:N \l__liftarm_LU_bool
+
+\clist_new:N \l__liftarm_trace_clist
+
+\fp_new:N \l__liftarm_angle_fp
+\fp_const:Nn \c__liftarm_axle_hole_angle_fp { 21.76702028497987 }%asind ( 1.78 / ( 16 * 0.3 ) )
+\fp_new:N \l__liftarm_connect_det_fp
+\fp_new:N \l__liftarm_connect_norm_fp
+\fp_new:N \l__liftarm_connect_start_constant_x_fp
+\fp_new:N \l__liftarm_connect_start_constant_y_fp
+\fp_new:N \l__liftarm_connect_stop_value_fp
+\fp_new:c { l__liftarm_connect_two_1_option_0_angle_fp }
+\fp_new:c { l__liftarm_connect_two_1_option_1_angle_fp }
+\fp_new:c { l__liftarm_connect_two_2_option_0_angle_fp }
+\fp_new:c { l__liftarm_connect_two_2_option_1_angle_fp }
+\fp_new:N \l__liftarm_connect_two_angle_fp
+\fp_new:N \l__liftarm_connect_two_A_angle_fp
+\fp_new:N \l__liftarm_connect_two_A_length_fp
+\fp_new:N \l__liftarm_connect_two_A_x_fp
+\fp_new:N \l__liftarm_connect_two_A_y_fp
+\fp_new:N \l__liftarm_connect_two_B_angle_fp
+\fp_new:N \l__liftarm_connect_two_B_length_fp
+\fp_new:N \l__liftarm_connect_two_B_x_fp
+\fp_new:N \l__liftarm_connect_two_B_y_fp
+\fp_new:N \l__liftarm_connect_two_length_fp
+\fp_new:N \g__liftarm_coord_x_fp
+\fp_new:N \g__liftarm_coord_y_fp
+\fp_new:N \l__liftarm_half_thickness_fp
+\fp_new:N \l__liftarm_hole_radius_fp
+\fp_new:N \l__liftarm_length_fp
+\fp_new:N \l__liftarm_LU_maxA_fp
+\fp_new:N \l__liftarm_LU_tmp_fp
+\fp_new:N \l__liftarm_mark_radius_fp
+\fp_new:N \l__liftarm_origin_fp
+\fp_new:N \l__liftarm_origin_connect_initial_fp
+\fp_new:N \l__liftarm_scalefactor_fp
+\fp_new:N \l__liftarm_screw_angle_fp
+\fp_new:N \l__liftarm_screw_radius_fp
+
+\int_new:N \l__liftarm_connect_count_int
+\int_new:N \l__liftarm_connect_equation_int
+\int_new:N \l__liftarm_LU_count_int
+\int_new:N \l__liftarm_LU_imax_int
+\int_new:N \l__liftarm_LU_j_int
+\int_new:N \l__liftarm_LU_N_int
+
+\iow_new:N \g__liftarm_animate_write_timeline_iow
+
+\seq_new:N \l__liftarm_connect_coordinate_seq
+\seq_new:N \l__liftarm_connect_start_arg_seq
+\seq_new:N \l__liftarm_connect_start_coeff_seq
+\seq_new:N \l__liftarm_coordinate_seq
+\seq_new:N \l__liftarm_trace_item_seq
+
+\str_new:N \l__liftarm_connect_stop_type_str
+\str_new:N \l__liftarm_type_str
+
+\tl_new:N \g__liftarm_animate_frames_tl
+\tl_new:N \g__liftarm_animate_frames_trace_tl
+\tl_new:N \l__liftarm_animate_value_tl
+\tl_new:N \l__liftarm_color_tl
+\tl_new:N \g__liftarm_construct_tl
+\tl_const:Nn \c__liftarm_cos_sin_diff_x_tl { - sin }
+\tl_const:Nn \c__liftarm_cos_sin_diff_y_tl { cos }
+\tl_const:Nn \c__liftarm_cos_sin_x_tl { cos }
+\tl_const:Nn \c__liftarm_cos_sin_y_tl { sin }
+\tl_new:N \l__liftarm_holes_tl
+\tl_new:N \l__liftarm_shape_tl
+\tl_new:N \l__liftarm_tmp_tl
+
+%%> \subsection{Pgfkeys}
+
+\pgfkeys
+ {
+ / liftarm /. is~family ,
+ / liftarm ,
+ axle~holes /. initial = {} ,
+ brick /. code = { \bool_set:Nn \l__liftarm_brick_bool { \cs:w c_#1_bool\cs_end: } } ,
+ brick /. default = true ,
+ brick = false ,
+ color /. code~2~args =
+ {
+ \tl_clear_new:c { l__liftarm_color_\int_eval:n {#1}_tl }
+ \tl_set:cn { l__liftarm_color_\int_eval:n {#1}_tl } {#2}
+ } ,
+ color = { 0 } { Gray } ,
+ color = { 1 } { darkgray } ,
+ color = { 2 } { Yellow } ,
+ color = { 3 } { Orange } ,
+ color = { 4 } { Red } ,
+ color = { 5 } { Green } ,
+ color = { 6 } { Blue } ,
+ color = { 7 } { Brown } ,
+ color~modulo /. initial = 8 ,
+ connect~stop /. is~choice ,
+ connect~stop / 1-norm /. code =
+ {
+ \str_set:Nn \l__liftarm_connect_stop_type_str { 1-norm }
+ \fp_set:Nn \l__liftarm_connect_stop_value_fp {#1}
+ } ,
+ connect~stop / 1-norm /. default = 0.001 ,
+ connect~stop / 2-norm /. code =
+ {
+ \str_set:Nn \l__liftarm_connect_stop_type_str { 2-norm }
+ \fp_set:Nn \l__liftarm_connect_stop_value_fp {#1}
+ } ,
+ connect~stop / 2-norm /. default = 0.001 ,
+ connect~stop / iterations /. code =
+ {
+ \str_set:Nn \l__liftarm_connect_stop_type_str { iterations }
+ \fp_set:Nn \l__liftarm_connect_stop_value_fp {#1}
+ } ,
+ connect~stop / iterations /. default = 10 ,
+ connect~stop = 1-norm ,
+ contour /. code = { \bool_set:Nn \l__liftarm_contour_bool { \cs:w c_#1_bool\cs_end: } } ,
+ contour /. default = true ,
+ contour = false ,
+ contour~style /. style = { contour_style /. style = {#1} } ,
+ contour_style /. style = {} ,
+ coordinate /. initial = {} ,
+ hole~radius /. initial = 0.3 ,
+ liftarm~style /. style = { liftarm_style /. style = {#1} } ,
+ liftarm_style /. style = {} ,
+ liftarm~thickness /. initial = 0.92 ,
+ mark~holes /. initial = {} ,
+ mark~radius /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_mark_radius_fp { \pgfmathresult }
+ } ,
+ mark~radius = 1 ,
+ mark~style /. style = { mark_style /. style = {#1} } ,
+ mark_style /. style = {} ,
+ origin /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_origin_fp { \pgfmathresult }
+ } ,
+ origin = 0 ,
+ scalefactor /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_scalefactor_fp { \pgfmathresult }
+ } ,
+ scalefactor = 0.5 ,
+ screw~angle /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_screw_angle_fp { \pgfmathresult }
+ } ,
+ screw~angle = 10 ,
+ screw~holes /. initial = {} ,
+ screw~radius /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_screw_radius_fp { \pgfmathresult }
+ } ,
+ screw~radius = 0.8 ,
+ screw~style /. style = { screw_style /. style = {#1} } ,
+ screw_style /. style = {} ,
+ trace /. code = { \clist_set:Nn \l__liftarm_trace_clist {#1} } ,
+ type /. is~choice ,
+ type / liftarm /. code = { \str_set:Nn \l__liftarm_type_str { liftarm } } ,
+ type / liftarm /. value~forbidden ,
+ type / line~segment /. code = { \str_set:Nn \l__liftarm_type_str { line~segment } } ,
+ type / line~segment /. value~forbidden ,
+ type = liftarm ,
+ }
+
+\pgfkeys
+ {
+ / liftarm / connect_algorithm /. is~family ,
+ / liftarm / connect_algorithm /. unknown /. code = {} ,
+ / liftarm / connect_algorithm ,
+ coordinate /. initial = {} ,
+ origin /. code =
+ {
+ \pgfmathparse {#1}
+ \fp_set:Nn \l__liftarm_origin_fp { \pgfmathresult }
+ } ,
+ }
+
+%%> \subsection{Functions}
+
+\cs_generate_variant:Nn \clist_if_in:nnTF { enTF }
+\cs_generate_variant:Nn \clist_map_inline:nn { en }
+\cs_generate_variant:Nn \seq_map_indexed_inline:Nn { cn }
+\cs_generate_variant:Nn \tl_build_begin:N { c }
+\cs_generate_variant:Nn \tl_build_gbegin:N { c }
+\cs_generate_variant:Nn \tl_build_end:N { c }
+\cs_generate_variant:Nn \tl_build_gend:N { c }
+\cs_generate_variant:Nn \tl_build_put_right:Nn { ce , cn }
+\cs_generate_variant:Nn \tl_build_gput_right:Nn { ce , cn }
+
+\cs_new_protected:Npn \__liftarm_connect:nnnn #1#2#3#4
+ {
+ \int_incr:N \l__liftarm_connect_count_int
+ \fp_zero_new:c { l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp }
+ \pgfmathparse {#4}
+ \fp_set:cn { l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp } { \pgfmathresult * deg }
+ \fp_set_eq:NN \l__liftarm_origin_fp \l__liftarm_origin_connect_initial_fp
+ \pgfkeys
+ {
+ / liftarm / connect_algorithm ,
+ coordinate = \pgfkeysvalueof { / liftarm / coordinate } ,
+ #1
+ }
+ \seq_if_in:NnTF \l__liftarm_connect_coordinate_seq {#2}
+ {
+ \fp_set_eq:Nc \l__liftarm_connect_start_constant_x_fp { l__liftarm_connect_constant_x_coord_#2_fp }
+ \fp_set_eq:Nc \l__liftarm_connect_start_constant_y_fp { l__liftarm_connect_constant_y_coord_#2_fp }
+ \seq_set_eq:Nc \l__liftarm_connect_start_arg_seq { l__liftarm_connect_arg_coord_#2_seq }
+ \seq_set_eq:Nc \l__liftarm_connect_start_coeff_seq { l__liftarm_connect_coeff_coord_#2_seq }
+ }
+ {
+ \__liftarm_def_coord:n {#2}
+ \fp_set_eq:NN \l__liftarm_connect_start_constant_x_fp \g__liftarm_coord_x_fp
+ \fp_set_eq:NN \l__liftarm_connect_start_constant_y_fp \g__liftarm_coord_y_fp
+ \seq_clear:N \l__liftarm_connect_start_arg_seq
+ \seq_clear:N \l__liftarm_connect_start_coeff_seq
+ }
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / connect_algorithm / coordinate } }
+ {
+ \seq_set_split:Nnn \l__liftarm_coordinate_seq { / } {##1}
+ \pgfmathparse { \seq_item:Nn \l__liftarm_coordinate_seq { 1 } }
+ \fp_set:Nn \l__liftarm_length_fp { \pgfmathresult - \l__liftarm_origin_fp }
+ \seq_if_in:NeTF \l__liftarm_connect_coordinate_seq { \seq_item:Nn \l__liftarm_coordinate_seq { 2 } }
+ {
+ \clist_map_inline:nn { x , y }
+ {
+ \int_incr:N \l__liftarm_connect_equation_int
+ \tl_clear_new:c { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ \tl_build_begin:c { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \tl_clear_new:c { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########1_tl }
+ \tl_build_begin:c { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########1_tl }
+ \tl_build_put_right:cn { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########1_tl }
+ { 0 }
+ \fp_zero_new:c { l__liftarm_LU_A_\int_use:N \l__liftarm_connect_equation_int _########1_fp }
+ }
+ \tl_build_put_right:ce { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ {
+ \fp_use:c { l__liftarm_connect_constant_####1_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_fp }
+ - \fp_use:c { l__liftarm_connect_start_constant_####1_fp }
+ - \fp_use:N \l__liftarm_length_fp * \cs:w c__liftarm_cos_sin_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp \exp_not:N \cs_end: )
+ }
+ \tl_build_put_right:ce
+ {
+ l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _
+ \int_use:N \l__liftarm_connect_count_int _tl
+ }
+ {
+ - \fp_use:N \l__liftarm_length_fp * \cs:w c__liftarm_cos_sin_diff_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp \exp_not:N \cs_end: )
+ }
+ \seq_map_indexed_inline:cn { l__liftarm_connect_arg_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq }
+ {
+ \tl_build_put_right:ce { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ {
+ + \seq_item:cn { l__liftarm_connect_coeff_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq } {########1}
+ * \cs:w c__liftarm_cos_sin_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_########2_fp \exp_not:N \cs_end: )
+ }
+ \tl_build_put_right:ce { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########2_tl }
+ {
+ + \seq_item:cn { l__liftarm_connect_coeff_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq } {########1}
+ * \cs:w c__liftarm_cos_sin_diff_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_########2_fp \exp_not:N \cs_end: )
+ }
+ }
+ \seq_map_indexed_inline:Nn \l__liftarm_connect_start_arg_seq
+ {
+ \tl_build_put_right:ce { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ {
+ - \seq_item:Nn \l__liftarm_connect_start_coeff_seq {########1} * \cs:w c__liftarm_cos_sin_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_########2_fp \exp_not:N \cs_end: )
+ }
+ \tl_build_put_right:ce { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########2_tl }
+ {
+ - \seq_item:Nn \l__liftarm_connect_start_coeff_seq {########1} * \cs:w c__liftarm_cos_sin_diff_####1_tl\cs_end:
+ ( \exp_not:N \cs:w l__liftarm_connect_angle_########2_fp \exp_not:N \cs_end: )
+ }
+ }
+ \tl_build_end:c { l__liftarm_connect_F_\int_use:N \l__liftarm_connect_equation_int _tl }
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \tl_build_end:c { l__liftarm_connect_Jacobian_\int_use:N \l__liftarm_connect_equation_int _########1_tl } }
+ }
+ }
+ {
+ \clist_map_inline:nn { x , y }
+ {
+ \fp_zero_new:c { l__liftarm_connect_constant_####1_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_fp }
+ \fp_set_eq:cc { l__liftarm_connect_constant_####1_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_fp }
+ { l__liftarm_connect_start_constant_####1_fp }
+ }
+ \clist_map_inline:nn { arg , coeff }
+ {
+ \seq_clear_new:c { l__liftarm_connect_####1_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq }
+ \seq_set_eq:cc { l__liftarm_connect_####1_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq }
+ { l__liftarm_connect_start_####1_seq }
+ }
+ \seq_put_right:ce { l__liftarm_connect_arg_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq }
+ { \int_use:N \l__liftarm_connect_count_int }
+ \seq_put_right:ce { l__liftarm_connect_coeff_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_seq }
+ { \fp_use:N \l__liftarm_length_fp }
+ \seq_put_right:Ne \l__liftarm_connect_coordinate_seq { \seq_item:Nn \l__liftarm_coordinate_seq { 2 } }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__liftarm_connect_stop_criterion:
+ {
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_set:cn { l__liftarm_LU_b_##1_fp } { \cs:w l__liftarm_connect_F_##1_tl\cs_end: } }
+ \str_case:Vn \l__liftarm_connect_stop_type_str
+ {
+ { 1-norm }
+ {
+ \fp_zero:N \l__liftarm_connect_norm_fp
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_add:Nn \l__liftarm_connect_norm_fp { abs ( \cs:w l__liftarm_LU_b_##1_fp\cs_end: ) } }
+ \bool_set:Nn \l__liftarm_LU_bool
+ { \fp_compare_p:nNn { \l__liftarm_connect_norm_fp } > { \l__liftarm_connect_stop_value_fp } }
+ }
+ { 2-norm }
+ {
+ \fp_zero:N \l__liftarm_connect_norm_fp
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_add:Nn \l__liftarm_connect_norm_fp { ( \cs:w l__liftarm_LU_b_##1_fp\cs_end: ) ^ 2 } }
+ \bool_set:Nn \l__liftarm_LU_bool
+ { \fp_compare_p:nNn { sqrt ( \l__liftarm_connect_norm_fp ) } > { \l__liftarm_connect_stop_value_fp } }
+ }
+ { iterations }
+ {
+ \bool_set:Nn \l__liftarm_LU_bool
+ { \fp_compare_p:nNn { \l__liftarm_LU_count_int } < { \l__liftarm_connect_stop_value_fp } }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__liftarm_def_coord:n #1
+ {
+ \path let \p { l__liftarm_coord } = (#1) in
+ [
+ / utils / exec =
+ {
+ \fp_gset:Nn \g__liftarm_coord_x_fp
+ { ( \pgf at yy * \x { l__liftarm_coord } - \pgf at yx * \y { l__liftarm_coord } ) / \l__liftarm_connect_det_fp }
+ \fp_gset:Nn \g__liftarm_coord_y_fp
+ { ( \pgf at xx * \y { l__liftarm_coord } - \pgf at xy * \x { l__liftarm_coord } ) / \l__liftarm_connect_det_fp }
+ }
+ ] ;
+ }
+
+\cs_new_protected:Npn \__liftarm_default:nnnn #1#2#3#4
+ {
+ \pgfmathparse {#3}
+ \fp_set:Nn \l__liftarm_length_fp { \pgfmathresult }
+ \fp_compare:nNnTF { \l__liftarm_length_fp } < { 0 }
+ { \PackageWarning { liftarm } { The~length~( \fp_use:N \l__liftarm_length_fp )~of~the~liftarm~is~smaller~than~0. } }
+ {
+ \pgfmathparse {#4}
+ \fp_set:Nn \l__liftarm_angle_fp { \pgfmathresult }
+ \begin { scope }
+ [
+ shift = { (#2) } ,
+ rotate = \fp_use:N \l__liftarm_angle_fp
+ ]
+ \pgfkeys { / liftarm , #1 }
+ \tl_set:Ne \l__liftarm_color_tl
+ {
+ \cs:w
+ l__liftarm_color_
+ \int_mod:nn { \fp_eval:n { trunc ( \l__liftarm_length_fp , 0 ) } } { \pgfkeysvalueof { / liftarm / color~modulo } }_tl
+ \cs_end:
+ }
+ \begin { scope } [ shift = { ( - \fp_use:N \l__liftarm_origin_fp , 0 ) } ]
+ \str_case:Vn \l__liftarm_type_str
+ {
+ { liftarm }
+ {
+ \pgfmathparse { \pgfkeysvalueof { / liftarm / liftarm~thickness } }
+ \fp_set:Nn \l__liftarm_half_thickness_fp { 0.5 * \l__liftarm_scalefactor_fp * \pgfmathresult }
+ \pgfmathparse { \pgfkeysvalueof { / liftarm / hole~radius } }
+ \fp_set:Nn \l__liftarm_hole_radius_fp { \l__liftarm_scalefactor_fp * \pgfmathresult }
+ \bool_if:NTF \l__liftarm_brick_bool
+ {
+ \tl_build_begin:N \l__liftarm_shape_tl
+ \tl_build_put_right:Ne \l__liftarm_shape_tl
+ {
+ ( -1 , \fp_eval:n { - \l__liftarm_scalefactor_fp * 0.7 } )
+ -- ( -1 , \fp_eval:n { \l__liftarm_scalefactor_fp * 0.5 } )
+ }
+ \int_step_inline:nnn { -1 } { \fp_eval:n { trunc ( \l__liftarm_length_fp , 0 ) } }
+ {
+ \tl_build_put_right:Ne \l__liftarm_shape_tl
+ {
+ -- (
+ \fp_eval:n { ##1 + 0.5 - \l__liftarm_scalefactor_fp * 0.3 } ,
+ \fp_eval:n { \l__liftarm_scalefactor_fp * 0.5 }
+ )
+ --++ ( 0 , \fp_eval:n { \l__liftarm_scalefactor_fp * 0.2 } )
+ --++ ( \fp_eval:n { \l__liftarm_scalefactor_fp * 0.6 } , 0 )
+ --++ ( 0 , \fp_eval:n { - \l__liftarm_scalefactor_fp * 0.2 } )
+ }
+ }
+ \tl_build_put_right:Ne \l__liftarm_shape_tl
+ {
+ -- ( \fp_eval:n { \l__liftarm_length_fp + 1 } , \fp_eval:n { \l__liftarm_scalefactor_fp * 0.5 } )
+ --++ ( 0 , \fp_eval:n { - \l__liftarm_scalefactor_fp * 1.2 } )
+ -- cycle
+ }
+ \tl_build_end:N \l__liftarm_shape_tl
+ }
+ {
+ \tl_set:Ne \l__liftarm_shape_tl
+ {
+ ( 0 , \fp_use:N \l__liftarm_half_thickness_fp )
+ arc
+ [
+ start~angle = 90 ,
+ end~angle = 270 ,
+ radius = \fp_use:N \l__liftarm_half_thickness_fp
+ ]
+ -- ( \fp_use:N \l__liftarm_length_fp , - \fp_use:N \l__liftarm_half_thickness_fp )
+ arc
+ [
+ start~angle = -90 ,
+ end~angle = 90 ,
+ radius = \fp_use:N \l__liftarm_half_thickness_fp
+ ]
+ -- cycle
+ }
+ }
+ \tl_build_begin:N \l__liftarm_holes_tl
+ \int_step_inline:nnn { 0 } { \fp_eval:n { trunc ( \l__liftarm_length_fp , 0 ) } }
+ {
+ \clist_if_in:enTF { \pgfkeysvalueof { / liftarm / axle~holes } } {##1}
+ {
+ \int_step_inline:nn { 4 }
+ {
+ \tl_build_put_right:Ne \l__liftarm_holes_tl
+ {
+ (
+ \fp_eval:n
+ {
+ ##1 + sqrt ( 2 ) * \l__liftarm_hole_radius_fp * sind ( \c__liftarm_axle_hole_angle_fp )
+ * cosd ( ####1 * 90 - 45 )
+ } ,
+ \fp_eval:n { sqrt ( 2 ) * \l__liftarm_hole_radius_fp * sind ( \c__liftarm_axle_hole_angle_fp )
+ * sind ( ####1 * 90 - 45 ) }
+ )
+ -- (
+ \fp_eval:n
+ {
+ ##1
+ + \l__liftarm_hole_radius_fp * cosd ( ####1 * 90 - \c__liftarm_axle_hole_angle_fp )
+ } ,
+ \fp_eval:n { \l__liftarm_hole_radius_fp * sind ( ####1 * 90 - \c__liftarm_axle_hole_angle_fp ) }
+ )
+ arc
+ [
+ start~angle = \fp_eval:n { ####1 * 90 - \c__liftarm_axle_hole_angle_fp } ,
+ end~angle = \fp_eval:n { ####1 * 90 + \c__liftarm_axle_hole_angle_fp } ,
+ radius = \fp_use:N \l__liftarm_hole_radius_fp
+ ]
+ --
+ }
+ }
+ \tl_build_put_right:Nn \l__liftarm_holes_tl { cycle }
+ }
+ {
+ \tl_build_put_right:Ne \l__liftarm_holes_tl
+ { ( ##1 , 0 ) circle [ radius = \fp_use:N \l__liftarm_hole_radius_fp ] }
+ }
+ }
+ \tl_build_end:N \l__liftarm_holes_tl
+ \fill [ \l__liftarm_color_tl , even~odd~rule , / liftarm / liftarm_style ]
+ \l__liftarm_shape_tl \l__liftarm_holes_tl ;
+ \bool_if:NT \l__liftarm_contour_bool
+ { \draw [ \l__liftarm_color_tl ! 75 ! black , ultra~thick , / liftarm / contour_style ] \l__liftarm_shape_tl ; }
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / mark~holes } }
+ {
+ \fill [ black , / liftarm / mark_style ]
+ ( {##1} , 0 ) circle [ radius = \fp_eval:n { \l__liftarm_mark_radius_fp * \l__liftarm_hole_radius_fp } ] ;
+ }
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / screw~holes } }
+ {
+ \clist_map_inline:nn { -1 , 1 }
+ {
+ \fill [ black , shift = { ( {##1} , 0 ) } , rotate = 45 , / liftarm / screw_style ]
+ (
+ \fp_eval:n { ####1 * \l__liftarm_screw_angle_fp }
+ \c_colon_str
+ \fp_eval:n { \l__liftarm_screw_radius_fp * \l__liftarm_hole_radius_fp }
+ )
+ arc
+ [
+ start~angle = \fp_eval:n { ####1 * \l__liftarm_screw_angle_fp } ,
+ end~angle = \fp_eval:n { ####1 * ( 180 - \l__liftarm_screw_angle_fp ) } ,
+ radius = \fp_eval:n { \l__liftarm_screw_radius_fp * \l__liftarm_hole_radius_fp }
+ ]
+ ;
+ }
+ }
+ }
+ { line~segment }
+ {
+ \draw [ \l__liftarm_color_tl , / liftarm / liftarm_style ] ( 0 , 0 ) -- ( \fp_use:N \l__liftarm_length_fp , 0 ) ;
+ }
+ }
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / coordinate } }
+ {
+ \seq_set_split:Nnn \l__liftarm_coordinate_seq { / } {##1}
+ \coordinate ( \seq_item:Nn \l__liftarm_coordinate_seq { 2 } )
+ at ( { \seq_item:Nn \l__liftarm_coordinate_seq { 1 } } , 0 ) ;
+ }
+ \bool_if:NT \l__liftarm_animate_bool
+ {
+ \clist_map_inline:Nn \l__liftarm_trace_clist
+ {
+ \seq_set_split:Nnn \l__liftarm_trace_item_seq { / } {##1}
+ \stepcounter { g__liftarm_animate_frame_number_counter }
+ \tl_build_gput_right:Ne \g__liftarm_animate_frames_trace_tl
+ {
+ \exp_not:n { \newframe \begin } { scope }
+ [ shift = { (#2) } , rotate = \fp_use:N \l__liftarm_angle_fp ]
+ \exp_not:N \begin { scope }
+ [ shift = { ( \fp_eval:n { \seq_item:Nn \l__liftarm_trace_item_seq { 1 } - \l__liftarm_origin_fp } , 0 ) } ]
+ \tl_if_empty:eTF { \seq_item:Nn \l__liftarm_trace_item_seq { 3 } }
+ {
+ \exp_not:N \fill
+ [ black ] ( 0 , 0 ) circle [ radius = \fp_eval:n { \l__liftarm_hole_radius_fp * 2 / 3 } ] ;
+ }
+ { \seq_item:Nn \l__liftarm_trace_item_seq { 3 } }
+ \exp_not:n { \end { scope } \end { scope } }
+ }
+ \tl_if_empty:eTF { \seq_item:Nn \l__liftarm_trace_item_seq { 2 } }
+ {
+ \tl_build_gput_right:ce { g__liftarm_animate_timeline_0_tl }
+ { \theg__liftarm_animate_frame_number_counter x 0 , }
+ }
+ {
+ \pgfmathparse { \use:e { \seq_item:Nn \l__liftarm_trace_item_seq { 2 } } }
+ \tl_build_gput_right:ce { g__liftarm_animate_timeline_\theg__liftarm_animate_step_number_counter _tl }
+ { \theg__liftarm_animate_frame_number_counter x \fp_eval:n { \pgfmathresult } , }
+ }
+ }
+ }
+ \end { scope }
+ \end { scope }
+ }
+ }
+
+\cs_new_protected:Npn \__liftarm_LU_decomposition:
+ {
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \int_zero_new:c { l__liftarm_LU_P_##1_int }
+ \int_set:cn { l__liftarm_LU_P_##1_int } {##1}
+ }
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \fp_zero:N \l__liftarm_LU_maxA_fp
+ \int_set:Nn \l__liftarm_LU_imax_int {##1}
+ \int_step_inline:nnn {##1} { \l__liftarm_LU_N_int }
+ {
+ \fp_set:Nn \l__liftarm_LU_tmp_fp { abs ( \cs:w l__liftarm_LU_A_####1_##1_fp\cs_end: ) }
+ \fp_compare:nNnT { \l__liftarm_LU_tmp_fp } > { \l__liftarm_LU_maxA_fp }
+ {
+ \fp_set_eq:NN \l__liftarm_LU_maxA_fp \l__liftarm_LU_tmp_fp
+ \int_set:Nn \l__liftarm_LU_imax_int {####1}
+ }
+ }
+ \int_compare:nNnF { \l__liftarm_LU_imax_int } = {##1}
+ {
+ \int_set_eq:Nc \l__liftarm_LU_j_int { l__liftarm_LU_P_##1_int }
+ \int_set_eq:cc { l__liftarm_LU_P_##1_int } { l__liftarm_LU_P_\int_use:N \l__liftarm_LU_imax_int _int }
+ \int_set_eq:cN { l__liftarm_LU_P_\int_use:N \l__liftarm_LU_imax_int _int } \l__liftarm_LU_j_int
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \fp_set_eq:Nc \l__liftarm_LU_tmp_fp { l__liftarm_LU_A_##1_####1_fp }
+ \fp_set_eq:cc { l__liftarm_LU_A_##1_####1_fp } { l__liftarm_LU_A_\int_use:N \l__liftarm_LU_imax_int _####1_fp }
+ \fp_set_eq:cN { l__liftarm_LU_A_\int_use:N \l__liftarm_LU_imax_int _####1_fp } \l__liftarm_LU_tmp_fp
+ }
+ }
+ \int_step_inline:nnn { ##1 + 1 } { \l__liftarm_LU_N_int }
+ {
+ \fp_set:cn { l__liftarm_LU_A_####1_##1_fp }
+ { \cs:w l__liftarm_LU_A_####1_##1_fp\cs_end: / \cs:w l__liftarm_LU_A_##1_##1_fp\cs_end: }
+ \int_step_inline:nnn { ##1 + 1 } { \l__liftarm_LU_N_int }
+ {
+ \fp_sub:cn { l__liftarm_LU_A_####1_########1_fp }
+ { \cs:w l__liftarm_LU_A_####1_##1_fp\cs_end: * \cs:w l__liftarm_LU_A_##1_########1_fp\cs_end: }
+ }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__liftarm_LU_solve:
+ {
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \fp_zero_new:c { l__liftarm_LU_x_##1_fp }
+ \fp_set_eq:cc { l__liftarm_LU_x_##1_fp } { l__liftarm_LU_b_\int_use:c { l__liftarm_LU_P_##1_int }_fp }
+ \int_step_inline:nn { ##1 - 1 }
+ {
+ \fp_sub:cn { l__liftarm_LU_x_##1_fp }
+ { \cs:w l__liftarm_LU_A_##1_####1_fp\cs_end: * \cs:w l__liftarm_LU_x_####1_fp\cs_end: }
+ }
+ }
+ \int_step_inline:nnnn { \l__liftarm_LU_N_int } { -1 } { 1 }
+ {
+ \int_step_inline:nnn { ##1 + 1 } { \l__liftarm_LU_N_int }
+ {
+ \fp_sub:cn { l__liftarm_LU_x_##1_fp }
+ { \cs:w l__liftarm_LU_A_##1_####1_fp\cs_end: * \cs:w l__liftarm_LU_x_####1_fp\cs_end: }
+ }
+ \fp_set:cn { l__liftarm_LU_x_##1_fp } { \cs:w l__liftarm_LU_x_##1_fp\cs_end: / \cs:w l__liftarm_LU_A_##1_##1_fp\cs_end: }
+ }
+ }
+
+\cs_new:Npn \__liftarm_Mod:nn #1#2
+ {
+ min
+ (
+ Mod
+ (
+ \fp_eval:n { \cs:w l__liftarm_connect_two_#1_option_#2_angle_fp\cs_end: - \cs:w l__liftarm_connect_angle_#1_fp\cs_end: } ,
+ 360
+ ) ,
+ Mod
+ (
+ \fp_eval:n { \cs:w l__liftarm_connect_angle_#1_fp\cs_end: - \cs:w l__liftarm_connect_two_#1_option_#2_angle_fp\cs_end: } ,
+ 360
+ )
+ )
+ }
+
+%%> \subsection{Document commands and environment}
+
+\NewDocumentCommand \liftarm { O {} m m m }
+ { \__liftarm_default:nnnn {#1} {#2} {#3} {#4} }
+
+\NewDocumentCommand \liftarmanimate { O {} m m m }
+ {
+ \bool_set_true:N \l__liftarm_animate_bool
+ \stepcounter { g__liftarm_animate_number_of_animation_counter }
+ \setcounter { g__liftarm_animate_number_of_steps_counter } { -1 }
+ \tl_build_gbegin:N \g__liftarm_animate_frames_tl
+ \tl_build_gbegin:N \g__liftarm_animate_frames_trace_tl
+ \setcounter { g__liftarm_animate_step_number_counter } { -1 }
+ \foreach \l__liftarm_animate_value_tl in {#3}
+ {
+ \stepcounter { g__liftarm_animate_number_of_steps_counter }
+ \tl_build_gput_right:Ne \g__liftarm_animate_frames_tl
+ {
+ \exp_not:n { \newframe \stepcounter { g__liftarm_animate_step_number_counter } #4 }
+ { \l__liftarm_animate_value_tl }
+ }
+ }
+ \tl_build_gend:N \g__liftarm_animate_frames_tl
+ \int_step_inline:nnn { 0 } { \theg__liftarm_animate_number_of_steps_counter }
+ {
+ \tl_clear_new:c { g__liftarm_animate_timeline_##1_tl }
+ \tl_build_gbegin:c { g__liftarm_animate_timeline_##1_tl }
+ }
+ \tl_build_gput_right:cn { g__liftarm_animate_timeline_0_tl } { c , }
+ \setcounter { g__liftarm_animate_frame_number_counter } { \theg__liftarm_animate_number_of_steps_counter }
+ \file_if_exist:nF { \c_sys_jobname_str \theg__liftarm_animate_number_of_animation_counter . tln }
+ {
+ \iow_open:Nn \g__liftarm_animate_write_timeline_iow
+ { \c_sys_jobname_str \theg__liftarm_animate_number_of_animation_counter . tln }
+ \iow_now:Ne \g__liftarm_animate_write_timeline_iow { \c_colon_str \c_colon_str c , 0 }
+ \iow_close:N \g__liftarm_animate_write_timeline_iow
+ }
+ \begin { animateinline } [ #1 , timeline = \c_sys_jobname_str \theg__liftarm_animate_number_of_animation_counter . tln ] {#2}
+ \tl_tail:N \g__liftarm_animate_frames_tl%remove the first \newframe
+ \tl_build_gend:N \g__liftarm_animate_frames_trace_tl
+ \g__liftarm_animate_frames_trace_tl
+ \end { animateinline }
+ \iow_open:Nn \g__liftarm_animate_write_timeline_iow { \c_sys_jobname_str \theg__liftarm_animate_number_of_animation_counter . tln }
+ \int_step_inline:nnn { 0 } { \theg__liftarm_animate_number_of_steps_counter }
+ {
+ \tl_build_gend:c { g__liftarm_animate_timeline_##1_tl }
+ \iow_now:Ne \g__liftarm_animate_write_timeline_iow
+ { \c_colon_str \c_colon_str \cs:w g__liftarm_animate_timeline_##1_tl\cs_end: ##1 }
+ }
+ \iow_close:N \g__liftarm_animate_write_timeline_iow
+ \bool_set_false:N \l__liftarm_animate_bool
+ }
+
+\NewDocumentCommand \liftarmconstruct { m }
+ {
+ \tl_gput_right:Nn \g__liftarm_construct_tl {#1}
+ \g__liftarm_construct_tl
+ }
+
+\NewDocumentCommand \liftarmconstructclear {}
+ { \tl_gclear:N \g__liftarm_construct_tl }
+
+\NewDocumentEnvironment { liftarmconnect } { O {} +b }
+ {
+ \pgfkeys { / liftarm , #1 }
+ %verify that the contents consists only of commands \liftarm because the contents of this environment are processed several times
+ \DeclareExpandableDocumentCommand \liftarm { O {} m m m } {}%expandable for usage in \tl_set:Ne
+ \tl_set:Ne \l__liftarm_tmp_tl {#2}
+ \tl_remove_all:Nn \l__liftarm_tmp_tl { \par }
+ \tl_if_blank:VF \l__liftarm_tmp_tl
+ { \PackageError { liftarm } { The~environment~liftarmconnect~should~only~consist~of~commands~\protect \liftarm } {} }
+ \int_zero:N \l__liftarm_LU_N_int
+ \RenewDocumentCommand \liftarm { O {} m m m } { \int_incr:N \l__liftarm_LU_N_int }
+ #2
+ \fp_set:Nn \l__liftarm_connect_det_fp { \pgf at yy * \pgf at xx - \pgf at yx * \pgf at xy }
+ \int_case:nnF { \l__liftarm_LU_N_int }
+ {
+ { 0 }
+ {}
+ { 1 }
+ {
+ \RenewDocumentCommand \liftarm { O {} m m m }
+ { \__liftarm_default:nnnn {##1} {##2} {##3} {##4} }
+ }
+ { 2 }
+ {
+ \int_zero:N \l__liftarm_connect_count_int
+ \int_zero:N \l__liftarm_connect_equation_int
+ \seq_clear:N \l__liftarm_connect_coordinate_seq
+ \fp_set_eq:NN \l__liftarm_origin_connect_initial_fp \l__liftarm_origin_fp
+ \RenewDocumentCommand \liftarm { O {} m m m }
+ {
+ \int_incr:N \l__liftarm_connect_count_int
+ \fp_zero_new:c { l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp }
+ \pgfmathparse {##4}
+ \fp_set:cn { l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp } { \pgfmathresult }
+ \fp_set_eq:NN \l__liftarm_origin_fp \l__liftarm_origin_connect_initial_fp
+ \pgfkeys
+ {
+ / liftarm / connect_algorithm ,
+ coordinate = \pgfkeysvalueof { / liftarm / coordinate } ,
+ ##1
+ }
+ \__liftarm_def_coord:n {##2}
+ \fp_set_eq:cN { l__liftarm_connect_two_\int_to_Alph:n { \l__liftarm_connect_count_int }_x_fp } \g__liftarm_coord_x_fp
+ \fp_set_eq:cN { l__liftarm_connect_two_\int_to_Alph:n { \l__liftarm_connect_count_int }_y_fp } \g__liftarm_coord_y_fp
+ \int_compare:nNnTF { \l__liftarm_connect_count_int } = { 1 }
+ {
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / connect_algorithm / coordinate } }
+ {
+ \seq_set_split:Nnn \l__liftarm_coordinate_seq { / } {####1}
+ \tl_clear_new:c { l__liftarm_connect_two_A_length_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_tl }
+ \tl_set:ce { l__liftarm_connect_two_A_length_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_tl }
+ { \seq_item:Nn \l__liftarm_coordinate_seq { 1 } - \fp_use:N \l__liftarm_origin_fp }
+ \seq_put_right:Ne \l__liftarm_connect_coordinate_seq { \seq_item:Nn \l__liftarm_coordinate_seq { 2 } }
+ }
+ }
+ {
+ \clist_map_inline:en { \pgfkeysvalueof { / liftarm / connect_algorithm / coordinate } }
+ {
+ \seq_set_split:Nnn \l__liftarm_coordinate_seq { / } {####1}
+ \seq_if_in:NeT \l__liftarm_connect_coordinate_seq { \seq_item:Nn \l__liftarm_coordinate_seq { 2 } }
+ {
+ \int_incr:N \l__liftarm_connect_equation_int
+ \int_compare:nNnT { \l__liftarm_connect_equation_int } > { 1 }
+ { \PackageError { liftarm } { There~are~too~many~conditions~for~2~liftarms } {} }
+ \pgfmathparse
+ { \cs:w l__liftarm_connect_two_A_length_coord_\seq_item:Nn \l__liftarm_coordinate_seq { 2 }_tl\cs_end: }
+ \fp_set:Nn \l__liftarm_connect_two_A_length_fp { \pgfmathresult }
+ \pgfmathparse { \seq_item:Nn \l__liftarm_coordinate_seq { 1 } }
+ \fp_set:Nn \l__liftarm_connect_two_B_length_fp { \pgfmathresult - \l__liftarm_origin_fp }
+ }
+ }
+ }
+ }
+ #2
+ \fp_set:Nn \l__liftarm_connect_two_length_fp
+ {
+ sqrt (
+ ( \l__liftarm_connect_two_A_x_fp - \l__liftarm_connect_two_B_x_fp ) ^ 2
+ + ( \l__liftarm_connect_two_A_y_fp - \l__liftarm_connect_two_B_y_fp ) ^ 2
+ )
+ }
+ \fp_set:Nn \l__liftarm_connect_two_angle_fp
+ {
+ atand (
+ \l__liftarm_connect_two_B_y_fp - \l__liftarm_connect_two_A_y_fp ,
+ \l__liftarm_connect_two_B_x_fp - \l__liftarm_connect_two_A_x_fp
+ )
+ }
+ \fp_set:Nn \l__liftarm_connect_two_A_angle_fp
+ {
+ acosd (
+ (
+ ( \l__liftarm_connect_two_A_length_fp ) ^ 2 + ( \l__liftarm_connect_two_length_fp ) ^ 2
+ - ( \l__liftarm_connect_two_B_length_fp ) ^ 2
+ ) / ( 2 * \l__liftarm_connect_two_A_length_fp * \l__liftarm_connect_two_length_fp )
+ )
+ }
+ \fp_set:Nn \l__liftarm_connect_two_B_angle_fp
+ {
+ acosd (
+ (
+ ( \l__liftarm_connect_two_B_length_fp ) ^ 2 + ( \l__liftarm_connect_two_length_fp ) ^ 2
+ - ( \l__liftarm_connect_two_A_length_fp ) ^ 2
+ ) / ( 2 * \l__liftarm_connect_two_B_length_fp * \l__liftarm_connect_two_length_fp )
+ )
+ }
+ \fp_set:cn { l__liftarm_connect_two_1_option_0_angle_fp }
+ { \l__liftarm_connect_two_angle_fp + \l__liftarm_connect_two_A_angle_fp }
+ \fp_set:cn { l__liftarm_connect_two_1_option_1_angle_fp }
+ { \l__liftarm_connect_two_angle_fp - \l__liftarm_connect_two_A_angle_fp }
+ \fp_set:cn { l__liftarm_connect_two_2_option_0_angle_fp }
+ { 180 + \l__liftarm_connect_two_angle_fp - \l__liftarm_connect_two_B_angle_fp }
+ \fp_set:cn { l__liftarm_connect_two_2_option_1_angle_fp }
+ { 180 + \l__liftarm_connect_two_angle_fp + \l__liftarm_connect_two_B_angle_fp }
+ \pgfmathparse
+ {
+ \__liftarm_Mod:nn { 1 } { 0 } + \__liftarm_Mod:nn { 2 } { 0 }
+ >
+ \__liftarm_Mod:nn { 1 } { 1 } + \__liftarm_Mod:nn { 2 } { 1 }
+ }
+ \tl_set:Ne \l__liftarm_tmp_tl { \pgfmathresult }
+ \int_zero:N \l__liftarm_connect_count_int
+ \RenewDocumentCommand \liftarm { O {} m m m }
+ {
+ \int_incr:N \l__liftarm_connect_count_int
+ \__liftarm_default:nnnn {##1} {##2} {##3}
+ { \fp_use:c { l__liftarm_connect_two_\int_use:N \l__liftarm_connect_count_int _option_\l__liftarm_tmp_tl _angle_fp } }
+ }
+ }
+ }
+ {
+ \int_zero:N \l__liftarm_connect_count_int
+ \int_zero:N \l__liftarm_connect_equation_int
+ \seq_clear:N \l__liftarm_connect_coordinate_seq
+ \fp_set_eq:NN \l__liftarm_origin_connect_initial_fp \l__liftarm_origin_fp
+ \RenewDocumentCommand \liftarm { O {} m m m } { \__liftarm_connect:nnnn {##1} {##2} {##3} {##4} }
+ #2
+ \int_compare:nNnF { \l__liftarm_connect_equation_int } = { \l__liftarm_LU_N_int }
+ {
+ \PackageError { liftarm }
+ {
+ The~Jacobian~matrix~is~not~square~
+ (the~size~is~\int_use:N \l__liftarm_connect_equation_int \space by~\int_use:N \l__liftarm_LU_N_int )
+ } {}
+ }
+ \int_zero:N \l__liftarm_LU_count_int
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_zero_new:c { l__liftarm_LU_b_##1_fp } }
+ \__liftarm_connect_stop_criterion:
+ \bool_while_do:Nn \l__liftarm_LU_bool
+ {
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ {
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_set:cn { l__liftarm_LU_A_##1_####1_fp } { \cs:w l__liftarm_connect_Jacobian_##1_####1_tl\cs_end: } }
+ }
+ \__liftarm_LU_decomposition:
+ \__liftarm_LU_solve:
+ \int_step_inline:nn { \l__liftarm_LU_N_int }
+ { \fp_sub:cn { l__liftarm_connect_angle_##1_fp } { \cs:w l__liftarm_LU_x_##1_fp\cs_end: } }
+ \int_incr:N \l__liftarm_LU_count_int
+ \__liftarm_connect_stop_criterion:
+ }
+ \int_zero:N \l__liftarm_connect_count_int
+ \RenewDocumentCommand \liftarm { O {} m m m }
+ {
+ \int_incr:N \l__liftarm_connect_count_int
+ \__liftarm_default:nnnn {##1} {##2} {##3}
+ { \fp_eval:n { \cs:w l__liftarm_connect_angle_\int_use:N \l__liftarm_connect_count_int _fp\cs_end: / deg } }
+ }
+ }
+ #2
+ }
+ {}
+
\endinput
\ No newline at end of file
More information about the tex-live-commits
mailing list.