| 1 |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 2 |
\ProvidesPackage{kinematikz}[2021/12/21 kinematikz definitions Package] |
| 3 |
%-------------------------- |
| 4 |
% Vitor Santos |
| 5 |
%-------------------------- |
| 6 |
|
| 7 |
\RequirePackage{tikz} |
| 8 |
\RequirePackage{graphicx} |
| 9 |
\RequirePackage{tikz-3dplot} |
| 10 |
|
| 11 |
\RequirePackage{xstring} |
| 12 |
\RequirePackage{ifthen} |
| 13 |
|
| 14 |
\RequirePackage{listofitems} |
| 15 |
\RequirePackage{xpatch} |
| 16 |
|
| 17 |
\usetikzlibrary{backgrounds,matrix,shapes,arrows} %and some special libraries for tikz |
| 18 |
\usetikzlibrary{shapes.multipart,shadows} |
| 19 |
\usetikzlibrary{calc} |
| 20 |
\usetikzlibrary{decorations.pathreplacing} |
| 21 |
\usetikzlibrary{decorations.pathmorphing} |
| 22 |
\usetikzlibrary{positioning} %for pic |
| 23 |
\usetikzlibrary{patterns} |
| 24 |
\usetikzlibrary{scopes} %to use shorthands for scopes ;-) |
| 25 |
\usetikzlibrary{angles} |
| 26 |
\usetikzlibrary{hobby} %to use shorthands for smooth curves ;-) Use many Latex3 stuff... is that recommended...? |
| 27 |
\usetikzlibrary{math} %for some more elaborate calculations ;-) |
| 28 |
\usetikzlibrary{intersections} %for intersections |
| 29 |
\usetikzlibrary{fit} %for fitting nodes after a list of points |
| 30 |
\usetikzlibrary{arrows.meta} %for special line endings :-) |
| 31 |
|
| 32 |
%\pgfdeclarelayer{background} |
| 33 |
%\pgfdeclarelayer{foreground} |
| 34 |
%\pgfsetlayers{background,main,foreground} |
| 35 |
|
| 36 |
%https://tex.stackexchange.com/questions/86023/tikz-declare-function-and-babel-french-option |
| 37 |
%\usetikzlibrary{babel} % For incompatibilities with tikz declarations and babel with french :-((( But it creates other problems :-((( |
| 38 |
%Put it locally to test things.... |
| 39 |
|
| 40 |
|
| 41 |
%----------------------------------- |
| 42 |
%\newif\iftikziii %create a test of which tikz version we have. NOT YET USED |
| 43 |
%\begingroup |
| 44 |
%\def\getmainversion#1.#2\getmainversion{#1} |
| 45 |
%\ifnum\expandafter\getmainversion\pgfversion\getmainversion=3 |
| 46 |
%\global\tikziiitrue |
| 47 |
%\fi |
| 48 |
%\endgroup |
| 49 |
%----------------------------------- |
| 50 |
%Check the date of tikz (date is approximate - v3.1.5 or later required) |
| 51 |
\makeatletter |
| 52 |
\@ifpackagelater{tikz}{2020/01/01}{% |
| 53 |
% Package is new enough |
| 54 |
}{% |
| 55 |
\PackageError{kinematikz}{Package tikz is too old for some kinematikz facilities}{Use another version of tikz package (v.3.1.5 or later)}% |
| 56 |
} |
| 57 |
\makeatother |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
% file with kinematics chains symbology |
| 62 |
% v. santos, v1, apr 2017 |
| 63 |
% v2, aug 2017 |
| 64 |
% minor adjustmente in Feb 2018 |
| 65 |
% v3 - started in Oct 2018 - towards the first fotmal LaTeX package |
| 66 |
% v4 - started in Sep 2020 - Changed name into kinematikz using previous stuff |
| 67 |
% use prefix (kind of name space) km instead of vs for local defs and commands |
| 68 |
% new creations follow that, later on change all existing |
| 69 |
% v5 - started on Feb 2021 - pic arguments being managed with package listofitems. (but no all migrate yet) |
| 70 |
% v6 - started on Sep 2021 - create pipc synonyms. Inside a tikzset do: |
| 71 |
% new synonym/.pic={\pic {existing name={#1}};}, |
| 72 |
% The previous construction works and the passed argument #1 is actually |
| 73 |
% all the arguments regardless of their format. Some may even be |
| 74 |
%decomposed in #1/#2/ etc.. or something else in the existing elements defined locally. This was a nice trick to create synonim seemlessly! |
| 75 |
% |
| 76 |
% v7 - Nov 2021 - prepare version for deployment |
| 77 |
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % |
| 78 |
% The main ideia is: |
| 79 |
% create symbols for: |
| 80 |
% 2D and 3D representation |
| 81 |
% ISO and non-ISO common |
| 82 |
% Geometry must develop around a central point along rectangular bbox |
| 83 |
% Expected connection/anchor points: |
| 84 |
% east, west, north, south |
| 85 |
% |
| 86 |
% Symbols must have a central point (or more) that will define them |
| 87 |
% Tikz coordinates should be defined (created) to ease the process of placement |
| 88 |
% and establishing links. Arbitrary or possibily in a matrix (useful for more complex structures) |
| 89 |
% |
| 90 |
% TODOs |
| 91 |
% |
| 92 |
% migrate all vs prefixes to kn prefixes (DONE) |
| 93 |
% erase all obsolete pics and styles (DONE) |
| 94 |
% erase compulsory arguments in pics that still have it |
| 95 |
|
| 96 |
|
| 97 |
% global definitions for kinematics chains. |
| 98 |
|
| 99 |
%%========================================================== |
| 100 |
% from https://tex.stackexchange.com/questions/54358/custom-and-built-in-tikz-fill-patterns |
| 101 |
% defining the new dimensions and parameters |
| 102 |
\newlength{\hatchspread} |
| 103 |
\newlength{\hatchthickness} |
| 104 |
\newlength{\hatchshift} |
| 105 |
\newcommand{\hatchcolor}{} |
| 106 |
% declaring the keys in tikz |
| 107 |
\tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}}, |
| 108 |
hatchthickness/.code={\setlength{\hatchthickness}{#1}}, |
| 109 |
hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0 |
| 110 |
hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}} |
| 111 |
% setting the default values |
| 112 |
\tikzset{hatchspread=3pt, |
| 113 |
hatchthickness=0.4pt, |
| 114 |
hatchshift=0pt,% must be >= 0 |
| 115 |
hatchcolor=black} |
| 116 |
% declaring the pattern |
| 117 |
\pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables |
| 118 |
{custom north west lines}% name |
| 119 |
{\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner |
| 120 |
{\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner |
| 121 |
{\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size |
| 122 |
{% shape description |
| 123 |
\pgfsetlinewidth{\hatchthickness} |
| 124 |
\pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}} |
| 125 |
\pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}} |
| 126 |
\ifdim \hatchshift > 0pt |
| 127 |
\pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}} |
| 128 |
\pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}} |
| 129 |
\fi |
| 130 |
\pgfsetstrokecolor{\hatchcolor} |
| 131 |
% \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way |
| 132 |
\pgfusepath{stroke} |
| 133 |
} |
| 134 |
|
| 135 |
\pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables |
| 136 |
{custom north east lines}% name |
| 137 |
{\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner |
| 138 |
{\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner |
| 139 |
{\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size |
| 140 |
{% shape description |
| 141 |
\pgfsetlinewidth{\hatchthickness} |
| 142 |
\pgfpathmoveto{\pgfqpoint{\dimexpr\hatchshift-0.15pt}{-0.15pt}} |
| 143 |
\pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt}{\dimexpr\hatchspread-\hatchshift+0.15pt}} |
| 144 |
\ifdim \hatchshift > 0pt |
| 145 |
\pgfpathmoveto{\pgfqpoint{-0.15pt}{\dimexpr\hatchspread-\hatchshift-0.15pt}} |
| 146 |
\pgfpathlineto{\pgfqpoint{\dimexpr\hatchshift+0.15pt}{\dimexpr\hatchspread+0.15pt}} |
| 147 |
\fi |
| 148 |
\pgfsetstrokecolor{\hatchcolor} |
| 149 |
% \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way |
| 150 |
\pgfusepath{stroke} |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
%%========================================================== |
| 155 |
|
| 156 |
\def\TikZ{Ti\emph{k}Z} |
| 157 |
\def\Kinematikz{Kinema\TikZ} |
| 158 |
\def\kinematikz{\Kinematikz} |
| 159 |
|
| 160 |
\newcommand{\knKinematikz}{ %A logo for the package still in development |
| 161 |
\pic [scale=0.3,transform shape] (F) {frame=7cm}; |
| 162 |
\pic [scale=0.3,transform shape,xshift=-3.2cm] (L1) at (F-end) {link bar generic={90:2/0/0/0//1}}; |
| 163 |
\coordinate (tt) at ($(L1-start)!0.9!(L1-center)$); |
| 164 |
\pic [scale=0.3,transform shape](L2) at (tt) {link bar generic={50:1.2/0//1//1}}; |
| 165 |
\pic [scale=0.3,transform shape](L3) at (tt) {link bar generic={-38:1.1/0//1//1}}; |
| 166 |
\node [at=(L3-end),xshift=-1pt, yshift=2.5pt,anchor=west,TSF] {inema\TikZ}; |
| 167 |
\pic[scale=0.3,transform shape] (F) {frame=7cm}; %Just to cover if exposed... |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
\makeatletter |
| 173 |
\newcommand\currentcoordinate{\the\tikz@lastxsaved,\the\tikz@lastysaved} |
| 174 |
\makeatother |
| 175 |
|
| 176 |
\def\pivotRadius{3pt} %radius of pivot elements |
| 177 |
\def\linkWidth{6.42pt} %width of links for vsCustomLinks |
| 178 |
\def\linkWidth{1pt} %width of links for vsCustomLinks |
| 179 |
\def\gapGround{0.04} %separation of moving ground contact (unit is default -- cm) |
| 180 |
\def\lAng{90} %default angle for link arms (can override locally) |
| 181 |
\def\lLenA{0.5} %default length for link arm A (can override locally) |
| 182 |
\def\lLenB{0.5} %default length for link arm B (can override locally) |
| 183 |
\def\COMradius{0.4em} %radius of center of mass (because of "em" can scale with font size modifyers :-) |
| 184 |
\def\LinkFillColor{gray!50} %default color of planar 2D links |
| 185 |
\def\SubLinkFillColor{gray!30} %default color of planar 2D sublinks (like pistons in 2D) |
| 186 |
\def\lockRadius{1.25*\pivotRadius} % to define the size of locks in ISO symbols |
| 187 |
|
| 188 |
\tikzset{TSF/.style={transform shape=false}} |
| 189 |
% The "transform shape" is necessarry to also scale pic in case of scaling tikzpictures |
| 190 |
%becase the global option scale=..., does not affect nodes or pics. But the problem |
| 191 |
%is that it scales fonts as well.. so you can use a smaller font like \footnotesize which is OK for scales of 1.25 except minor issue in kerning. But, it's better to use |
| 192 |
%an independnet solution which is to use "transform shape=false" locally on the node to avoid font scaling. So this is useful to keep nodes without drawn shapes with normal |
| 193 |
%font sizes... |
| 194 |
%So it is recomended to use the TSF style created above in nodes with only text and |
| 195 |
%no shape to be drawn to keep text the default size |
| 196 |
|
| 197 |
|
| 198 |
\newcommand{\lineTip}[1]{\fill #1 circle (0.6pt)} %was 0.4 pt, but 0.6 is adequate for "thick" lines. command to append small termination to some tips of lines to cover for poorer line joining :-( Accepts one argument which is the point where to put the terminations |
| 199 |
%NOTE - in many cases the previous was replaced by [line cap=round] which is more automatic, but applies to both ends of line and that can be undesired in certain cases; actually a style knLineCap was created for that :-) |
| 200 |
|
| 201 |
%\draw [options] (center) +(start ang:radius) arc (start ang:end ang:radius); %technique to draw an arc with a center, radius, start and end angle |
| 202 |
|
| 203 |
|
| 204 |
%---Code to allow callout overlay----------- |
| 205 |
%code from: https://tex.stackexchange.com/questions/187165/callout-with-multiple-pointers-how-to-design-it |
| 206 |
% The goal is to translate |
| 207 |
% \overlaynode<red,blue>{hallo}; |
| 208 |
% into |
| 209 |
% \node[red]{hallo}; |
| 210 |
% \node[blue]{hallo}; |
| 211 |
\makeatletter |
| 212 |
\def\overlaynode<#1>#2;{ |
| 213 |
\gdef\stacknodecommonpart{#2} |
| 214 |
\pgfkeys{/typeset node/.list={#1}} |
| 215 |
} |
| 216 |
\pgfkeys{ |
| 217 |
/typeset node/.code={ |
| 218 |
\edef\pgf@marshal{\noexpand\node[#1]\stacknodecommonpart;} |
| 219 |
\pgf@marshal |
| 220 |
} |
| 221 |
} |
| 222 |
\def\overlaynodedrawfill{\pgfutil@ifnextchar[{\overlaynodedrawfill@opt}{\overlaynodedrawfill@opt[]}} |
| 223 |
\def\overlaynodedrawfill@opt[#1]<#2>#3;{ |
| 224 |
\begin{scope}[transparency group,draw=black,fill=white,line cap=round,line join=round,#1] |
| 225 |
\pgfmathsetmacro\pgflinewidthdouble{2\pgflinewidth} |
| 226 |
\overlaynode<#2>[draw=pgfstrokecolor,line width=\pgflinewidthdouble]#3; |
| 227 |
\overlaynode<#2>[fill=pgffillcolor]#3; |
| 228 |
\end{scope} |
| 229 |
} |
| 230 |
\makeatother |
| 231 |
%---------------------------------- |
| 232 |
|
| 233 |
|
| 234 |
%---------------------------------- |
| 235 |
%% Command to draw a coordinate system in 2D with 3rd axis (z) in perspective |
| 236 |
% Accepts an optional argument which if the orientation of the system |
| 237 |
% The second argument is the index of the coordinate system, |
| 238 |
% and the thrid is the point where to draw that is: |
| 239 |
% \knAddCoordFrame[ang]{num}{point} |
| 240 |
% \knAddCoordFrame{num}{point} |
| 241 |
% A special index should also be allowed (R,H, etc...) |
| 242 |
|
| 243 |
\def\knCoordScale{1} %Global scale for Coordinate frame sizes. Can be adjusted |
| 244 |
\newcommand{\knAddCoordFrameZout}[3][0]{ %#1 - optional: angle; #2 - mandatory: suffix; #3 startingpoint |
| 245 |
\ifthenelse{ \equal{#3}{} } |
| 246 |
{ |
| 247 |
\def\cAng{0} |
| 248 |
\def\cSuff{#1} |
| 249 |
\def\cOrigin{#2} |
| 250 |
} |
| 251 |
{ |
| 252 |
\def\cAng{#1} |
| 253 |
\def\cSuff{#2} |
| 254 |
\def\cOrigin{#3} |
| 255 |
} |
| 256 |
\tikzmath{ |
| 257 |
int \drawTheta; |
| 258 |
\drawTheta=0; |
| 259 |
if ( \cSuff >= 0 ) then |
| 260 |
{ |
| 261 |
\drawTheta=1; |
| 262 |
} else |
| 263 |
{ |
| 264 |
\cSuff = int(-\cSuff); |
| 265 |
}; |
| 266 |
} |
| 267 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 268 |
\edef\idxAng{\pgfmathresult} |
| 269 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[above,TSF] {$\hat x_{\cSuff}$}; |
| 270 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(0,{\knCoordScale*0.75}) node[left,TSF] {$\hat y_{\cSuff}$}; |
| 271 |
\draw[robot coord system] \cOrigin -- ++({-\knCoordScale*0.5},{-\knCoordScale*0.5}) node[right,TSF] {$\hat z_{\cSuff}$}; |
| 272 |
%\draw [options] (center) +(start ang:radius) arc (start ang:end ang:radius); |
| 273 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 274 |
{ |
| 275 |
\draw [angular lines no limits] \cOrigin ++(-135:{\knCoordScale*0.4}) +(-30:0.2) arc (-30:+150:0.2) node [left,xshift=3pt,TSF] {$ \theta_{\idxAng} $}; |
| 276 |
} |
| 277 |
{} |
| 278 |
\draw [fill] \cOrigin circle (1pt); |
| 279 |
} |
| 280 |
%------- |
| 281 |
\newcommand{\knAddCoordFrameZoutB}[4][0]{ %#1 - optional: tikz options; #2 rotation angle except for one axis; #3 - mandatory: suffix; #4 startingpoint |
| 282 |
\ifthenelse{ \equal{#4}{} } %Only has 3 parameters |
| 283 |
{ |
| 284 |
\def\cOptions{} |
| 285 |
\def\cAng{#1} |
| 286 |
\def\cSuff{#2} |
| 287 |
\def\cOrigin{#3} |
| 288 |
} |
| 289 |
{ %Has the 4 parameters |
| 290 |
\def\cOptions{#1} |
| 291 |
\def\cAng{#2} %This angle overrides angle potentially included in the general options |
| 292 |
\def\cSuff{#3} |
| 293 |
\def\cOrigin{#4} |
| 294 |
} |
| 295 |
\tikzmath{ |
| 296 |
int \drawTheta; |
| 297 |
\drawTheta=0; |
| 298 |
%Comment next since this is now for special cases |
| 299 |
% if ( \cSuff >= 0 ) then |
| 300 |
% { |
| 301 |
% \drawTheta=1; |
| 302 |
% } else |
| 303 |
% { |
| 304 |
% \cSuff = int(-\cSuff); |
| 305 |
% }; |
| 306 |
} |
| 307 |
%\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 308 |
\edef\idxAng{\pgfmathresult} \edef\idxAng{-} |
| 309 |
\draw[robot coord system,\cOptions,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[above,TSF] {$\hat x_{\cSuff}$}; |
| 310 |
\draw[robot coord system,\cOptions,rotate=\cAng] \cOrigin -- ++(0,{\knCoordScale*0.75}) node[left,TSF] {$\hat y_{\cSuff}$}; |
| 311 |
\draw[robot coord system,\cOptions] \cOrigin -- ++({-\knCoordScale*0.5},{-\knCoordScale*0.5}) node[right,TSF] {$\hat z_{\cSuff}$}; |
| 312 |
%\draw [options] (center) +(start ang:radius) arc (start ang:end ang:radius); |
| 313 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 314 |
{ |
| 315 |
\draw [angular lines no limits] \cOrigin ++(-135:{\knCoordScale*0.4}) +(-30:0.2) arc (-30:+150:0.2) node [left,xshift=3pt,TSF] {$ \theta_{\idxAng} $}; |
| 316 |
} |
| 317 |
{} |
| 318 |
\draw [fill] \cOrigin circle (1pt); |
| 319 |
} |
| 320 |
%------- |
| 321 |
\newcommand{\knAddCoordFrameZup}[3][0]{ %#1 - optional: angle; #2 - mandatory: suffix; #3 startingpoint |
| 322 |
\ifthenelse{ \equal{#3}{} } |
| 323 |
{ |
| 324 |
\def\cAng{0} |
| 325 |
\def\cSuff{#1} |
| 326 |
\def\cOrigin{#2} |
| 327 |
} |
| 328 |
{ |
| 329 |
\def\cAng{#1} |
| 330 |
\def\cSuff{#2} |
| 331 |
\def\cOrigin{#3} |
| 332 |
} |
| 333 |
\tikzmath{ |
| 334 |
int \drawTheta; |
| 335 |
\drawTheta=0; %by default does not draw |
| 336 |
if ( \cSuff >= 0 ) then |
| 337 |
{ |
| 338 |
\drawTheta=1; |
| 339 |
} |
| 340 |
else |
| 341 |
{ |
| 342 |
\cSuff = int(-\cSuff); |
| 343 |
}; |
| 344 |
} |
| 345 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 346 |
\edef\idxAng{\pgfmathresult} |
| 347 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[anchor=south west,inner sep=1pt,TSF] {$\hat x_{\cSuff}$}; |
| 348 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(0,{\knCoordScale*0.75}) node[anchor=south east,inner sep=1pt,TSF] {$\hat z_{\cSuff}$}; |
| 349 |
\draw[robot coord system] \cOrigin -- ++({\knCoordScale*0.5},{\knCoordScale*0.5}) node[anchor=south east,inner sep=1pt,TSF] {$\hat y_{\cSuff}$}; |
| 350 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 351 |
{ |
| 352 |
\draw[angular lines no limits,rotate=\cAng] \cOrigin ++(90:{\knCoordScale*0.4}) node [left,xshift=-3pt,TSF] {$ \theta_{\idxAng} $} [partial ellipse=-250:60:0.25cm and 0.1cm]; |
| 353 |
}{} |
| 354 |
|
| 355 |
\draw[fill] \cOrigin circle (1pt); |
| 356 |
} |
| 357 |
|
| 358 |
%------ |
| 359 |
|
| 360 |
\newcommand{\knAddCoordFrameZdown}[3][0]{ %#1 - optional: angle; #2 - mandatory: suffix; #3 startingpoint |
| 361 |
\ifthenelse{ \equal{#3}{} } |
| 362 |
{ |
| 363 |
\def\cAng{0} |
| 364 |
\def\cSuff{#1} |
| 365 |
\def\cOrigin{#2} |
| 366 |
} |
| 367 |
{ |
| 368 |
\def\cAng{#1} |
| 369 |
\def\cSuff{#2} |
| 370 |
\def\cOrigin{#3} |
| 371 |
} |
| 372 |
\tikzmath{ |
| 373 |
int \drawTheta; |
| 374 |
\drawTheta=0; %by default does not draw |
| 375 |
if ( \cSuff >= 0 ) then |
| 376 |
{ |
| 377 |
\drawTheta=1; |
| 378 |
} |
| 379 |
else |
| 380 |
{ |
| 381 |
\cSuff = int(-\cSuff); |
| 382 |
}; |
| 383 |
} |
| 384 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 385 |
\edef\idxAng{\pgfmathresult} |
| 386 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[anchor=south east,inner sep=1pt,TSF] {$\hat x_{\cSuff}$}; |
| 387 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(0,-{\knCoordScale*0.75}) node[anchor=south east,inner sep=1pt,TSF] {$\hat z_{\cSuff}$}; |
| 388 |
\draw[robot coord system] \cOrigin -- ++(-{\knCoordScale*0.5},{-\knCoordScale*0.5}) node[anchor=south east,inner sep=1pt,TSF] {$\hat y_{\cSuff}$}; |
| 389 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 390 |
{ |
| 391 |
\draw[angular lines no limits,rotate=\cAng] \cOrigin ++(-90:{\knCoordScale*0.4}) [partial ellipse=60:-250:0.25cm and 0.1cm] node [right,xshift=2pt,yshift=4pt,TSF] {$ \theta_{\idxAng} $}; |
| 392 |
}{} |
| 393 |
|
| 394 |
\draw[fill] \cOrigin circle (1pt); |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
%----- |
| 400 |
\newcommand{\knAddCoordFrameZupRotX}[3][0]{ %#1 - optional: angle; #2 - mandatory: suffix; #3 startingpoint |
| 401 |
\ifthenelse{ \equal{#3}{} } |
| 402 |
{ |
| 403 |
\def\cAng{0} |
| 404 |
\def\cSuff{#1} |
| 405 |
\def\cOrigin{#2} |
| 406 |
} |
| 407 |
{ |
| 408 |
\def\cAng{#1} |
| 409 |
\def\cSuff{#2} |
| 410 |
\def\cOrigin{#3} |
| 411 |
} |
| 412 |
\tikzmath{ |
| 413 |
int \drawTheta; |
| 414 |
\drawTheta=0; %by default does not draw |
| 415 |
if ( \cSuff >= 0 ) then |
| 416 |
{ |
| 417 |
\drawTheta=1; |
| 418 |
} |
| 419 |
else |
| 420 |
{ |
| 421 |
\cSuff = int(-\cSuff); |
| 422 |
}; |
| 423 |
} |
| 424 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 425 |
\edef\idxAng{\pgfmathresult} |
| 426 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[anchor=south east,inner sep=1pt,TSF] {$\hat y_{\cSuff}$}; |
| 427 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(0,{\knCoordScale*0.75}) node[anchor=south east,inner sep=1pt,TSF] {$\hat z_{\cSuff}$}; |
| 428 |
\draw[robot coord system] \cOrigin -- ++({-\knCoordScale*0.5},{-\knCoordScale*0.5}) node[anchor=south east,inner sep=1pt,TSF] {$\hat x_{\cSuff}$}; |
| 429 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 430 |
{ |
| 431 |
\draw[angular lines no limits,rotate=\cAng] \cOrigin ++(90:{\knCoordScale*0.4}) node [left,xshift=-3pt,TSF] {$ \theta_{\idxAng} $} [partial ellipse=-250:60:0.25cm and 0.1cm]; |
| 432 |
}{} |
| 433 |
|
| 434 |
\draw[fill] \cOrigin circle (1pt); |
| 435 |
} |
| 436 |
%----- |
| 437 |
|
| 438 |
|
| 439 |
\newcommand{\knAddCoordFrameZright}[3][0]{ %#1 - optional: angle; #2 - mandatory: suffix; #3 startingpoint (if suffix is < 0 does not draw angle :-) |
| 440 |
\ifthenelse{ \equal{#3}{} } |
| 441 |
{ |
| 442 |
\def\cAng{0} |
| 443 |
\def\cSuff{#1} |
| 444 |
\def\cOrigin{#2} |
| 445 |
} |
| 446 |
{ |
| 447 |
\def\cAng{#1} |
| 448 |
\def\cSuff{#2} |
| 449 |
\def\cOrigin{#3} |
| 450 |
} |
| 451 |
\tikzmath{ |
| 452 |
int \drawTheta; |
| 453 |
\drawTheta=0; %by default does not draw |
| 454 |
if ( \cSuff >= 0 ) then |
| 455 |
{ |
| 456 |
\drawTheta=1; |
| 457 |
} |
| 458 |
else |
| 459 |
{ |
| 460 |
\cSuff = int(-\cSuff); |
| 461 |
}; |
| 462 |
} |
| 463 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 464 |
\edef\idxAng{\pgfmathresult} |
| 465 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++({\knCoordScale*0.5},0) node[above,TSF] {$\hat z_{\cSuff}$}; |
| 466 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(0,{\knCoordScale*0.75}) node[left,TSF] {$\hat x_{\cSuff}$}; |
| 467 |
\draw[robot coord system] \cOrigin -- ++({-\knCoordScale*0.5},{-\knCoordScale*0.5}) node[right,TSF] {$\hat y_{\cSuff}$}; |
| 468 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 469 |
{ |
| 470 |
\draw[angular lines no limits,rotate=\cAng] \cOrigin ++(0:{\knCoordScale*0.2}) [partial ellipse=60:330:0.1cm and 0.25cm] node [below,anchor=north west,TSF] {$ \theta_{\idxAng} $}; |
| 471 |
} |
| 472 |
{} |
| 473 |
\draw[fill] \cOrigin circle (1pt); |
| 474 |
} |
| 475 |
|
| 476 |
%=========================================== |
| 477 |
% Command intended to cover for all the above with flexibility |
| 478 |
% The facilities in tikz 3D lib or tikz-3dplot do not help... |
| 479 |
% Command must cover generates one of the following options |
| 480 |
% System direction (order left to right, d means down) |
| 481 |
% |
| 482 |
% Y |
| 483 |
% |__X (ZdYX) (default) |
| 484 |
% / |
| 485 |
% Z |
| 486 |
% |
| 487 |
% X |
| 488 |
% |__Z (YdXZ) rotz90 * rotx90 * default |
| 489 |
% / |
| 490 |
% Y |
| 491 |
% |
| 492 |
% Z |
| 493 |
% |__Y (XdZY) |
| 494 |
% / |
| 495 |
% X |
| 496 |
% |
| 497 |
% _X (YdZdX) |
| 498 |
% /| |
| 499 |
% Y Z |
| 500 |
% |
| 501 |
% Z Y |
| 502 |
% |/__X (ZYX) |
| 503 |
% |
| 504 |
% |
| 505 |
|
| 506 |
|
| 507 |
%Implement a switch case in latex |
| 508 |
%from https://tex.stackexchange.com/questions/5116/making-switch-case-with-etoolboxs-ifdefequal/5210 |
| 509 |
\newcommand{\CheckCase}[1]{% |
| 510 |
\par\noindent%What is this for?? |
| 511 |
\IfEqCase*{#1}{% |
| 512 |
{ZdYX}{\def\zDir{-135:{\knCoordScale*0.4}} \def\yDir{90:{\knCoordScale*1}} \def\xDir{0:{\knCoordScale*1}} }% |
| 513 |
{YdXZ}{}% |
| 514 |
{XdZY}{}% |
| 515 |
{YdZdX}{}% |
| 516 |
{ZYX}{}% |
| 517 |
}[Did not match any given case!]%Put the default here |
| 518 |
}% |
| 519 |
|
| 520 |
|
| 521 |
\newcommand{\knAddCoordFrame}[5][0]{ |
| 522 |
% #1 - optional rotation angle in plane (default 0) |
| 523 |
% #2 - suffix for system naming (0,1,2,..., H, R, ... other) |
| 524 |
% #3 - starting point Where to draw origin in current picture |
| 525 |
% #4 - type of system (ZdYX,YdXZ,XdZY,YdZdX,ZYX) |
| 526 |
% #5 - draw joint around z , or along z; (0 - no drawing, 1 - circular, 2 - linear ) |
| 527 |
%\def\zDir{-135:{\knCoordScale*0.4}} \def\yDir{90:{\knCoordScale*1}} \def\xDir{0:{\knCoordScale*1}} |
| 528 |
\ifthenelse{\equal{#5}{} } %if not 5 params passed... |
| 529 |
{ |
| 530 |
\def\cAng{0} |
| 531 |
\def\cSuff{#1} |
| 532 |
\def\cOrigin{#2} |
| 533 |
\def\cType{#3} |
| 534 |
\def\cJoint{#4} |
| 535 |
} |
| 536 |
{ |
| 537 |
\def\cAng{#1} |
| 538 |
\def\cSuff{#2} |
| 539 |
\def\cOrigin{#3} |
| 540 |
\def\cType{#4} |
| 541 |
\def\cJoint{#5} |
| 542 |
} |
| 543 |
|
| 544 |
\tikzmath{ |
| 545 |
int \drawTheta; |
| 546 |
\drawTheta=0; |
| 547 |
if ( \cSuff >= 1 ) then |
| 548 |
{ |
| 549 |
\drawTheta=1; |
| 550 |
} else |
| 551 |
{ |
| 552 |
\cSuff = int(-\cSuff); |
| 553 |
}; |
| 554 |
} |
| 555 |
\pgfmathparse{int(\cSuff+1)} %had to use int to avoid decimal places |
| 556 |
\edef\idxAng{\pgfmathresult} |
| 557 |
|
| 558 |
% \CheckCase{\cType}%Extract type of coord system and adjust some macros accordingly |
| 559 |
|
| 560 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(\xDir) node[TSF] {$\hat x_{\cSuff}$}; |
| 561 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(\yDir) node[TSF] {$\hat y_{\cSuff}$}; |
| 562 |
\draw[robot coord system,rotate=\cAng] \cOrigin -- ++(\zdir) node[TSF] {$\hat z_{\cSuff}$}; |
| 563 |
%\draw [options] (center) +(start ang:radius) arc (start ang:end ang:radius); |
| 564 |
|
| 565 |
\ifthenelse{ \equal{\drawTheta}{1} } |
| 566 |
{ |
| 567 |
% \draw [angular lines no limits] \cOrigin ++(-135:{\knCoordScale*0.4}) +(-30:0.2) arc (-30:+150:0.2) node [left,xshift=3pt,TSF] {$ \theta_{\idxAng} $}; |
| 568 |
} |
| 569 |
{} |
| 570 |
\draw [fill] \cOrigin circle (1pt); |
| 571 |
} |
| 572 |
|
| 573 |
%=========================================== |
| 574 |
|
| 575 |
%----------------------------------- |
| 576 |
|
| 577 |
\tikzset{ |
| 578 |
%https://tex.stackexchange.com/questions/23453/symbol-center-of-mass-dowelpin |
| 579 |
pics/center of mass/.style={ % |
| 580 |
code={ |
| 581 |
\begin{scope}[radius=\COMradius] %use the same radius for all operations in scope |
| 582 |
\fill (0,0) -- ++(\COMradius,0) arc [start angle=0,end angle=90] -- ++(0,-2*\COMradius) arc [start angle=270, end angle=180];% |
| 583 |
\draw (0,0) circle;% |
| 584 |
\end{scope} |
| 585 |
}% |
| 586 |
} |
| 587 |
} |
| 588 |
|
| 589 |
\newcommand{\addCOM}[1][black] %alternative to "center of mass" pic. Accepts one argument which are the parameters to fill and draw operations. |
| 590 |
%Valid only when there is a (-center) node defined, so most useful inside other figures (pic or other)... |
| 591 |
{ |
| 592 |
\begin{scope}[radius=\COMradius] %use the same radius for all operations in scope |
| 593 |
\fill [#1] (-center) -- ++(\COMradius,0) arc [start angle=0,end angle=90] -- ++(0,-2*\COMradius) arc [start angle=270, end angle=180];% |
| 594 |
\draw [#1] (-center) circle;% |
| 595 |
\end{scope} |
| 596 |
} |
| 597 |
|
| 598 |
%after https://tex.stackexchange.com/questions/39293/coordinates-a-b-compute-b-a-and-angle-between-x-and-b-a |
| 599 |
\newcommand{\kmpgfextractangle}[2] |
| 600 |
{ |
| 601 |
\pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfpointanchor{#2}{center}} |
| 602 |
\global\let#1\pgfmathresult |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
%after https://tex.stackexchange.com/questions/98924/transform-defined-coordinates-in-tikz |
| 608 |
\makeatletter |
| 609 |
\newcommand{\gettikzxy}[3]{% |
| 610 |
\tikz@scan@one@point\pgfutil@firstofone#1\relax |
| 611 |
\edef#2{\the\pgf@x}% |
| 612 |
\edef#3{\the\pgf@y}% |
| 613 |
} |
| 614 |
\makeatother |
| 615 |
|
| 616 |
|
| 617 |
%Next definitions inspired from |
| 618 |
%https://tex.stackexchange.com/questions/411726/how-to-connect-nodes-with-45-degree-and-0-degree-lines-possibly-via-style/411734 |
| 619 |
\tikzset{ |
| 620 |
45-/.style={ |
| 621 |
to path={ |
| 622 |
let \p{start}=(\tikztostart), |
| 623 |
\p{target}=(\tikztotarget), |
| 624 |
\p{diff}=({\x{target}-\x{start}}, {\y{target}-\y{start}}), |
| 625 |
\p{absdiff}=({abs(\x{diff})}, {abs(\y{diff})}), |
| 626 |
\n{mindiff}={min(\x{absdiff}, \y{absdiff})}, |
| 627 |
\p{inter}=( |
| 628 |
{sign(\x{diff}) * \n{mindiff}}, |
| 629 |
{sign(\y{diff}) * \n{mindiff}} |
| 630 |
) |
| 631 |
in |
| 632 |
\ifnum \ifdim\x{target}=\x{start} 1 |
| 633 |
\else \ifdim\y{target}=\y{start} 1 |
| 634 |
\else \ifdim\x{absdiff}=\y{absdiff} 1 |
| 635 |
\else 0\fi\fi\fi=1 %primitive tex or condition |
| 636 |
-- (\tikztotarget) |
| 637 |
\else |
| 638 |
--++ (\p{inter}) -- (\tikztotarget) |
| 639 |
\fi |
| 640 |
}, |
| 641 |
}, |
| 642 |
} |
| 643 |
|
| 644 |
%THIS STARTS WITH THE DIAGONAL PART AND ADDS THE VERTICAL/HORIZONTAL PART AFTER |
| 645 |
%SWAP POINTS IF YOU WANT THE REVERSE. |
| 646 |
\tikzset{ |
| 647 |
-45/.style={ |
| 648 |
to path={ |
| 649 |
let \p{start}=(\tikztostart), |
| 650 |
\p{target}=(\tikztotarget), |
| 651 |
\p{diff}=({\x{target}-\x{start}}, {\y{target}-\y{start}}), |
| 652 |
\p{absdiff}=({abs(\x{diff})}, {abs(\y{diff})}), |
| 653 |
\n{mindiff}={min(\x{absdiff}, \y{absdiff})}, |
| 654 |
\p{inter}=( |
| 655 |
{sign(\x{diff}) * \n{mindiff}}, |
| 656 |
{sign(\y{diff}) * \n{mindiff}} |
| 657 |
), |
| 658 |
\p{inter}=( |
| 659 |
\x{target}, |
| 660 |
{sign(\y{diff}) * \n{mindiff}} |
| 661 |
) |
| 662 |
in |
| 663 |
\ifnum |
| 664 |
\ifdim\x{target}=\x{start} 1 % points in horizontal? |
| 665 |
\else \ifdim\y{target}=\y{start} 1 % points in vertical? |
| 666 |
\else \ifdim\x{absdiff}=\y{absdiff} 1 % points in45º diagonal? |
| 667 |
\else 0 % not any of those |
| 668 |
\fi |
| 669 |
\fi |
| 670 |
\fi=1 %primitive tex or condition |
| 671 |
-- (\tikztotarget) %single horizontal/vertical/diagonal line |
| 672 |
\else |
| 673 |
-- (\p{inter}) -- (\tikztotarget) %two steps: to intermediate and to target |
| 674 |
\fi |
| 675 |
}, |
| 676 |
}, |
| 677 |
} |
| 678 |
|
| 679 |
%%=============================================================== |
| 680 |
\tikzset{ %definitions for some filling and line styles |
| 681 |
ground/.style={ %style for a decoration (of a line) |
| 682 |
% The border decoration is a path replacing decorator. |
| 683 |
% For the ground style we want to draw the original path. |
| 684 |
% The postaction option is therefore used to ensure that the |
| 685 |
% border decoration is drawn *after* the original path. |
| 686 |
% postaction={ %uncomment to also draw the path, but attention to the xshift |
| 687 |
draw, |
| 688 |
very thin, |
| 689 |
decorate, |
| 690 |
decoration={ |
| 691 |
border, |
| 692 |
angle=120, |
| 693 |
mirror=true, |
| 694 |
amplitude=0.2cm, |
| 695 |
transform={xshift=2.5pt}, |
| 696 |
% pre=lineto, pre length=3pt, post=border, %post length=2pt, |
| 697 |
segment length=2pt, |
| 698 |
}, |
| 699 |
% } %uncomment to also draw the path |
| 700 |
}, |
| 701 |
%------------------------------------------ |
| 702 |
ground2 texture/.style={ |
| 703 |
pattern=custom north east lines, |
| 704 |
hatchspread=2.5pt, |
| 705 |
% hatchcolor=green!65!black, |
| 706 |
% hatchcolor=black, |
| 707 |
hatchshift=0pt, |
| 708 |
hatchthickness=0.3pt, |
| 709 |
% pattern=north east lines, pattern color=black, |
| 710 |
}, |
| 711 |
ground2/.style={ %style for a node (rectangle) - good only for multiple of 90º orientations |
| 712 |
rectangle, |
| 713 |
line width=0, |
| 714 |
ground2 texture, |
| 715 |
minimum height=5pt, |
| 716 |
anchor=north west, |
| 717 |
inner sep=0, |
| 718 |
transform shape, %to rotate rectangle (but not pattern) |
| 719 |
}, |
| 720 |
%------------------------------------------ |
| 721 |
knLinkStyle/.style={% main style for links - namely type of line |
| 722 |
thick, %was very thick |
| 723 |
% line join=round, %curved connections? May be yes to match line caps... |
| 724 |
miter limit=5, %avoid long sharp corners in special edges |
| 725 |
}, |
| 726 |
knLineCap/.style={ %additional option for line cap in some drawings |
| 727 |
line cap=round, |
| 728 |
}, |
| 729 |
knJointStyle/.style={ %Style for drawing joint parts - not the link parts, like ends or arms! |
| 730 |
knLinkStyle, %similar to knLinkStyle. But can be adjusted if needed |
| 731 |
line join=miter, %Reinforce the default, unless you want soft corners in rectangles. |
| 732 |
}, |
| 733 |
%------------------------------------------- |
| 734 |
cube face 1/.style={ |
| 735 |
knJointStyle, |
| 736 |
line join=bevel, |
| 737 |
fill=white, %to allow hidding lines in drawing |
| 738 |
}, |
| 739 |
gripper 1/.style={ |
| 740 |
line join=bevel, |
| 741 |
knJointStyle, %was very thick |
| 742 |
}, |
| 743 |
%% SEVERAL LINE STYLES |
| 744 |
auxiliary lines/.style={ |
| 745 |
very thin, |
| 746 |
blue, |
| 747 |
}, |
| 748 |
symmetry lines/.style={ %to indicate symmetric longitudinal rotational axle |
| 749 |
auxiliary lines, |
| 750 |
line width=0.5pt, |
| 751 |
densely dash dot, |
| 752 |
}, |
| 753 |
dimension lines no limits/.style={ |
| 754 |
auxiliary lines, |
| 755 |
red, |
| 756 |
>=stealth, |
| 757 |
<->, |
| 758 |
}, |
| 759 |
dimension lines/.style={ |
| 760 |
dimension lines no limits, |
| 761 |
|<->|, |
| 762 |
}, |
| 763 |
angular lines no limits/.style={ |
| 764 |
dimension lines no limits, |
| 765 |
red, |
| 766 |
>=stealth, |
| 767 |
->, |
| 768 |
}, |
| 769 |
angular lines/.style={ |
| 770 |
angular lines no limits, |
| 771 |
->|, %possibly |->| ? |
| 772 |
}, |
| 773 |
joint axis/.style={ |
| 774 |
symmetry lines, |
| 775 |
black, |
| 776 |
}, |
| 777 |
%%OTHER USEFUL STYLES |
| 778 |
robot coord system/.style={ |
| 779 |
thick, |
| 780 |
->, |
| 781 |
>=stealth, |
| 782 |
blue, |
| 783 |
}, |
| 784 |
partial ellipse/.style args={#1:#2:#3}{ |
| 785 |
insert path={+ (#1:#3) arc (#1:#2:#3)} |
| 786 |
}, |
| 787 |
%------------------------------------------ |
| 788 |
} |
| 789 |
|
| 790 |
% Check also https://tex.stackexchange.com/questions/463370/pass-an-argument-for-a-pic |
| 791 |
% for how to pass arguments to pics |
| 792 |
% And this https://tex.stackexchange.com/questions/250728/tikz-pics-with-optional-default-parameters |
| 793 |
% to specify default arguments |
| 794 |
%%=============================================================== |
| 795 |
\tikzset{ |
| 796 |
%=================================================== |
| 797 |
pics/frame/.default=1cm, %default argument - base width |
| 798 |
pics/frame/.style args={#1}{ %ISO frame 3952-1-3.1 % OK in man (passed to the manual) |
| 799 |
% Arg 1 - dimension - base width [1cm] |
| 800 |
code={ |
| 801 |
% \pgfmathsetmacro\myW{#1/2}; %in case you need maths |
| 802 |
\coordinate (-left) at (-#1/2,0); |
| 803 |
\coordinate (-right) at (#1/2,0); |
| 804 |
\coordinate (-center) at (0,0); |
| 805 |
\coordinate (-centerTan) at (0,0.175); %This point of for tangency of a link polygon there |
| 806 |
\coordinate (-north) at (0,0); |
| 807 |
\coordinate (-in) at (0,0); |
| 808 |
\coordinate (-out) at (-in); |
| 809 |
\coordinate (-end) at (-out); |
| 810 |
\coordinate (-south) at (-north); |
| 811 |
\coordinate (-start) at (-in); |
| 812 |
\node [ground2,minimum width=#1] at (-left) {}; % \draw [ground] (0,0) -- (2,0); |
| 813 |
\draw [knJointStyle] (-left) -- ++(#1,0); |
| 814 |
} %end of code for this particular pic |
| 815 |
}, |
| 816 |
%------------------------------------------ |
| 817 |
pics/frame 3D/.default=1cm, %default argument - base width |
| 818 |
pics/frame 3D/.style args={#1}{ %Frame 3D |
| 819 |
% Arg 1 - dimension - base width [1cm] |
| 820 |
code={ |
| 821 |
% \pgfmathsetmacro\myW{#1/2}; %in case you need maths |
| 822 |
\coordinate (-west) at (-#1/2,0); |
| 823 |
\coordinate (-east) at (#1/2,0); |
| 824 |
\coordinate (-center) at (0,0); |
| 825 |
\coordinate (-south) at (-135:#1/4); |
| 826 |
\coordinate (-north) at (45:#1/4); |
| 827 |
\coordinate (-south west) at ($(-south)-(#1/2,0)$); |
| 828 |
\coordinate (-south east) at ($(-south)+(#1/2,0)$); |
| 829 |
\coordinate (-north west) at ($(-north)-(#1/2,0)$); |
| 830 |
\coordinate (-north east) at ($(-north)+(#1/2,0)$); |
| 831 |
\coordinate (-in) at (0,0); |
| 832 |
\coordinate (-out) at (-in); |
| 833 |
\coordinate (-end) at (-out); |
| 834 |
\coordinate (-start) at (-in); |
| 835 |
\coordinate (-left) at (-west); |
| 836 |
\coordinate (-right) at (-east); |
| 837 |
|
| 838 |
\node [ground2,minimum width=#1] at (-south west) {}; |
| 839 |
\draw [ground2 texture,draw=none, pattern=custom north west lines,] (-south east) -- (-north east) -- ++(0,-5pt) -- ($(-south east)-(0,5pt)$ ) --cycle ; |
| 840 |
\draw [knJointStyle] (-south west) -- (-south east) -- (-north east) -- (-north west) -- cycle; |
| 841 |
} %end of code for this particular pic |
| 842 |
}, |
| 843 |
%=================================================== |
| 844 |
pics/base flat pivot/.style={ %simple flat ground with a pivot |
| 845 |
code={ |
| 846 |
\coordinate (-left) at (-1,0); |
| 847 |
\coordinate (-right) at (1,0); |
| 848 |
\coordinate (-center) at (0,0.175); %why this and not (0,0)? |
| 849 |
\coordinate (-north) at (0,0); |
| 850 |
\node [ground2,minimum width=2cm] at (-left) {}; % \draw [ground] (0,0) -- (2,0); |
| 851 |
\draw [knJointStyle] (-left) -- ($(-north)+(-\pivotRadius-1.5pt,0)$) arc (180:0:\pivotRadius+1.5pt) -- (-right); |
| 852 |
\draw [fill=white] (-north) circle (\pivotRadius); |
| 853 |
} %end of code for this particular pic |
| 854 |
}, |
| 855 |
%------------------------------------------ |
| 856 |
pics/frame pivot flat/.default=1cm, %simple flat frame with a pivot |
| 857 |
pics/frame pivot flat/.style={ %simple flat ground with a pivot % OKinman |
| 858 |
code={ |
| 859 |
\coordinate (-left) at (-#1/2,0); |
| 860 |
\coordinate (-right) at (#1/2,0); |
| 861 |
% \coordinate (-center) at (0,0.175); %why this and not (0,0)? |
| 862 |
\coordinate (-center) at (0,0); |
| 863 |
\coordinate (-north) at (0,0); |
| 864 |
\coordinate (-out) at (0,0); |
| 865 |
\coordinate (-end) at (-out); |
| 866 |
\coordinate (-in) at (0,0); |
| 867 |
\coordinate (-start) at (-in); |
| 868 |
\coordinate (-south) at (0,-\pivotRadius/2); |
| 869 |
\node [ground2,minimum width=#1] at (-left) {}; % \draw [ground] (0,0) -- (2,0); |
| 870 |
\draw [knJointStyle] (-left) -- ($(-north)+(-\pivotRadius-1.5pt,0)$) arc (180:0:\pivotRadius+1.5pt) -- (-right); |
| 871 |
\draw [fill=white] (-north) circle (\pivotRadius); |
| 872 |
} %end of code for this particular pic |
| 873 |
}, |
| 874 |
%=================================================== |
| 875 |
pics/frame pivot trapezium/.default=0.8cm, %trapezium frame with a pivot |
| 876 |
pics/frame pivot trapezium/.style={ %OKinman |
| 877 |
code={ |
| 878 |
\coordinate (-left) at (-#1/2,-#1/4); |
| 879 |
\coordinate (-right) at (#1/2,-#1/4); |
| 880 |
\coordinate (-center) at (0,0); |
| 881 |
\coordinate (-north) at ($(-center)+(90:#1*0.355)$); |
| 882 |
\coordinate (-in) at (-center); |
| 883 |
\coordinate (-start) at (-center); |
| 884 |
\coordinate (-out) at (-center); |
| 885 |
\coordinate (-end) at (-center); |
| 886 |
\coordinate (-south) at ($(-left)!0.5!(-right)$); |
| 887 |
\draw [knJointStyle, line join=round] (-left) -- ++(0:#1) -- ++(120:#1*0.7) -- ++(180:#1*0.3) -- cycle; |
| 888 |
\node at (-left) [ground2,minimum width=#1] {}; % \draw [ground] (0,0) -- (1,0); |
| 889 |
\draw [] (-center) circle (\pivotRadius); |
| 890 |
} %end of code for this particular pic |
| 891 |
}, |
| 892 |
%=================================================== |
| 893 |
pics/frame pivot rounded/.default=0.5cm, %rounded frame with a pivot |
| 894 |
pics/frame pivot rounded/.style={ %OKinman |
| 895 |
code={ |
| 896 |
\coordinate (-left) at (-#1/2,-#1/2); |
| 897 |
\coordinate (-right) at ( #1/2,-#1/2); |
| 898 |
\coordinate (-center) at (0,0); |
| 899 |
\coordinate (-in) at (-center); |
| 900 |
\coordinate (-out) at (-center); |
| 901 |
\coordinate (-end) at (-out); |
| 902 |
\coordinate (-start) at (-center); |
| 903 |
\coordinate (-south) at ($(-left)!0.5!(-right)$); |
| 904 |
\draw [knJointStyle, line join=round] (-left) -- ++(0:#1) -- ++(90:#1/2) arc (0:180:#1/2) node [midway,inner sep=0] (-north){} -- cycle; |
| 905 |
\node at (-left) [ground2,minimum width=#1] {}; %\draw [ground] (0,0) -- (0.5,0); |
| 906 |
\draw [] (-center) circle (\pivotRadius); |
| 907 |
} %end of code for this particular pic |
| 908 |
}, |
| 909 |
%=================================================== |
| 910 |
pics/frame pivot triangle/.default=0.7cm, %triangle frame with a pivot |
| 911 |
pics/frame pivot triangle/.style={ %OKinman |
| 912 |
code={ |
| 913 |
% \pgfmathsetmacro\myH{2*sin(60)} |
| 914 |
\pgfmathsetmacro\myH{1.3} |
| 915 |
\coordinate (-left) at (-#1/2,-#1/\myH); |
| 916 |
\coordinate (-right) at ( #1/2,-#1/\myH); |
| 917 |
\coordinate (-center) at (0,0); |
| 918 |
\coordinate (-north) at (-center); |
| 919 |
\coordinate (-in) at (-center); |
| 920 |
\coordinate (-end) at (-in); |
| 921 |
\coordinate (-start) at (-in); |
| 922 |
\coordinate (-out) at (-center); |
| 923 |
% \coordinate (-south) at ($(-left)!0.5!(-right)$); %This is failing in the book!!! Problem was babel package with french option! |
| 924 |
\coordinate (-south) at ($0.5*(-left)+0.5*(-right)$); %so use this... :-( |
| 925 |
|
| 926 |
\draw [knJointStyle, line join=round] (-center) -- (-left) -- (-right) -- cycle; |
| 927 |
\node at (-left) [ground2,minimum width=#1] {};% \draw [ground] (0,0) -- (0.5,0); |
| 928 |
\draw [fill=white] (-center) circle (\pivotRadius); |
| 929 |
} %end of code for this particular pic |
| 930 |
}, |
| 931 |
%=================================================== |
| 932 |
pics/frame dual pivot slide/.style={ %OKinman |
| 933 |
%Arg 1 -> width [2cm] |
| 934 |
%Arg 2 -> fraction of placement from -0.25 to +0.25 [0] %default is in the center |
| 935 |
%Arg 3 -> fraction size of cursor of frame [0.5] %But there sre max and min absolute sizes |
| 936 |
code={ |
| 937 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 938 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 939 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 940 |
\readlist\myArgs{\allArgs} |
| 941 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\fLength} {\def\fLength{}} |
| 942 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\fFraction}{\def\fFraction{}} |
| 943 |
\ifthenelse{ \myArgslen > 2} {\itemtomacro\myArgs[3]\fCursor}{\def\fCursor{}} |
| 944 |
%Test if any parameter is blank and put the default in that case |
| 945 |
\ifthenelse{ \equal{\fLength}{} }{\def\fLength{2cm}} {} |
| 946 |
\ifthenelse{ \equal{\fFraction}{}}{\def\fFraction{0}} {} |
| 947 |
\ifthenelse{ \equal{\fCursor}{}}{\def\fCursor{0.5}} {} |
| 948 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 949 |
|
| 950 |
\dimendef\myL=0 %first create a dimension register... |
| 951 |
% \pgfmathsetlength\myL{max(2*\pivotRadius,\fCursor*\fLength)} %min size |
| 952 |
% \pgfmathsetlength\myL{min(1cm,\fCursor*\fLength)} %max size |
| 953 |
\pgfmathsetlength\myL{max(2*\pivotRadius,min(1cm,\fCursor*\fLength)} %min/max size |
| 954 |
|
| 955 |
|
| 956 |
%limit excursion of cursor |
| 957 |
\pgfmathsetmacro\fFraction{min(0.25,\fFraction)} |
| 958 |
\pgfmathsetmacro\fFraction{max(-0.25,\fFraction)} |
| 959 |
|
| 960 |
\coordinate (-left) at (-\fLength/2,0); |
| 961 |
\coordinate (-right) at (\fLength/2,0); |
| 962 |
\coordinate (-center) at ($(-left)!0.5!(-right)$); |
| 963 |
\coordinate (-in) at (\fFraction*\fLength,0); %proportion of displacement |
| 964 |
\coordinate (-north) at ($(-left)!0.5!(-right)+(0,0.25)$); |
| 965 |
\coordinate (-start) at (-in); |
| 966 |
\coordinate (-out) at (-in); |
| 967 |
\coordinate (-end) at (-out); |
| 968 |
\coordinate (-south) at ($(-left)!0.5!(-right)-(0,0.25)$); |
| 969 |
\draw [line width=1pt,fill=\LinkFillColor] ($(-in)+(-\myL/2,\gapGround-0.25)$) rectangle ++(\myL,0.5-2*\gapGround); |
| 970 |
\node [ground2,minimum width=\fLength] at (-\fLength/2,-0.25) {}; % \draw [ground] (0,0) -- (2,0); |
| 971 |
\node [ground2,minimum width=\fLength,anchor=south west] at (-\fLength/2,0.25) {}; %\draw [ground] (2,0.5) -- (0,0.5); |
| 972 |
\draw [knJointStyle] (-\fLength/2,0.25) -- (\fLength/2,0.25); |
| 973 |
\draw [knJointStyle] (-\fLength/2,-0.25) -- (\fLength/2,-0.25); |
| 974 |
% \coordinate (-center) at (1,0.25); |
| 975 |
\draw [fill=white] (-in) circle (\pivotRadius); |
| 976 |
} %end of code for this particular pic |
| 977 |
}, |
| 978 |
%---------------------------------------------------------- |
| 979 |
} % end of base/frame styles |
| 980 |
|
| 981 |
|
| 982 |
\tikzset{ %definitions/pics for SYMBOLS INSPIRED FROM ISO 3952-1 |
| 983 |
%=============================================================== |
| 984 |
pics/revolute pair planar/.style={ % ISO |
| 985 |
%Arg 1 -> destination point |
| 986 |
%Arg 2 -> boolean: add or not COM (discarded -1 in legacy for a special case... :-( ) |
| 987 |
%Arg 3 -> boolean: add or not pivot in destination (default is 1 yes) |
| 988 |
code={ |
| 989 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 990 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/} \def\noArgs{1} \def\addStartPivot{0} } {\def\allArgs{#1} \def\noArgs{0} \def\addStartPivot{1}} |
| 991 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 992 |
\readlist\myArgs{\allArgs} |
| 993 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\endPoint} {\def\endPoint{}} |
| 994 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\dCOM} {\def\dCOM{} } |
| 995 |
\ifthenelse{ \myArgslen > 2} {\itemtomacro\myArgs[3]\addEndPivot}{\def\addEndPivot{} } |
| 996 |
%Test if any parameter is blank and put the default in that case |
| 997 |
\ifthenelse{ \equal{\endPoint}{} }{\def\endPoint{15:1}}{} |
| 998 |
\ifthenelse{ \equal{\dCOM}{} }{\def\dCOM{0}} {} |
| 999 |
\ifthenelse{ \equal{\addEndPivot}{}}{\def\addEndPivot{1}} {} |
| 1000 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 1001 |
|
| 1002 |
\coordinate (-in) at (0,0); |
| 1003 |
\coordinate (-start) at (-in); |
| 1004 |
\coordinate (-end) at (\endPoint); |
| 1005 |
\coordinate (-out) at (-end); |
| 1006 |
% \coordinate (-center) at ($(-start)!0.5!(-end)$); %This is failing... :-( |
| 1007 |
\coordinate (-center) at ($0.5*(-start)+0.5*(-end)$); %... so use this |
| 1008 |
|
| 1009 |
\draw [knLinkStyle] (-in) -- (-end); |
| 1010 |
%Test for a special case when no params are passed and append a second arm |
| 1011 |
\ifnum \noArgs=1 |
| 1012 |
\draw [knLinkStyle] (-end) -- ++(-10:0.7) coordinate (-end2); |
| 1013 |
\fi |
| 1014 |
|
| 1015 |
\ifthenelse{\addStartPivot=1}{ |
| 1016 |
\draw [knLinkStyle,fill=white] (-start) circle (\pivotRadius); |
| 1017 |
}{} |
| 1018 |
\ifthenelse{\addEndPivot=1}{ |
| 1019 |
\draw [knLinkStyle,fill=white] (-end) circle (\pivotRadius); |
| 1020 |
}{} |
| 1021 |
|
| 1022 |
\ifthenelse{\dCOM=1}{ \addCOM }{} |
| 1023 |
|
| 1024 |
} %end of code for this particular pic |
| 1025 |
}, |
| 1026 |
%=============================================================== |
| 1027 |
% |
| 1028 |
pics/revolute pair spatial/.default={45:1cm/0/0}, %ISO revolute pair - 3D %FOR CONSISTENCY PASSED POINT SHOULD NOT BE IN () CORRECT THAT IN CALLER |
| 1029 |
%param: point for link end (default: (45:1cm)); |
| 1030 |
%param: direction of end arm: 0 top, 1 bottom (default: 0); |
| 1031 |
%param: axle fixed to some frame: 0 not fixed, 1 fixed (default: 0) |
| 1032 |
pics/revolute pair spatial/.style args={#1/#2/#3}{ % ISO |
| 1033 |
% TODO: should accept partial parameters |
| 1034 |
code={ |
| 1035 |
\def\invGap{3pt} %inner separation of body 2 from limits of body 1 |
| 1036 |
\def\outvGap{6pt} %outer gap of axle (can be zero in fexed variant) |
| 1037 |
\def\argA{#1} |
| 1038 |
\def\argB{#2} \def\armTop {0} |
| 1039 |
\def\argC{#3} \def\fFixed {1} |
| 1040 |
|
| 1041 |
\coordinate (-center) at (\currentcoordinate); |
| 1042 |
|
| 1043 |
\def\rectW{0.6cm} |
| 1044 |
\def\rectH{0.4cm} |
| 1045 |
|
| 1046 |
\if\argC\fFixed |
| 1047 |
\def\outvGap{0pt} |
| 1048 |
\fi |
| 1049 |
|
| 1050 |
%NB. If param 1 is passed as literal its effect is local, if by a node name, global! |
| 1051 |
%That is why default parameter always has local referencing |
| 1052 |
%SO FOR EASIER LOCAL REPRESENTATIONS CENTER THE pic AROUND (0,0) |
| 1053 |
%But that may complicate anchoring.... |
| 1054 |
|
| 1055 |
|
| 1056 |
\coordinate (-in) at ($(-center) - (0:\rectW/2+\outvGap+\invGap)$); |
| 1057 |
\coordinate (-in2) at ($(-center) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1058 |
\coordinate (-start) at (-in); |
| 1059 |
\coordinate (-start2) at (-in2); |
| 1060 |
\coordinate (-end) at (#1); %Note that this is an absolute point, not relative to -center |
| 1061 |
\coordinate (-out) at (-end); |
| 1062 |
\coordinate (-north) at ($(-center) + (0,\rectH/2)$); |
| 1063 |
\coordinate (-south) at ($(-center) - (0,\rectH/2)$); |
| 1064 |
\coordinate (-east) at ($(-center) + (0:\rectW/2+\invGap)$); |
| 1065 |
\coordinate (-west) at ($(-center) - (0:\rectW/2+\invGap)$); |
| 1066 |
|
| 1067 |
\if\argC\fFixed %expected to have a frame in one end - so shift all coordinate names |
| 1068 |
\coordinate (-in) at ($(-in) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1069 |
\coordinate (-in2) at ($(-in2) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1070 |
\coordinate (-start) at (-in); |
| 1071 |
\coordinate (-start2) at (-in2); |
| 1072 |
\coordinate (-end) at ($(-end) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1073 |
\coordinate (-out) at (-end); |
| 1074 |
\coordinate (-north) at ($(-north) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1075 |
\coordinate (-south) at ($(-south) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1076 |
\coordinate (-east) at ($(-east) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1077 |
\coordinate (-west) at ($(-west) + (0:\rectW/2+\outvGap+\invGap)$); |
| 1078 |
\fi |
| 1079 |
|
| 1080 |
%\node[inner sep=0, minimum width=\rectW+2*\outvGap+2*\invGap,circle,opacity=0.5] (-bbox) at (0,0) {}; |
| 1081 |
% previous node created to attempt anchoring pic by any of it internal nodes |
| 1082 |
% but it only works if not defined after other internal coordinates. Only explicit |
| 1083 |
% measumrents, otherwise the anchor is always at (0,0) and |
| 1084 |
% you need shift to anchor the pic :-( Moreover, only the node is relocated by anchoring |
| 1085 |
% and not the other drawings :-(((( Check more at |
| 1086 |
% https://tex.stackexchange.com/questions/185279/anchoring-tikz-pics |
| 1087 |
|
| 1088 |
|
| 1089 |
% \kmpgfextractangle{\nAng}{-end} %not #1, needs to be a node name :-( |
| 1090 |
% There is problem when pic is named because then -end is not found :-(( |
| 1091 |
% So I need to do the calculation myself |
| 1092 |
|
| 1093 |
\newdimen\XCoord |
| 1094 |
\newdimen\YCoord |
| 1095 |
\newdimen\XCoordN |
| 1096 |
\newdimen\YCoordN |
| 1097 |
\newdimen\XCoordS |
| 1098 |
\newdimen\YCoordS |
| 1099 |
\newdimen\XCoordiN |
| 1100 |
\newdimen\YCoordiN |
| 1101 |
|
| 1102 |
% \path ($#1-(-north) - (-in)$); \pgfgetlastxy{\XCoord}{\YCoord}; |
| 1103 |
% \pgfmathparse{atan2(\YCoord,\XCoord)} |
| 1104 |
% \edef\nAng{\pgfmathresult}% |
| 1105 |
% |
| 1106 |
% \path ($#1-(-south) - (-in)$); \pgfgetlastxy{\XCoord}{\YCoord}; |
| 1107 |
% \pgfmathparse{atan2(\YCoord,\XCoord)} |
| 1108 |
% \edef\sAng{\pgfmathresult}% |
| 1109 |
|
| 1110 |
%But that is a problem because \pgfgetlastxy works with absolute coordinates in the figure, which is a problem when there are transformations on parts of the image :-( |
| 1111 |
%So we need another trick to calculate the angles: |
| 1112 |
|
| 1113 |
% \path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1114 |
% \path (-north); \pgfgetlastxy{\XCoordN} {\YCoordN}; |
| 1115 |
% \path (-south); \pgfgetlastxy{\XCoordS} {\YCoordS}; |
| 1116 |
% \path #1; \pgfgetlastxy{\XCoordiN}{\YCoordiN}; |
| 1117 |
|
| 1118 |
%But this previous solution works for only translations (but not all rotations) |
| 1119 |
%So there is this one using the custom \gettikzxy: |
| 1120 |
|
| 1121 |
% \gettikzxy{(-in)} {\XCoord} {\YCoord} |
| 1122 |
\path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1123 |
\gettikzxy{(-north)} {\XCoordN} {\YCoordN} |
| 1124 |
\gettikzxy{(-south)} {\XCoordS} {\YCoordS} |
| 1125 |
\gettikzxy{(-end)} {\XCoordiN}{\YCoordiN} |
| 1126 |
|
| 1127 |
\pgfmathparse{atan2(\YCoordiN-\YCoordN,\XCoordiN-\XCoordN)} |
| 1128 |
\edef\nAng{\pgfmathresult}% |
| 1129 |
|
| 1130 |
\pgfmathparse{atan2(\YCoordiN-\YCoordS,\XCoordiN-\XCoordS)} |
| 1131 |
\edef\sAng{\pgfmathresult}% |
| 1132 |
|
| 1133 |
% In case I wanted the vector length |
| 1134 |
% \pgfmathparse{veclen(\XCoord...,\YCoord...)} |
| 1135 |
% \edef\lRadius{\pgfmathresult}% |
| 1136 |
|
| 1137 |
\draw [knLineCap,knLinkStyle] (-in) -- (-in2); % horiz axis. Round line extremities for better connection |
| 1138 |
\draw [knJointStyle] ($(-in)+(\outvGap,-\rectH/2-1pt)$) -- ++(90:\rectH+2pt); %vert bar left |
| 1139 |
\draw [knJointStyle] ($(-in2)+(-\outvGap,-\rectH/2-1pt)$) -- ++(90:\rectH+2pt); %vert bar right |
| 1140 |
|
| 1141 |
\if\argC\fFixed % two lines |
| 1142 |
\draw [knJointStyle] ($(-in)+(\outvGap, \rectH/2)+(\invGap,0)$) -- ++(\rectW,0); |
| 1143 |
\draw [knJointStyle] ($(-in)+(\outvGap,-\rectH/2)+(\invGap,0)$) -- ++(\rectW,0); |
| 1144 |
\else % a full rectangle |
| 1145 |
\draw [knJointStyle] ($(-in)+(\outvGap,-\rectH/2)+(\invGap,0)$) rectangle ++(\rectW,\rectH); %rectangle |
| 1146 |
\fi |
| 1147 |
|
| 1148 |
\if\argB\armTop |
| 1149 |
\draw [knLineCap,knLinkStyle] (-north) -- (-end); %arm |
| 1150 |
\fill [] (-north) -- ++(\lockRadius,0) arc (0:\nAng:\lockRadius) -- cycle; %lock, as arc |
| 1151 |
\else |
| 1152 |
\draw [knLineCap,knLinkStyle] (-south) -- (-end); %arm |
| 1153 |
\fill [] (-south) -- ++(\lockRadius,0) arc (0:\sAng:\lockRadius) -- cycle; %lock, as arc |
| 1154 |
\fi |
| 1155 |
} %end of code for this particular pic |
| 1156 |
}, |
| 1157 |
%----------------------------------- |
| 1158 |
linear pair/.pic={\pic {prismatic pair={#1}};}, %a synonym for prismatic pair. %always use #1 independetly of the number or arguments! |
| 1159 |
pics/prismatic pair/.default={45:1cm/0}, %ISO linear pair %FOR CONSISTENCY PASSED POINT SHOULD NOT BE IN () CHECK THAT IN CALLER |
| 1160 |
%param: point for link end (default: (45:1cm)); |
| 1161 |
%param: direction of end arm: 0 top, 1 bottom (default: 0); |
| 1162 |
pics/prismatic pair/.style args={#1/#2}{ % ISO |
| 1163 |
code={ |
| 1164 |
\def\argA{(#1)} |
| 1165 |
\def\argB{#2} \def\armTop {0} |
| 1166 |
|
| 1167 |
\def\endGap{8pt} |
| 1168 |
|
| 1169 |
\def\rectW{0.6cm} |
| 1170 |
\def\rectH{0.4cm} |
| 1171 |
|
| 1172 |
%NB. If param 1 is passed as literal its effect is local, if by a node name, global! |
| 1173 |
%That is why default parameter always has local referencing |
| 1174 |
%SO FOR EASIER LOCAL REPRESENTATIONS CENTER THE pic AROUND (0,0) |
| 1175 |
%But that may complicate anchoring.... |
| 1176 |
|
| 1177 |
% \coordinate (-center) at (\currentcoordinate); |
| 1178 |
\coordinate (-center) at (0,0); |
| 1179 |
\coordinate (-east) at ($(-center) + (0:\rectW/2)$); |
| 1180 |
\coordinate (-west) at ($(-center) - (0:\rectW/2)$); |
| 1181 |
\coordinate (-in) at ($(-west) - (0:\endGap)$); |
| 1182 |
\coordinate (-in2) at ($(-east) + (0:\endGap)$); |
| 1183 |
\coordinate (-start) at (-in); |
| 1184 |
\coordinate (-start2) at (-in2); |
| 1185 |
\coordinate (-end) at (#1); |
| 1186 |
\coordinate (-out) at (-end); |
| 1187 |
\coordinate (-north) at ($(-center) + (0,\rectH/2)$); |
| 1188 |
\coordinate (-south) at ($(-center) - (0,\rectH/2)$); |
| 1189 |
|
| 1190 |
%\node[inner sep=0, minimum width=\rectW,circle,opacity=0.5] (-bbox) at (0,0) {}; |
| 1191 |
% previous node created to attempt anchoring pic by any of it internal nodes |
| 1192 |
% but it only works if not defined after other internal coordinates. Only explicit |
| 1193 |
% measumrents, otherwise the anchor is always at (0,0) and |
| 1194 |
% you need shift to anchor the pic :-( Moreover, only the node is relocated by anchoring |
| 1195 |
% and not the other drawings :-(((( Check more at |
| 1196 |
% https://tex.stackexchange.com/questions/185279/anchoring-tikz-pics |
| 1197 |
|
| 1198 |
|
| 1199 |
% \kmpgfextractangle{\nAng}{-end} %not #1, needs to be a node name :-( |
| 1200 |
% There is problem when pic is named because then -end is not found :-(( |
| 1201 |
% So I need to do the calculation myself |
| 1202 |
|
| 1203 |
\newdimen\XCoord |
| 1204 |
\newdimen\YCoord |
| 1205 |
\newdimen\XCoordN |
| 1206 |
\newdimen\YCoordN |
| 1207 |
\newdimen\XCoordS |
| 1208 |
\newdimen\YCoordS |
| 1209 |
\newdimen\XCoordiN |
| 1210 |
\newdimen\YCoordiN |
| 1211 |
|
| 1212 |
|
| 1213 |
% \gettikzxy{(-in)} {\XCoord} {\YCoord} |
| 1214 |
\path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1215 |
\gettikzxy{(-north)} {\XCoordN} {\YCoordN} |
| 1216 |
\gettikzxy{(-south)} {\XCoordS} {\YCoordS} |
| 1217 |
\gettikzxy{(#1)} {\XCoordiN}{\YCoordiN} |
| 1218 |
|
| 1219 |
\pgfmathparse{atan2(\YCoordiN-\YCoordN,\XCoordiN-\XCoordN)} |
| 1220 |
\edef\nAng{\pgfmathresult}% |
| 1221 |
|
| 1222 |
\pgfmathparse{atan2(\YCoordiN-\YCoordS,\XCoordiN-\XCoordS)} |
| 1223 |
\edef\sAng{\pgfmathresult}% |
| 1224 |
|
| 1225 |
% In case I wanted the vector length |
| 1226 |
% \pgfmathparse{veclen(\XCoord...,\YCoord...)} |
| 1227 |
% \edef\lRadius{\pgfmathresult}% |
| 1228 |
|
| 1229 |
\coordinate (llCorner) at ($(-center) - (\rectW/2,\rectH/2)$); |
| 1230 |
|
| 1231 |
\draw [knJointStyle] (llCorner) rectangle ++(\rectW, \rectH); |
| 1232 |
\draw [knLinkStyle] (-in) -- (-west) (-in2) -- (-east); |
| 1233 |
|
| 1234 |
\if\argB\armTop |
| 1235 |
\draw [knLineCap,knLinkStyle] (-north) -- (-end);%arm |
| 1236 |
\fill [] (-north) -- ++(\lockRadius,0) arc (0:\nAng:\lockRadius) -- cycle; %lock, as arc |
| 1237 |
\else |
| 1238 |
\draw [knLineCap,knLinkStyle] (-south) -- (-end);%arm |
| 1239 |
\fill [] (-south) -- ++(\lockRadius,0) arc (0:\sAng:\lockRadius) -- cycle; %lock, as arc |
| 1240 |
\fi |
| 1241 |
} %end of code for this particular pic |
| 1242 |
}, |
| 1243 |
%=============================================================== |
| 1244 |
pics/spherical pair/.style={ % 2d socket and ball pair ISO |
| 1245 |
code={ |
| 1246 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 1247 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 1248 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 1249 |
\readlist\myArgs{\allArgs} |
| 1250 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\angR} {\def\angR{}} |
| 1251 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\rFactor} {\def\rFactor{}} |
| 1252 |
\ifthenelse{ \myArgslen > 2} {\itemtomacro\myArgs[3]\lLenA} {\def\lLenA{}} |
| 1253 |
\ifthenelse{ \myArgslen > 3} {\itemtomacro\myArgs[4]\lLenB} {\def\lLenB{}} |
| 1254 |
\ifthenelse{ \myArgslen > 4} {\itemtomacro\myArgs[5]\atIn} {\def\atIn{}} |
| 1255 |
%Test if any parameter is blank and put the default in that case |
| 1256 |
\ifthenelse{ \equal{\angR}{}} {\def\angR{15}} {} %default angle of end arm |
| 1257 |
\ifthenelse{ \equal{\rFactor}{}} {\def\rFactor{1}} {} %default scale factor for ball |
| 1258 |
\ifthenelse{ \equal{\lLenA}{}} {\def\lLenA{0.8}} {} %default left arm length |
| 1259 |
\ifthenelse{ \equal{\lLenB}{}} {\def\lLenB{0.8}} {} %default right arm length |
| 1260 |
\ifthenelse{ \equal{\atIn}{}} {\def\atIn{0}} {} %1 to attach to -in instead of -center |
| 1261 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 1262 |
|
| 1263 |
\def\gapBS{1.5pt} %gap between ball and socket |
| 1264 |
\def\ballRadius{\rFactor*\pivotRadius} |
| 1265 |
\def\tmpIn{(\lLenA,0)} %The temporary in for a shift if required |
| 1266 |
\def\inShift{(0,0)} %Default internal shift (null) |
| 1267 |
\ifthenelse{ \equal{\atIn}{1}} {\def\inShift{\tmpIn}} {} %new internal shift if attaching to -in |
| 1268 |
|
| 1269 |
% TODO this next option should also be available in other pics |
| 1270 |
\begin{scope}[shift={\inShift}] % to adjust the anchoring point as needed |
| 1271 |
\coordinate (-center) at (0,0); |
| 1272 |
\draw [knLinkStyle] (-center) -- ++(-\lLenA,0) coordinate (-in); |
| 1273 |
\fill [] ($(-center)-(\ballRadius+\gapBS,0)$) -- ++(-\ballRadius,0) arc (180:30:\ballRadius) -- cycle; %lock left |
| 1274 |
% \draw [vsISOLinkStyle,fill=white] (-center) arc (90:270:0.2); %socket |
| 1275 |
\draw [knLinkStyle,fill=white] ([shift=(60:\ballRadius+\gapBS)]-center) arc (60:300:\ballRadius+\gapBS); %This is way too smart: check https://tex.stackexchange.com/questions/66216/draw-arc-in-tikz-when-center-of-circle-is-specified |
| 1276 |
\draw [knLinkStyle] (-center) -- ++(\angR:\lLenB) coordinate (-end); %right arm |
| 1277 |
\fill [] ($ (-center) + (\angR:\ballRadius) $) -- ++(\angR:\ballRadius) arc (\angR:-120:\ballRadius) -- cycle; %lock right |
| 1278 |
\draw [knLinkStyle,fill=white] (-center) circle (\ballRadius); %ball |
| 1279 |
|
| 1280 |
\coordinate (-start) at (-in); |
| 1281 |
\coordinate (-out) at (-end); |
| 1282 |
\end{scope} |
| 1283 |
|
| 1284 |
} %end of code for this particular pic |
| 1285 |
}, |
| 1286 |
%------------------------------------------ |
| 1287 |
%%%% I AM HERE ... DURING THE MIGRATION TO ISO |
| 1288 |
%=============================================================== |
| 1289 |
% |
| 1290 |
pics/helical pair/.default={45:1cm/0}, % |
| 1291 |
%param: point for link end (default: (45:1cm)); |
| 1292 |
%param: direction of end arm: 0 top, 1 bottom (default: 0); |
| 1293 |
pics/helical pair/.style args={#1/#2}{ % |
| 1294 |
code={ |
| 1295 |
\def\argA{(#1)} |
| 1296 |
\def\argB{#2} \def\armTop {0} |
| 1297 |
|
| 1298 |
\def\endGap{8pt} |
| 1299 |
|
| 1300 |
\def\rectW{0.6cm} |
| 1301 |
\def\rectH{0.4cm} |
| 1302 |
|
| 1303 |
%NB. If param 1 is passed as literal its effect is local, if by a node name, global! |
| 1304 |
%That is why default parameter always has local referencing |
| 1305 |
%SO FOR EASIER LOCAL REPRESENTATIONS CENTER THE pic AROUND (0,0) |
| 1306 |
%But that may complicate anchoring.... |
| 1307 |
|
| 1308 |
% \coordinate (-center) at (\currentcoordinate); |
| 1309 |
\coordinate (-center) at (0,0); |
| 1310 |
\coordinate (-east) at ($(-center) + (0:\rectW/2)$); |
| 1311 |
\coordinate (-west) at ($(-center) - (0:\rectW/2)$); |
| 1312 |
\coordinate (-in) at ($(-west) - (0:\endGap)$); |
| 1313 |
\coordinate (-in2) at ($(-east) + (0:\endGap)$); |
| 1314 |
\coordinate (-start) at (-in); |
| 1315 |
\coordinate (-start2) at (-in2); |
| 1316 |
\coordinate (-end) at (#1); |
| 1317 |
\coordinate (-out) at (-end); |
| 1318 |
\coordinate (-north) at ($(-center) + (0,\rectH/2)$); |
| 1319 |
\coordinate (-south) at ($(-center) - (0,\rectH/2)$); |
| 1320 |
|
| 1321 |
\node[inner sep=0, minimum width=\rectW,circle,opacity=0.5] (-bbox) at (0,0) {}; |
| 1322 |
% previous node created to attempt anchoring pic by any of it internal nodes |
| 1323 |
% but it only works if not defined after other internal coordinates. Only explicit |
| 1324 |
% measumrents, otherwise the anchor is always at (0,0) and |
| 1325 |
% you need shift to anchor the pic :-( Moreover, only the node is relocated by anchoring |
| 1326 |
% and not the other drawings :-(((( Check more at |
| 1327 |
% https://tex.stackexchange.com/questions/185279/anchoring-tikz-pics |
| 1328 |
|
| 1329 |
|
| 1330 |
% \kmpgfextractangle{\nAng}{-end} %not #1, needs to be a node name :-( |
| 1331 |
% There is problem when pic is named because then -end is not found :-(( |
| 1332 |
% So I need to do the calculation myself |
| 1333 |
|
| 1334 |
\newdimen\XCoord |
| 1335 |
\newdimen\YCoord |
| 1336 |
\newdimen\XCoordN |
| 1337 |
\newdimen\YCoordN |
| 1338 |
\newdimen\XCoordS |
| 1339 |
\newdimen\YCoordS |
| 1340 |
\newdimen\XCoordiN |
| 1341 |
\newdimen\YCoordiN |
| 1342 |
|
| 1343 |
|
| 1344 |
% \gettikzxy{(-in)} {\XCoord} {\YCoord} |
| 1345 |
\path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1346 |
\gettikzxy{(-north)} {\XCoordN} {\YCoordN} |
| 1347 |
\gettikzxy{(-south)} {\XCoordS} {\YCoordS} |
| 1348 |
\gettikzxy{(#1)} {\XCoordiN}{\YCoordiN} |
| 1349 |
|
| 1350 |
\pgfmathparse{atan2(\YCoordiN-\YCoordN,\XCoordiN-\XCoordN)} |
| 1351 |
\edef\nAng{\pgfmathresult}% |
| 1352 |
|
| 1353 |
\pgfmathparse{atan2(\YCoordiN-\YCoordS,\XCoordiN-\XCoordS)} |
| 1354 |
\edef\sAng{\pgfmathresult}% |
| 1355 |
|
| 1356 |
% In case I wanted the vector length |
| 1357 |
% \pgfmathparse{veclen(\XCoord...,\YCoord...)} |
| 1358 |
% \edef\lRadius{\pgfmathresult}% |
| 1359 |
|
| 1360 |
\coordinate (llCorner) at ($(-center) - (\rectW/2,\rectH/2)$); |
| 1361 |
|
| 1362 |
\draw [knJointStyle] (llCorner) rectangle ++(\rectW, \rectH); |
| 1363 |
\draw [knLinkStyle] (-in) -- (-west) (-in2) -- (-east); |
| 1364 |
% \draw [knLinkStyle, decoration={snake,segment length=\rectW/2.75,amplitude=\rectH/3.5}] (-west) decorate {--(-east)}; |
| 1365 |
%The previous decoration is not adjusting to scale so using a compopund of sin/cos :-( |
| 1366 |
\draw [knLinkStyle] (-west) sin |
| 1367 |
($(-west)+(\rectW/12,\rectH/4)$) cos |
| 1368 |
($(-west)+(2*\rectW/12,0)$) sin |
| 1369 |
($(-west)+(3*\rectW/12,-\rectH/4)$) cos |
| 1370 |
($(-west)+(4*\rectW/12,0)$) sin |
| 1371 |
($(-west)+(5*\rectW/12,\rectH/4)$) cos |
| 1372 |
($(-west)+(6*\rectW/12,0)$) sin |
| 1373 |
($(-west)+(7*\rectW/12,-\rectH/4)$) cos |
| 1374 |
($(-west)+(8*\rectW/12,0)$) sin |
| 1375 |
($(-west)+(9*\rectW/12,\rectH/4)$) cos |
| 1376 |
($(-west)+(10*\rectW/12,0)$) sin |
| 1377 |
($(-west)+(11*\rectW/12,-\rectH/4)$) cos |
| 1378 |
(-east); |
| 1379 |
|
| 1380 |
\if\argB\armTop |
| 1381 |
\draw [knLineCap,knLinkStyle] (-north) -- (-end); %arm |
| 1382 |
\fill [] (-north) -- ++(\lockRadius,0) arc (0:\nAng:\lockRadius) -- cycle; %lock, as arc |
| 1383 |
\else\ |
| 1384 |
\draw [knLineCap,knLinkStyle] (-south) -- (-end); %arm |
| 1385 |
\fill [] (-south) -- ++(\lockRadius,0) arc (0:\sAng:\lockRadius) -- cycle; %lock, as arc |
| 1386 |
\fi |
| 1387 |
} %end of code for this particular pic |
| 1388 |
}, |
| 1389 |
%------------------------------------------ |
| 1390 |
pics/cylindrical pair/.default={45:1cm/0},% |
| 1391 |
%param: point for link end (default: (45:1cm)); |
| 1392 |
%param: direction of end arm: 0 top, 1 bottom (default: 0); |
| 1393 |
pics/cylindrical pair/.style args={#1/#2}{ % cylindrical link ISO |
| 1394 |
code={ |
| 1395 |
\def\argA{(#1)} |
| 1396 |
\def\argB{#2} \def\armTop {0} |
| 1397 |
|
| 1398 |
\def\endGap{0.7cm} %Extension of axis for each side |
| 1399 |
|
| 1400 |
\def\rectW{0.6cm} %width |
| 1401 |
\def\rectH{0.4cm} %height |
| 1402 |
|
| 1403 |
\coordinate (-center) at (0,0); |
| 1404 |
\coordinate (-in) at ($(-center) - (0:\endGap)$); |
| 1405 |
\coordinate (-in2) at ($(-center) + (0:\endGap)$); |
| 1406 |
\coordinate (-start) at (-in); |
| 1407 |
\coordinate (-start2) at (-in2); |
| 1408 |
\coordinate (-end) at (#1); |
| 1409 |
\coordinate (-out) at (-end); |
| 1410 |
\coordinate (-east) at (-in2); |
| 1411 |
\coordinate (-west) at (-in); |
| 1412 |
\coordinate (-north) at ($(-center) + (0,\rectH/2)$); |
| 1413 |
\coordinate (-south) at ($(-center) - (0,\rectH/2)$); |
| 1414 |
|
| 1415 |
% \kmpgfextractangle{\nAng}{-end} %not #1, needs to be a node name :-( |
| 1416 |
% There is problem when pic is named because then -end is not found :-(( |
| 1417 |
% So I need to do the calculation myself |
| 1418 |
|
| 1419 |
\newdimen\XCoord |
| 1420 |
\newdimen\YCoord |
| 1421 |
\newdimen\XCoordN |
| 1422 |
\newdimen\YCoordN |
| 1423 |
\newdimen\XCoordS |
| 1424 |
\newdimen\YCoordS |
| 1425 |
\newdimen\XCoordiN |
| 1426 |
\newdimen\YCoordiN |
| 1427 |
|
| 1428 |
% \gettikzxy{(-in)} {\XCoord} {\YCoord} |
| 1429 |
\path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1430 |
\gettikzxy{(-north)} {\XCoordN} {\YCoordN} |
| 1431 |
\gettikzxy{(-south)} {\XCoordS} {\YCoordS} |
| 1432 |
\gettikzxy{(#1)} {\XCoordiN}{\YCoordiN} |
| 1433 |
|
| 1434 |
\pgfmathparse{atan2(\YCoordiN-\YCoordN,\XCoordiN-\XCoordN)} |
| 1435 |
\edef\nAng{\pgfmathresult}% angle in north arm |
| 1436 |
|
| 1437 |
\pgfmathparse{atan2(\YCoordiN-\YCoordS,\XCoordiN-\XCoordS)} |
| 1438 |
\edef\sAng{\pgfmathresult}% angle in south arm |
| 1439 |
|
| 1440 |
% In case I wanted the vector length |
| 1441 |
% \pgfmathparse{veclen(\XCoord...,\YCoord...)} |
| 1442 |
% \edef\lRadius{\pgfmathresult}% |
| 1443 |
|
| 1444 |
\coordinate (llCorner) at ($(-center) - (\rectW/2,\rectH/2)$); |
| 1445 |
|
| 1446 |
%Draw the joint parts |
| 1447 |
\draw [knJointStyle] (llCorner) -- ++(\rectW, 0); |
| 1448 |
\draw [knJointStyle] (llCorner) ++(0, \rectH) -- ++(\rectW, 0); |
| 1449 |
%Draw the link (axis) part |
| 1450 |
\draw [knLinkStyle] (-in) -- (-in2); |
| 1451 |
|
| 1452 |
\if\argB\armTop |
| 1453 |
\draw [knLineCap,knLinkStyle] (-north) -- (-end); %arm |
| 1454 |
\fill [] (-north) -- ++(\lockRadius,0) arc (0:\nAng:\lockRadius) -- cycle; %lock, as arc |
| 1455 |
\else\ |
| 1456 |
\draw [knLineCap,knLinkStyle] (-south) -- (-end); %arm |
| 1457 |
\fill [] (-south) -- ++(\lockRadius,0) arc (0:\sAng:\lockRadius) -- cycle; %lock, as arc |
| 1458 |
\fi |
| 1459 |
} %end of code for this particular pic |
| 1460 |
}, |
| 1461 |
%------------------------------------------ |
| 1462 |
pics/cylindrical pair F/.default={90:0.75cm},% |
| 1463 |
%param: point for link end (default: (90:0.75cm)); |
| 1464 |
pics/cylindrical pair F/.style args={#1}{ % cylindrical pair in Frontal view ISO |
| 1465 |
code={ |
| 1466 |
\def\diam{0.2cm} %radius |
| 1467 |
\coordinate (-center) at (0,0); |
| 1468 |
\coordinate (-in) at (-center); |
| 1469 |
\coordinate (-start) at (-in); |
| 1470 |
\coordinate (-out) at (#1); |
| 1471 |
\coordinate (-end) at (-out); |
| 1472 |
\draw [knLinkStyle] (-center) -- (#1); |
| 1473 |
\draw [knLinkStyle, fill=white] (-center) circle (\diam); |
| 1474 |
\draw [knLinkStyle, fill=black] (-center) circle (0.01); |
| 1475 |
} %end of code for this particular pic |
| 1476 |
}, |
| 1477 |
%------------------------------------------ |
| 1478 |
pics/planar contact pair/.default={60:0.5cm/-120:0.5cm},% |
| 1479 |
%param: point for upper link end (default: (45:0.5cm)); |
| 1480 |
%param: point for lower link end (default: (-135:0.5cm)); |
| 1481 |
pics/planar contact pair/.style args={#1/#2}{ % plannar link in 2D ISO. Replaces the previous plannarlink2D |
| 1482 |
code={ |
| 1483 |
\def\rectW{0.9cm} %width |
| 1484 |
\def\rectH{0.2cm} %height |
| 1485 |
|
| 1486 |
\draw [knJointStyle] (-0.5*\rectW,-0.5*\rectH) -- ++(0:\rectW); %horiz bottom |
| 1487 |
\draw [knJointStyle] (-0.5*\rectW, 0.5*\rectH) -- ++(0:\rectW); %horiz top |
| 1488 |
|
| 1489 |
\coordinate (-north) at (0, 0.5*\rectH); |
| 1490 |
\coordinate (-south) at (0,-0.5*\rectH); |
| 1491 |
|
| 1492 |
\coordinate (-center) at (0,0); |
| 1493 |
\coordinate (-end) at (#1); %top |
| 1494 |
\coordinate (-end1) at (-end); |
| 1495 |
\coordinate (-end2) at (#2); %bottom |
| 1496 |
\coordinate (-in) at (-end2); %bottom |
| 1497 |
\coordinate (-out) at (-end); %top |
| 1498 |
\coordinate (-start) at (-in); |
| 1499 |
|
| 1500 |
\newdimen\XCoord \newdimen\YCoord |
| 1501 |
\newdimen\XCoordN \newdimen\YCoordN |
| 1502 |
\newdimen\XCoordS \newdimen\YCoordS |
| 1503 |
\newdimen\XCoordiN \newdimen\YCoordiN |
| 1504 |
\newdimen\XCoordiS \newdimen\YCoordiS |
| 1505 |
|
| 1506 |
% \gettikzxy{(-in)} {\XCoord} {\YCoord} |
| 1507 |
\path (-in); \pgfgetlastxy{\XCoord} {\YCoord}; |
| 1508 |
\gettikzxy{(-north)} {\XCoordN} {\YCoordN} |
| 1509 |
\gettikzxy{(-south)} {\XCoordS} {\YCoordS} |
| 1510 |
\gettikzxy{(#1)} {\XCoordiN}{\YCoordiN} |
| 1511 |
\gettikzxy{(#2)} {\XCoordiS}{\YCoordiS} |
| 1512 |
|
| 1513 |
\pgfmathparse{atan2(\YCoordiN-\YCoordN,\XCoordiN-\XCoordN)} |
| 1514 |
\edef\nAng{\pgfmathresult}% angle in north arm |
| 1515 |
|
| 1516 |
\pgfmathparse{atan2(\YCoordiS-\YCoordS,\XCoordiS-\XCoordS)} |
| 1517 |
\edef\sAng{\pgfmathresult}% angle in south arm |
| 1518 |
|
| 1519 |
\draw [knLineCap,knLinkStyle] (-north) -- (-end); %arm |
| 1520 |
\fill [] (-north) -- ++(\lockRadius,0) arc (0:\nAng:\lockRadius) -- cycle; |
| 1521 |
%lock up |
| 1522 |
\draw [knLineCap,knLinkStyle] (-south) -- (-end2); %arm |
| 1523 |
\fill [] (-south) -- ++(-\lockRadius,0) arc (0:180+\sAng:-\lockRadius) -- cycle; |
| 1524 |
} %end of code for this particular pic |
| 1525 |
}, |
| 1526 |
%------------------------------------------ |
| 1527 |
rotating cam plate/.pic={\pic {camlink=#1};}, %ISO synonym of camlink which is the legacy name |
| 1528 |
pics/camlink/.default=-30, % default arguments for this pic |
| 1529 |
pics/camlink/.style args={#1}{ % cam link with triangular pivot ISO |
| 1530 |
code={ |
| 1531 |
\coordinate (-center) at (0.2,0.33); |
| 1532 |
{ [shift=(-center),rotate=#1, local bounding box=bb] %translate into center (abbrev. for scope) |
| 1533 |
\draw [ |
| 1534 |
name path global=vsCurvedLine, %needed the global because of the scope :-( |
| 1535 |
use Hobby shortcut, closed=true, |
| 1536 |
scale=-1.75, |
| 1537 |
fill=\LinkFillColor |
| 1538 |
] |
| 1539 |
(0,-0.7) .. (0.2,-0.6) .. (0,0.4) .. (-0.2,-0.6) .. (0,-0.7); |
| 1540 |
|
| 1541 |
\coordinate (-out) at (0,1); %anchor point in case you need it |
| 1542 |
\coordinate (-end) at (-out); |
| 1543 |
%This can be an amuseming alternative |
| 1544 |
% \node[name path global=vsCurvedLine, |
| 1545 |
% star, |
| 1546 |
% draw, |
| 1547 |
% minimum width=2cm, |
| 1548 |
% rounded corners=5pt, |
| 1549 |
% star points=6, |
| 1550 |
% rotate=#1, |
| 1551 |
% xshift=10pt, |
| 1552 |
% yscale=1.2, |
| 1553 |
%% shading = axis, left color=blue, right color=red!30!white, shading angle=135, |
| 1554 |
% ] at (-center) {}; |
| 1555 |
} |
| 1556 |
|
| 1557 |
%State a vertical passing some contact point (for example the (-center)) |
| 1558 |
%and extend it to the limit of the bounding box |
| 1559 |
\path let \p1=(bb.north), \p2=(-center) in coordinate (-toplimit) at (\x2,\y1); |
| 1560 |
\path let \p1=(bb.south), \p2=(-center) in coordinate (-bottomlimit) at (\x2,\y1); |
| 1561 |
\path [name path=vsVerticalLine] (-toplimit) -- (-bottomlimit); |
| 1562 |
\path [name intersections={of={vsVerticalLine} and {vsCurvedLine}}] ; |
| 1563 |
% \coordinate (-touchtop) at (intersection-1); |
| 1564 |
% \coordinate (-touchbottom) at (intersection-2); |
| 1565 |
% as intesections may change order must do a further text of which point is up... |
| 1566 |
|
| 1567 |
\path let \p1=(intersection-1), |
| 1568 |
\p2=(intersection-2) in coordinate (-touchtop) at (\x1,{max(\y1,\y2)}); |
| 1569 |
\path let \p1=(intersection-1), |
| 1570 |
\p2=(intersection-2) in coordinate (-touchbottom) at (\x1,{min(\y1,\y2)}); |
| 1571 |
|
| 1572 |
%Can do the same in horizontal |
| 1573 |
\path let \p1=(bb.west), \p2=(-center) in coordinate (-leftlimit) at (\x1,\y2); |
| 1574 |
\path let \p1=(bb.east), \p2=(-center) in coordinate (-rightlimit) at (\x1,\y2); |
| 1575 |
\path [name path=vsHorizontalLine] (-leftlimit) -- (-rightlimit); |
| 1576 |
\path [name intersections={of={vsHorizontalLine} and {vsCurvedLine}}] ; |
| 1577 |
\path let \p1=(intersection-1), |
| 1578 |
\p2=(intersection-2) in coordinate (-touchright) at ({max(\x1,\x2)},\y2); |
| 1579 |
|
| 1580 |
\path let \p1=(intersection-1), |
| 1581 |
\p2=(intersection-2) in coordinate (-touchleft) at ({min(\x1,\x2)},\y2); |
| 1582 |
|
| 1583 |
|
| 1584 |
\draw [line join=round,fill=white] (0,0) -- (0.4,0) -- (0.2,0.33) -- cycle; |
| 1585 |
\node [ground2,minimum width=0.8cm,xshift=-0.2cm] {};% \draw [ground] (0,0) -- (0.5,0); |
| 1586 |
\draw [thick,xshift=-0.2cm] (0,0) -- (0.8,0); |
| 1587 |
\draw [fill=white] (-center) circle (\pivotRadius); |
| 1588 |
} %end of code for this particular pic |
| 1589 |
}, %end of pic |
| 1590 |
%------------------------------------------ |
| 1591 |
campin/.pic={\pic {cam follower=4};}, %a way to keep compatibility with the early campin element that can now be emulated as a particular case of cam follower |
| 1592 |
%------------------------------------------ |
| 1593 |
pics/cam follower/.style={ % The ISO version of campin |
| 1594 |
code={ |
| 1595 |
%------------------------ |
| 1596 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 1597 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 1598 |
\readlist\myArgs{\allArgs} |
| 1599 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\pinType} {\def\pinType{}} |
| 1600 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\pinDir} {\def\pinDir{}} |
| 1601 |
%Test if any parameter is blank and put the default in that case |
| 1602 |
\ifthenelse{ \equal{\pinType}{}} {\def\pinType{0}} {} %default 0 for knifeedhe |
| 1603 |
\ifthenelse{ \equal{\pinDir}{}} {\def\pinDir{0}} {} %default 0 for vertical |
| 1604 |
%---------------------- |
| 1605 |
|
| 1606 |
\def\KNIFEEDGE{0} |
| 1607 |
\def\ARCUATE{1} |
| 1608 |
\def\ROLLER{2} |
| 1609 |
\def\FLATFACED{3} |
| 1610 |
\def\CAMPIN{4} %A special definition for an eralier version non ISO |
| 1611 |
\def\PINVERT{0} |
| 1612 |
\def\PINHORIZ{1} |
| 1613 |
|
| 1614 |
\def\armLen{1cm} %length or arm |
| 1615 |
\def\tipGap{20pt} % gap from contact to arm |
| 1616 |
|
| 1617 |
\coordinate (-in) at (0,0); |
| 1618 |
|
| 1619 |
\if\pinType\KNIFEEDGE % |
| 1620 |
\def\tipGap{8pt} % gap from contact to arm |
| 1621 |
\draw [knLinkStyle,line join=round] (-in) -- ++(-4pt,\tipGap) -- ++(8pt,0) -- cycle; |
| 1622 |
\else |
| 1623 |
\if\pinType\ARCUATE |
| 1624 |
\def\tipGap{6pt} % gap from contact to arm |
| 1625 |
\draw [knLinkStyle] (-6pt,\tipGap) arc (-180:0:\tipGap) -- cycle; |
| 1626 |
\else |
| 1627 |
\if\pinType\ROLLER |
| 1628 |
\def\tipGap{10pt} % gap from contact to arm |
| 1629 |
\draw [knLinkStyle,fill=white] (0,0.5*\tipGap) circle (0.5*\tipGap); |
| 1630 |
\draw [knLinkStyle,fill=white] (0,0.5*\tipGap) circle (0.25*\tipGap); |
| 1631 |
\else |
| 1632 |
\if\pinType\FLATFACED |
| 1633 |
\def\tipGap{3pt} % gap from contact to arm |
| 1634 |
\draw [knLinkStyle] (-5pt,0) rectangle ++(10pt,\tipGap); |
| 1635 |
\fi |
| 1636 |
\fi |
| 1637 |
\fi |
| 1638 |
\fi |
| 1639 |
|
| 1640 |
\coordinate (-topin) at (0,\tipGap); |
| 1641 |
|
| 1642 |
\if\pinDir\PINVERT % |
| 1643 |
\coordinate (-end) at (0,\armLen); |
| 1644 |
\else |
| 1645 |
\coordinate (-end) at (\armLen,\tipGap); |
| 1646 |
\fi |
| 1647 |
|
| 1648 |
\draw [knLinkStyle] (-topin) -- (-end); |
| 1649 |
|
| 1650 |
\coordinate (-out) at (-end); |
| 1651 |
\coordinate (-center) at (-in); |
| 1652 |
\coordinate (-start) at (-in); |
| 1653 |
|
| 1654 |
\if\pinType\CAMPIN %legacy for early campin |
| 1655 |
\coordinate (-center) at (0,17pt); |
| 1656 |
\draw [fill=\LinkFillColor] (0,0)--++(2pt,4pt)--++(0,30pt)--++(-2pt,0) coordinate (-end) --++(-2pt,0)--++(0,-30pt) --cycle; |
| 1657 |
\coordinate (-out) at (-end); |
| 1658 |
\fi |
| 1659 |
} %end of code for this particular pic |
| 1660 |
}, %end of pic |
| 1661 |
%------------------------------------------ |
| 1662 |
} %end of tikzset |
| 1663 |
% |
| 1664 |
%====== OTHER DEFINITIONS vsCustomLinks ================= |
| 1665 |
|
| 1666 |
\tikzset{ % definitions for my definitions of link pics () |
| 1667 |
% |
| 1668 |
% Technique adapted from https://tex.stackexchange.com/questions/218813/latex-access-every-character-of-an-string-variable using listofitems package |
| 1669 |
pics/link bar generic/.style=% |
| 1670 |
%Arg 1 -> point of end [0:30pt] %Point cannot come in ( ) because it gives problems below... :-( |
| 1671 |
%Arg 2 -> bool include the COM symbol in the geometric center [1] |
| 1672 |
%Arg 3 -> bool has pivot in -start [1] |
| 1673 |
%Arg 4 -> bool has pivot in -end [1] |
| 1674 |
%Arg 5 -> bool draw option crosshairs in extremes [0] |
| 1675 |
%Arg 6 -> line width undocumented :-) to manipulate line with |
| 1676 |
{ |
| 1677 |
code={ |
| 1678 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 1679 |
%Split joint argument in several args. If passed, use it, else put blanks. |
| 1680 |
%But first impose an empty list in case no args are passed to avoid error of readlist |
| 1681 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 1682 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 1683 |
\readlist\myArgs{\allArgs} |
| 1684 |
\ifthenelse{ \myArgslen > 0} {\def\destPoint {\myArgs[1]}} {\def\destPoint{}} |
| 1685 |
\ifthenelse{ \myArgslen > 1} {\def\hasCOM {\myArgs[2]}} {\def\hasCOM{}} |
| 1686 |
\ifthenelse{ \myArgslen > 2} {\def\hasStartPivot{\myArgs[3]}} {\def\hasStartPivot{}} |
| 1687 |
\ifthenelse{ \myArgslen > 3} {\def\hasEndPivot {\myArgs[4]}} {\def\hasEndPivot{}} |
| 1688 |
\ifthenelse{ \myArgslen > 4} {\def\hasCrossHairs{\myArgs[5]}} {\def\hasCrossHairs{}} |
| 1689 |
\ifthenelse{ \myArgslen > 5} {\def\hasThinLines {\myArgs[6]}} {\def\hasThinLines{}} |
| 1690 |
%Test if any parameter is blank and put the default in that case |
| 1691 |
\ifthenelse{ \equal{\destPoint}{}} {\def\destPoint {0:30pt}}{} |
| 1692 |
\ifthenelse{ \equal{\hasCOM}{}} {\def\hasCOM {1}} {} |
| 1693 |
\ifthenelse{ \equal{\hasStartPivot}{}}{\def\hasStartPivot{1}} {} |
| 1694 |
\ifthenelse{ \equal{\hasEndPivot}{}} {\def\hasEndPivot {1}} {} |
| 1695 |
\ifthenelse{ \equal{\hasCrossHairs}{}}{\def\hasCrossHairs{0}} {} |
| 1696 |
\ifthenelse{ \equal{\hasThinLines}{}} {\def\hasThinLines {0}} {} |
| 1697 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 1698 |
|
| 1699 |
\coordinate (-start) at (\currentcoordinate); |
| 1700 |
\coordinate (-end) at (\destPoint); |
| 1701 |
\coordinate (-end1) at (-end); %a synonym for compatitility with others |
| 1702 |
|
| 1703 |
%AUX CALCS |
| 1704 |
\coordinate (A) at (-start); |
| 1705 |
\coordinate (B) at ($(A)+(-end)$); |
| 1706 |
%Calculate angle of point alignment |
| 1707 |
\gettikzxy{(A)} {\XCoordA} {\YCoordA} |
| 1708 |
\gettikzxy{(B)} {\XCoordB} {\YCoordB} |
| 1709 |
\pgfmathparse{atan2(\YCoordB-\YCoordA,\XCoordB-\XCoordA)} |
| 1710 |
\edef\nAng{\pgfmathresult}% |
| 1711 |
|
| 1712 |
\def\lWidth{0.75pt} %line width of drawings. |
| 1713 |
\ifthenelse{\hasThinLines=1}{\def\lWidth{0.2pt}}{}%Very very thin (0 in the limit) |
| 1714 |
|
| 1715 |
%Calculate base length |
| 1716 |
\pgfmathparse{veclen(\XCoordB-\XCoordA,\YCoordB-\YCoordA)} |
| 1717 |
\edef\lRadiusS{\pgfmathresult}% |
| 1718 |
|
| 1719 |
%Calculate extension factor beyond B and obtain posB |
| 1720 |
\pgfmathparse{1+5/\lRadiusS} %Extension of 5pt more to draw a pivot |
| 1721 |
\edef\lFact{\pgfmathresult}% |
| 1722 |
\coordinate (posB) at ($(A)!\lFact!(B)$); %Full extremity with the pivot point |
| 1723 |
% \coordinate (posB) at ($\lFact*(A)+(B)$); %Full extremity with the pivot point |
| 1724 |
|
| 1725 |
|
| 1726 |
%Calculate extension factor beyond A and obtain preA |
| 1727 |
\pgfmathparse{1+5/\lRadiusS} %Extension of 5pt more to draw a pivot |
| 1728 |
\edef\lFact{\pgfmathresult}% |
| 1729 |
\coordinate (preA) at ($(B)!\lFact!(A)$); %Full extremity with the pivot point |
| 1730 |
% \coordinate (preA) at ($\lFact*(B)+(A)$); %Full extremity with the pivot point |
| 1731 |
|
| 1732 |
|
| 1733 |
\def\rrWest{none} %ending type for the case in no pivot in West (left or start) |
| 1734 |
\def\rrEast{none} %ending type for the case in no pivot in East (right or end) |
| 1735 |
|
| 1736 |
\ifthenelse{\hasStartPivot=1}{\def\rrWest{convex}}{\coordinate (preA) at (A);} % if using pre extension keep the calculations |
| 1737 |
\ifthenelse{\hasEndPivot=1}{\def\rrEast{convex}}{\coordinate (posB) at (B);} % if using pre extension keep the calculations |
| 1738 |
|
| 1739 |
%After this point the final extremities are in preA and posB even if no pivots (coincide with A/B) |
| 1740 |
% \coordinate (-center) at ($(preA)!0.5!(posB)$); |
| 1741 |
\coordinate (-center) at ($0.5*(preA)+0.5*(posB)$); |
| 1742 |
|
| 1743 |
\gettikzxy{(preA)} {\XCoordA} {\YCoordA} |
| 1744 |
\gettikzxy{(posB)} {\XCoordB} {\YCoordB} |
| 1745 |
\pgfmathparse{veclen(\XCoordB-\XCoordA,\YCoordB-\YCoordA)} |
| 1746 |
\edef\lRadius{\pgfmathresult}% |
| 1747 |
|
| 1748 |
\coordinate (ppreA) at ($(preA)-(\nAng:\lWidth/2)$); %recalculate for correct drawing below |
| 1749 |
\node [rotate=\nAng, |
| 1750 |
inner sep=0, |
| 1751 |
rounded rectangle, |
| 1752 |
draw, |
| 1753 |
fill=\LinkFillColor, |
| 1754 |
line width=\lWidth, %controls line width |
| 1755 |
minimum width=\lRadius, %dimension (actually the longest dim or link length) |
| 1756 |
minimum height=10pt, %dimension (actually the shortests dim or link thickness) |
| 1757 |
% at=(-center); |
| 1758 |
at=(ppreA), %actully preA with a line width correction |
| 1759 |
anchor=west, %force this anchor to avoid external changes... |
| 1760 |
rounded rectangle west arc=\rrWest, %none, convex, concave %controls the ending type |
| 1761 |
rounded rectangle east arc=\rrEast, %none, convex, concave %controls the ending type |
| 1762 |
] () {}; |
| 1763 |
\coordinate (-in) at (-start); |
| 1764 |
\coordinate (-out) at (-end); |
| 1765 |
\coordinate (-south) at ($ (-center) - (90+\nAng:5pt)$); |
| 1766 |
\coordinate (-north) at ($ (-center) + (90+\nAng:5pt)$); |
| 1767 |
|
| 1768 |
\ifthenelse{\hasStartPivot=1}{\draw [fill=white] (-start) circle (\pivotRadius);}{} % draw pivot in start |
| 1769 |
\ifthenelse{\hasEndPivot=1}{\draw [fill=white] (-end) circle (\pivotRadius);}{} % draw pivot in end |
| 1770 |
|
| 1771 |
\ifthenelse{\hasCOM=1}{ |
| 1772 |
\tiny \addCOM %[blue] or [fill=none,draw=none], etc. %addmits that (-center) is defined |
| 1773 |
} {} |
| 1774 |
\ifthenelse{\hasCrossHairs=1}{ |
| 1775 |
\draw (A) -- ++(90+\nAng:4pt) (A) -- ++(-90+\nAng:4pt) (A) -- ++(\nAng:4pt) (A) -- ++(180+\nAng:4pt); |
| 1776 |
\draw (B) -- ++(90+\nAng:4pt) (B) -- ++(-90+\nAng:4pt)(B) -- ++(\nAng:4pt) (B) -- ++(180+\nAng:4pt);} {} |
| 1777 |
} %end of code for this particular pic |
| 1778 |
}, |
| 1779 |
%------------------------------------------ |
| 1780 |
pics/linear joint bar/.style={% 2D linear joint bar |
| 1781 |
% arg 1 - fraction of insertion (default 0.5) - 0 is no insertion at all, 1 is fully inserted |
| 1782 |
% arg 2 - lenght of fixed part (default 1cm) |
| 1783 |
% arg 3 - boolean - has curved base (0 no - default, 1 - yes) |
| 1784 |
% arg 4 - boolean - has curved tip (0 no, 1 yes (default)) |
| 1785 |
code={ |
| 1786 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 1787 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 1788 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 1789 |
\readlist\myArgs{\allArgs} |
| 1790 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\fracDepth} {\def\fracDepth{}} |
| 1791 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\fixLen} {\def\fixLen{}} |
| 1792 |
\ifthenelse{ \myArgslen > 2} {\itemtomacro\myArgs[3]\curvBase} {\def\curvBase{}} |
| 1793 |
\ifthenelse{ \myArgslen > 3} {\itemtomacro\myArgs[4]\curvTip} {\def\curvTip{}} |
| 1794 |
%Test if any parameter is blank and put the default in that case |
| 1795 |
\ifthenelse{ \equal{\fracDepth}{}} {\def\fracDepth{0.5}} {} %default 0.5 fraction of insertion |
| 1796 |
\ifthenelse{ \equal{\fixLen}{}} {\def\fixLen{1cm}} {} %default 1cm length of fixed part |
| 1797 |
\ifthenelse{ \equal{\curvBase}{}} {\def\curvBase{0}} {} %default is no curved base |
| 1798 |
\ifthenelse{ \equal{\curvTip}{}} {\def\curvTip{1}} {} %default is to have a curved tip |
| 1799 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 1800 |
|
| 1801 |
\def\iGap{2pt} %inner separation of piston from body |
| 1802 |
\def\rectH{10pt} %height of outer cyl |
| 1803 |
|
| 1804 |
\begin{scope}[rotate=0] %No rotation draw it horizontally |
| 1805 |
\coordinate (-start) at (0,0); |
| 1806 |
\coordinate (-jpoint) at ($(0,0) + (\fixLen,0) $); |
| 1807 |
\coordinate (-center) at (-jpoint); |
| 1808 |
\coordinate (-end) at ($(0,0) + (2*\fixLen-\fracDepth*\fixLen,0) $); %size varies |
| 1809 |
\coordinate (-in) at (-start); |
| 1810 |
\coordinate (-out) at (-end); |
| 1811 |
\coordinate (-topright) at ([yshift=0.5*\rectH]-jpoint); |
| 1812 |
\coordinate (-topleft) at ([yshift=0.5*\rectH]-start); |
| 1813 |
\coordinate (-bottomleft) at ([yshift=-0.5*\rectH]-start); |
| 1814 |
\coordinate (-bottomright) at ([yshift=-0.5*\rectH]-jpoint); |
| 1815 |
|
| 1816 |
\coordinate (-toprightS) at ([yshift={0.5*\rectH-\iGap}]-end); |
| 1817 |
\coordinate (-topleftS) at ([yshift={0.5*\rectH-\iGap}]-jpoint); |
| 1818 |
\coordinate (-bottomleftS) at ([yshift={-0.5*\rectH+\iGap}]-jpoint); |
| 1819 |
\coordinate (-bottomrightS) at ([yshift={-0.5*\rectH+\iGap}]-end); |
| 1820 |
|
| 1821 |
\ifthenelse{ \equal{\curvTip}{0} } |
| 1822 |
{ |
| 1823 |
\fill [\SubLinkFillColor] (-topleftS) -- (-toprightS) -- (-bottomrightS) -- (-bottomleftS) -- cycle; |
| 1824 |
} |
| 1825 |
{ |
| 1826 |
\fill [\SubLinkFillColor] (-topleftS) -- (-toprightS) arc (90:-90:0.5*\rectH-\iGap) -- (-bottomleftS) -- cycle; |
| 1827 |
} |
| 1828 |
|
| 1829 |
|
| 1830 |
\ifthenelse{ \equal{\curvBase}{0} } |
| 1831 |
{ |
| 1832 |
\draw [knLinkStyle,fill=\LinkFillColor] (-topright) -- (-topleft) -- (-bottomleft) -- (-bottomright); |
| 1833 |
} |
| 1834 |
{ |
| 1835 |
\draw [knLinkStyle,fill=\LinkFillColor] (-topright) -- (-topleft) arc (90:270:0.5*\rectH) -- (-bottomright); |
| 1836 |
\draw [fill=white] (-start) circle (\pivotRadius); |
| 1837 |
} |
| 1838 |
|
| 1839 |
\end{scope} |
| 1840 |
} %end of code for this particular pic |
| 1841 |
}, |
| 1842 |
%------------------------------------------ |
| 1843 |
pics/link polygon/.style=% |
| 1844 |
%Arg 1 -> point of -end1 |
| 1845 |
%Arg 2 -> point of -end2 |
| 1846 |
%... |
| 1847 |
%Arg n -> point of -endn |
| 1848 |
{ |
| 1849 |
code={ |
| 1850 |
%Split joint argument in several args. Empty arguments are discarded. |
| 1851 |
%But first impose a default list with onde point in case no args at all are passed to avoid error of readlist |
| 1852 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{0:30pt}} {\def\allArgs{#1}} |
| 1853 |
\ignoreemptyitems %to discard empty entries in list of arguments |
| 1854 |
\setsepchar[.]{/} % "/" is the separator; "." is separator of sperators in the separator list |
| 1855 |
\readlist\myArgs{\allArgs} %separate the argments in their own variable (myArgs[1], myArgs[2], etc... |
| 1856 |
% studying second level separators to decide which pivot to draw, but it complicates too much the decoding code. So use a defined list (macro) of booleans to decide which pivot points to draw. |
| 1857 |
|
| 1858 |
%Lame solutions -- limited to a fixed number because could not implement the solution shown |
| 1859 |
\ifdefined\ListOfPivotPointsToDraw |
| 1860 |
%do nothing |
| 1861 |
\else |
| 1862 |
% \count=\myArgslen \def\ListOfPivotPointsToDraw{\loop \ifnum\count0>0 \advance\count0 by -1 {1,}\repeat} |
| 1863 |
\def\ListOfPivotPointsToDraw{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} %:-(( |
| 1864 |
\fi |
| 1865 |
|
| 1866 |
\setsepchar{,} % restore the "," separator; |
| 1867 |
\readlist\dPivots{\ListOfPivotPointsToDraw} % |
| 1868 |
|
| 1869 |
\coordinate (-start) at (\currentcoordinate); |
| 1870 |
\coordinate (-in) at (-start); |
| 1871 |
%Create all -end coordinates |
| 1872 |
\foreachitem\pPoint\in\myArgs{\coordinate [at=(\pPoint),name=-end\pPointcnt] ; \coordinate [at=(\pPoint),name=-out\pPointcnt] ;} |
| 1873 |
|
| 1874 |
\coordinate (-centerS) at (-start); %init this accumulator |
| 1875 |
\foreachitem\pPoint\in\myArgs{\coordinate [at=($(\pPoint)+(-centerS)$),name=-centerS] ;} %add allpoints |
| 1876 |
|
| 1877 |
\coordinate (-out) at (-out1); |
| 1878 |
\coordinate (-end) at (-out); |
| 1879 |
|
| 1880 |
|
| 1881 |
\xdef\AllPoints{(-in)} %start with -in |
| 1882 |
\foreach \n in {1,...,\myArgslen} {\xdef\AllPoints{\AllPoints(-end\n)} } %add all -ends |
| 1883 |
\node[fit=\AllPoints] (-box){}; %create a fit box |
| 1884 |
|
| 1885 |
\pgfmathsetmacro\vsWeight{1/(\myArgslen+1)} %because you cannot apply division in nodes :-(( and do not forget starting points |
| 1886 |
\coordinate (-center) at ($\vsWeight*(-centerS)$); |
| 1887 |
|
| 1888 |
%Trick draw a wide line first |
| 1889 |
%%OPTION A - The best except if you want a fill pattern |
| 1890 |
\draw [line join=round, line width=10pt,rounded corners=0pt, fill=\LinkFillColor] |
| 1891 |
(-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1892 |
%... and then the same with a thinner line with the same color as fill color |
| 1893 |
\draw [\LinkFillColor, line join=round, line width=8.25pt,rounded corners=0pt, fill=\LinkFillColor] |
| 1894 |
(-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1895 |
|
| 1896 |
%%OPTION B - The simplest and best for patterns but not the best for the geometry contour :-( |
| 1897 |
% \draw [line join=round, line width=0.75pt,rounded corners=0pt, pattern=north east lines] |
| 1898 |
% (-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1899 |
|
| 1900 |
%%OPTION C |
| 1901 |
% %This Alternative is more elegant but not faithfull geometrically and poorer for 2 points only :-( |
| 1902 |
% \def\exFact{1.15} |
| 1903 |
% \draw [line join=round, |
| 1904 |
% line width=0.75pt, |
| 1905 |
% rounded corners=5pt, |
| 1906 |
%% fill=\LinkFillColor, |
| 1907 |
% pattern=north east lines |
| 1908 |
% ] |
| 1909 |
% ($(-center)!\exFact!(-start)$) \foreach \n in {1,...,\myArgslen} {-- ($(-center)!\exFact!(-end\n)$)} -- cycle; |
| 1910 |
|
| 1911 |
%%OPTION D - Inspired in A and uses pattersn but leaves a white border. May confuse. Perhaps avoid |
| 1912 |
% \draw [line join=round, line width=10pt,rounded corners=0pt] %, fill=\LinkFillColor] |
| 1913 |
% (-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1914 |
%% %... and then the same with a thinner line with the same color as fill color |
| 1915 |
% \draw [white, line join=round, line width=8.25pt,rounded corners=0pt,fill=white] |
| 1916 |
% (-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1917 |
% \draw [draw=none,line join=round, line width=0pt,rounded corners=0pt, pattern=north east lines] |
| 1918 |
% (-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1919 |
% |
| 1920 |
|
| 1921 |
%%OPTION E |
| 1922 |
%% This would be a trick with clip but not very useful since line options cannot be passed to clip :-( |
| 1923 |
% \begin{scope} |
| 1924 |
% %Sets the clipping areas and also the limits to use as bounding box of polygon |
| 1925 |
% \clip [ use as bounding box ] |
| 1926 |
% (-start) \foreach \n in {1,...,\myArgslen} {-- (-end\n)} -- cycle; |
| 1927 |
% %Draw a rectangle filled with the correct pattern |
| 1928 |
% \draw [draw=none,pattern=north east lines] (current bounding box.south west) rectangle (current bounding box.north east); |
| 1929 |
% \end{scope} |
| 1930 |
|
| 1931 |
|
| 1932 |
\draw [fill=white] (-start) circle (\pivotRadius); %pivot at -start |
| 1933 |
|
| 1934 |
%Draw remainder pivots |
| 1935 |
\foreach \n in {1,...,\myArgslen} |
| 1936 |
{ |
| 1937 |
\ifthenelse{ \dPivots[\n] = 1} |
| 1938 |
{ |
| 1939 |
\draw [fill=white] (-end\n) circle (\pivotRadius); %pivot at -end\n |
| 1940 |
}{} |
| 1941 |
} |
| 1942 |
|
| 1943 |
\pic at (-center) {center of mass}; |
| 1944 |
} %end of code for this particular pic |
| 1945 |
}, |
| 1946 |
%------------------------------------------ |
| 1947 |
pics/linear piston/.style={% 2D linear piston-like pair. Replaces the previous 2 |
| 1948 |
% arg 1 - fraction of insertion (default 0.5) |
| 1949 |
% arg 2 - width of inner piston plate (default 5pt) |
| 1950 |
code={ |
| 1951 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 1952 |
% TODO Should be extended to all pics with params. Only some have it------ :-) |
| 1953 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 1954 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 1955 |
\readlist\myArgs{\allArgs} |
| 1956 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\fracDepth} {\def\fracDepth{}} |
| 1957 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\pWidth} {\def\pWidth{}} |
| 1958 |
%Test if any parameter is blank and put the default in that case |
| 1959 |
\ifthenelse{ \equal{\fracDepth}{}} {\def\fracDepth{0.5}} {} %default 0.5 fraction of insertion |
| 1960 |
\ifthenelse{ \equal{\pWidth}{}} {\def\pWidth{10pt}} {} %default 5pt width |
| 1961 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 1962 |
|
| 1963 |
\def\iGap{2pt} %inner separation of piston plate from body |
| 1964 |
\def\rectH{0.5cm} %height of outer cyl |
| 1965 |
\edef\rectW{2*\iGap+\pWidth} %width of outer cyl |
| 1966 |
\def\armLen{0.4cm} %arm length |
| 1967 |
|
| 1968 |
\begin{scope}[rotate=90] |
| 1969 |
\coordinate (-center) at (0,0); |
| 1970 |
\coordinate (-innerend) at ($(-center) - (0, \fracDepth*\rectH) $); |
| 1971 |
\coordinate (-start) at (0,\armLen); |
| 1972 |
% \coordinate (-start) at ($(-innerend) - (0,\rectH-\fracDepth*\rectH+\armLen) $); %Keep size |
| 1973 |
\coordinate (-end) at ($(-innerend) - (0,0.5*\rectH+\armLen) $); %size varies |
| 1974 |
\coordinate (-in) at (-start); |
| 1975 |
\coordinate (-out) at (-end); |
| 1976 |
\coordinate (-iend) at (-innerend); |
| 1977 |
|
| 1978 |
\draw [knJointStyle] (-\iGap-0.5*\pWidth,-\rectH) -- ++(0,\rectH) -- ++(\rectW,0) -- ++(0, -\rectH); |
| 1979 |
\draw [knJointStyle, ultra thick] (-innerend) -- ++(-0.5*\pWidth,0)(-innerend)--++(0.5*\pWidth,0); |
| 1980 |
\draw [knLinkStyle] (-center) -- (-start) (-innerend) -- (-end); |
| 1981 |
\end{scope} |
| 1982 |
} %end of code for this particular pic |
| 1983 |
}, |
| 1984 |
%------------------------------------------ |
| 1985 |
} |
| 1986 |
|
| 1987 |
%=========== ALTERNATIVES TO ISO ================================= |
| 1988 |
|
| 1989 |
\tikzset{ %definitions/pics for link symbols alternatives to ISO |
| 1990 |
%------------------------------------------ |
| 1991 |
pics/rotational colinear/.style={ %~ alternative rotational joint with axis colinear with link |
| 1992 |
code={ |
| 1993 |
\def\vsLen{0.6} |
| 1994 |
\def\vsAng{30} |
| 1995 |
\coordinate (-center) at (0,0); |
| 1996 |
\coordinate (BP) at ($(-center)-(0,{\vsLen*sin(\vsAng)})$); %low point |
| 1997 |
\draw [knJointStyle] (BP) -- ++(\vsAng:\vsLen) coordinate[name=RP] -- ++(180-\vsAng:\vsLen) coordinate[name=TP] -- ++(180+\vsAng:\vsLen) coordinate[name=LP] -- cycle (LP) -- (RP); |
| 1998 |
\draw [knLinkStyle] (TP) --++(0, 0.25) coordinate[name=-end]; |
| 1999 |
\draw [knLinkStyle] (BP) --++(0,-0.25) coordinate[name=-start]; |
| 2000 |
|
| 2001 |
\coordinate (-in) at (-start); |
| 2002 |
\coordinate (-out) at (-end); |
| 2003 |
} |
| 2004 |
}, |
| 2005 |
%------------------------------------------ |
| 2006 |
} |
| 2007 |
|
| 2008 |
%%=============== the default XYZ convention in tikz |
| 2009 |
% |
| 2010 |
% YY |
| 2011 |
% ^ |
| 2012 |
% | |
| 2013 |
% | |
| 2014 |
% +-----> XX |
| 2015 |
% / |
| 2016 |
% / |
| 2017 |
% ZZ |
| 2018 |
% |
| 2019 |
%%======== ELEMENTS TO DRAW FULL CHAINS WITH 3D EQUIVALENTS ===== |
| 2020 |
\tikzset{ |
| 2021 |
%----------------------------------------------------------------------- |
| 2022 |
pics/linear 3D/.style={ % linear link in 3D generic that accepts one argument and no terminal lines |
| 2023 |
% Arg 1 -> direction of motion |
| 2024 |
% Meanings: |
| 2025 |
%Absent: defaults to the right (5) with simple ends drawn (for illustration) |
| 2026 |
%The remainder options do not draw end segments and add a plane for thr direction of motion: |
| 2027 |
%1 top |
| 2028 |
%2 bottom |
| 2029 |
%3 near (front/closer) |
| 2030 |
%4 far (back of page) |
| 2031 |
%5 right |
| 2032 |
%6 left |
| 2033 |
code={ |
| 2034 |
\def\cubedge{0.75}% cube edge |
| 2035 |
\def\plangap{0.15}% gap of extra plane for motion indication |
| 2036 |
%0.353553=cos(45)/2 |
| 2037 |
%some points below seem not perfect at larger vlues of cube size :-( |
| 2038 |
\def\halfEdge{\cubedge*0.512} %should be 0.5 but tikz is not using perfect ortogonal perspective and this is relevant for occluding cases.. :-( |
| 2039 |
\coordinate (-center) at (0,0,0); %The usual default |
| 2040 |
\coordinate (-refstart) at ($(-center)+(-\cubedge/2,-\cubedge/2,-\cubedge/2)$); %easier to start in the back left lower vertex :-) |
| 2041 |
\coordinate (-label) at ($(-refstart)+(\cubedge/4,\cubedge/4,\cubedge/4)$); %central place for a label |
| 2042 |
|
| 2043 |
%Command to draw the main cube. Invoke below in the right order |
| 2044 |
\newcommand{\knDrawMainCube}{ |
| 2045 |
\draw [cube face 1] (-refstart) -- ++(0,\cubedge,0) -- ++(\cubedge,0,0) -- ++(0,-\cubedge,0) -- cycle; %back |
| 2046 |
\draw [cube face 1] (-refstart) -- ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(0,0,-\cubedge) -- cycle; %left |
| 2047 |
\draw [cube face 1] (-refstart) -- ++(0,0,\cubedge) -- ++(\cubedge,0,0) -- ++(0,0,-\cubedge) -- cycle; %bottom |
| 2048 |
\draw [cube face 1] (-refstart) ++(0,\cubedge,0) -- ++(0,0,\cubedge) -- ++(\cubedge,0,0) -- ++(0,0,-\cubedge) -- cycle; %top |
| 2049 |
\draw [cube face 1] (-refstart) ++(\cubedge,0,0) -- ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(0,0,-\cubedge) -- cycle; %right |
| 2050 |
\draw [cube face 1] (-refstart) ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(\cubedge,0,0) -- ++(0,-\cubedge,0) -- cycle; %frontal |
| 2051 |
} |
| 2052 |
|
| 2053 |
\def\arg{#1} %if absent, a default to the right with simple ends drawn (for illustration) |
| 2054 |
\def\TTT {1} %no ends extra plane to top |
| 2055 |
\def\BBB {2} %no ends extra plane to bottom |
| 2056 |
\def\NNN {3} %no ends extra plane to near (front/closer) |
| 2057 |
\def\FFF {4} %no ends extra plane to far (back of page) |
| 2058 |
\def\RRR {5} %no ends extra plane to right |
| 2059 |
\def\LLL {6} %no ends extra plane to left |
| 2060 |
|
| 2061 |
%Adapt behavior depending on argument |
| 2062 |
\if\arg\TTT %1 is to draw plane on the top |
| 2063 |
\knDrawMainCube |
| 2064 |
\draw [cube face 1] (-refstart) ++(0,{\cubedge+\plangap},0) -- ++(0,0,\cubedge) -- ++(\cubedge,0,0) -- ++(0,0,-\cubedge) -- cycle; %after top |
| 2065 |
|
| 2066 |
\coordinate (-east) at ($(-center)+(\cubedge/2,0,0)$); |
| 2067 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553,0,0)$); %adjust X for hidden line effect |
| 2068 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge*1.353553,0)$); %adjust Y for hidden line effect |
| 2069 |
\coordinate (-north) at ($(-center)+(0,{\cubedge/2+\plangap},0)$); |
| 2070 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553,-\halfEdge*0.353553,0)$); |
| 2071 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2072 |
\coordinate (-out) at (-north); |
| 2073 |
\coordinate (-in) at (-south); |
| 2074 |
\else |
| 2075 |
\if\arg\BBB %2 is to draw plane below |
| 2076 |
% \begin{pgfonlayer}{background} |
| 2077 |
\draw [cube face 1] (-refstart) ++(0,-\plangap,0) -- ++(0,0,\cubedge) -- ++(\cubedge,0,0) -- ++(0,0,-\cubedge) -- cycle; %after down |
| 2078 |
% \end{pgfonlayer}{background} |
| 2079 |
\knDrawMainCube |
| 2080 |
|
| 2081 |
\coordinate (-east) at ($(-center)+(\cubedge/2,0,0)$); |
| 2082 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553,0,0)$); %adjust X for hidden line effect |
| 2083 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge*1.353553-\plangap,0)$); %adjust Y for hidden line effect |
| 2084 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2085 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553,-\halfEdge*0.353553,0)$); |
| 2086 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2087 |
\coordinate (-out) at (-south); |
| 2088 |
\coordinate (-in) at (-north); |
| 2089 |
\else |
| 2090 |
\if\arg\NNN %3 is to draw plane on the front (near) far) |
| 2091 |
\knDrawMainCube |
| 2092 |
\draw [cube face 1] (-refstart) ++(0,0,\cubedge+\plangap) -- ++(\cubedge,0,0) -- ++(0,\cubedge,0) -- ++(-\cubedge,0,0) -- cycle; %afterfront |
| 2093 |
|
| 2094 |
\coordinate (-east) at ($(-center)+(\cubedge/2,0,0)$); |
| 2095 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553-1.353553*\plangap*0.28,0,0)$); %adjust X for hidden line effect. Formula is approx but irregularities found in defining it |
| 2096 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge*1.3536-1.353553*\plangap*0.28,0)$); %adjust Y for hidden line effect. Formula is approx but irregularities found in defining it |
| 2097 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2098 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553-\plangap/2*0.353553,-\halfEdge*0.353553-\plangap/2*0.353553,0)$); |
| 2099 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2100 |
\coordinate (-in) at (-back); |
| 2101 |
\coordinate (-out) at (-front); |
| 2102 |
\else |
| 2103 |
\if\arg\FFF %4 is to draw plane on the back far) |
| 2104 |
% \begin{pgfonlayer}{background} |
| 2105 |
\draw [cube face 1] (-refstart) ++(0,0,-\plangap) -- ++(\cubedge,0,0) -- ++(0,\cubedge,0) -- ++(-\cubedge,0,0) -- cycle; |
| 2106 |
%afterback |
| 2107 |
% \end{pgfonlayer}{background} |
| 2108 |
\knDrawMainCube |
| 2109 |
|
| 2110 |
\coordinate (-east) at ($(-center)+(\cubedge/2,0,0)$); |
| 2111 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553,0,0)$); %adjust X for hidden line effect |
| 2112 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge*1.353553,0)$); %adjust Y for hidden line effect |
| 2113 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2114 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553-\plangap/2*0.353553,-\halfEdge*0.353553-\plangap/2*0.353553,0)$); |
| 2115 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553+\plangap*0.353553,\halfEdge*1.353553+\plangap*0.353553,0)$); |
| 2116 |
\coordinate (-out) at (-back); |
| 2117 |
\coordinate (-in) at (-front); |
| 2118 |
\else |
| 2119 |
\if\arg\RRR %5 is to draw plane on the right |
| 2120 |
\knDrawMainCube |
| 2121 |
\draw [cube face 1] (-refstart) ++({\cubedge+\plangap},0,0) -- ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(0,0,-\cubedge) -- cycle; %afterright |
| 2122 |
|
| 2123 |
\coordinate (-east) at ($(-center)+({\cubedge/2+\plangap},0,0)$); |
| 2124 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553,0,0)$); %adjust X for hidden line effect |
| 2125 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge2*1.353553,0)$); %adjust Y for hidden line effect |
| 2126 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2127 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553-\plangap/2*0.353553,-\halfEdge*0.353553-\plangap/2*0.353553,0)$); |
| 2128 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2129 |
\coordinate (-out) at (-east); |
| 2130 |
\coordinate (-in) at (-west); |
| 2131 |
\else |
| 2132 |
\if\arg\LLL %6 is to draw plane on the left |
| 2133 |
% \begin{pgfonlayer}{background} |
| 2134 |
\draw [cube face 1] (-refstart) ++(-\plangap,0,0) -- ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(0,0,-\cubedge) -- cycle; %afterleft |
| 2135 |
% \end{pgfonlayer} |
| 2136 |
\knDrawMainCube |
| 2137 |
|
| 2138 |
\coordinate (-east) at ($(-center)+(\cubedge/2,0,0)$); |
| 2139 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553-\plangap,0,0)$); %adjust X for hidden line effect |
| 2140 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge*1.353553,0)$); %adjust Y for hidden line effect |
| 2141 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2142 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553,-\halfEdge*0.353553,0)$); |
| 2143 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2144 |
\coordinate (-out) at (-west); |
| 2145 |
\coordinate (-in) at (-east); |
| 2146 |
\else %other values (or none) is to draw a right and plane and simple pins right/left |
| 2147 |
\knDrawMainCube |
| 2148 |
\draw [cube face 1] (-refstart) ++({\cubedge+\plangap},0,0) -- ++(0,0,\cubedge) -- ++(0,\cubedge,0) -- ++(0,0,-\cubedge) -- cycle; %afterright |
| 2149 |
|
| 2150 |
\coordinate (-east) at ($(-center)+({\cubedge/2+\plangap},0,0)$); |
| 2151 |
\coordinate (-west) at ($(-center)+(-\halfEdge*1.353553,0,0)$); %adjust X for hidden line effect |
| 2152 |
\coordinate (-south) at ($(-center)+(0,-\halfEdge2*1.353553,0)$); %adjust Y for hidden line effect |
| 2153 |
\coordinate (-north) at ($(-center)+(0,\cubedge/2,0)$); |
| 2154 |
\coordinate (-front) at ($(-center)+(-\halfEdge*0.353553-\plangap/2*0.353553,-\halfEdge*0.353553-\plangap/2*0.353553,0)$); |
| 2155 |
\coordinate (-back) at ($(-center)+(\halfEdge*1.353553,\halfEdge*1.353553,0)$); |
| 2156 |
\coordinate (-out) at (-east); |
| 2157 |
\coordinate (-in) at (-west); |
| 2158 |
\draw [knLinkStyle] (-out) -- ++(0.5cm,0) node [inner sep=0] (-neweast) {}; |
| 2159 |
\draw [knLinkStyle] (-in) -- ++(-0.5cm,0) node [inner sep=0] (-newwest) {}; |
| 2160 |
\coordinate (-east) at (-neweast); |
| 2161 |
\coordinate (-west) at (-newwest); |
| 2162 |
\coordinate (-out) at (-east); |
| 2163 |
\coordinate (-in) at (-west); |
| 2164 |
\fi %of LLL |
| 2165 |
\fi %RRR |
| 2166 |
\fi %of FFF |
| 2167 |
\fi %of NNN |
| 2168 |
\fi %of BBB |
| 2169 |
\fi %of TTT |
| 2170 |
\coordinate (-top) at (-north); |
| 2171 |
\coordinate (-bottom) at (-south); |
| 2172 |
\coordinate (-end) at (-out); |
| 2173 |
\coordinate (-start) at (-in); |
| 2174 |
|
| 2175 |
% For illustration purposed only... |
| 2176 |
%\draw [red](-center) -- ++(3,0,0) |
| 2177 |
% (-center) -- ++(0,3,0) |
| 2178 |
% (-center) -- ++(0,0,6) |
| 2179 |
% ; |
| 2180 |
%\draw [dashed] (-center) -- ++(-3,0,0) |
| 2181 |
% (-center) -- ++(0,-3,0) |
| 2182 |
% (-center) -- ++(0,0,-6) |
| 2183 |
% ; |
| 2184 |
|
| 2185 |
% \foreach \n in {A,B,C,D,E,F,G,H,J,K,O} |
| 2186 |
% \foreach \n in {in,out} % |
| 2187 |
% \foreach \n in {start,end} % |
| 2188 |
% \foreach \n in {center,east,west,north,south,front,back,in,out}% |
| 2189 |
% \fill (-\n) circle (0.5pt) node [inner sep=0,anchor=south,yshift=1pt,font={\tiny\sffamily}] {\n}; |
| 2190 |
} %end of code for this particular pic |
| 2191 |
}, |
| 2192 |
%----------------------------------------------------------------------- |
| 2193 |
%Generic gripper with two fingers with variable orientation |
| 2194 |
pics/gripper/.style={ % |
| 2195 |
%Arg 1 -> direction (times 90º) to orient starting with 0 to the right [0] |
| 2196 |
%Arg 2 -> bool draw in pespective[0] |
| 2197 |
code={ |
| 2198 |
% ----START ANALYSE ARGUMENTS AND SET DEFAULTS -------------------------- |
| 2199 |
\ifthenelse{ \equal{#1}{}} {\def\allArgs{/}} {\def\allArgs{#1}} |
| 2200 |
\setsepchar[.]{/} % "/" is the separator "." is the second level separator |
| 2201 |
\readlist\myArgs{\allArgs} |
| 2202 |
\ifthenelse{ \myArgslen > 0} {\itemtomacro\myArgs[1]\fDir} {\def\fDir{}} |
| 2203 |
\ifthenelse{ \myArgslen > 1} {\itemtomacro\myArgs[2]\fPerspective}{\def\fPerspective{}} |
| 2204 |
%Test if any parameter is blank and put the default in that case |
| 2205 |
\ifthenelse{ \equal{\fDir}{} } {\def\fDir{0}} {} %default 0 - to the right |
| 2206 |
\ifthenelse{ \equal{\fPerspective}{}}{\def\fPerspective{0}} {} %default 0 - no perspective |
| 2207 |
%-----------------------END ANALYSE ARGUMENTS AND SET DEFAULTS ------------------- |
| 2208 |
|
| 2209 |
\coordinate (-center) at (0,0); |
| 2210 |
|
| 2211 |
\def\knxSLANT{0} %default: no slant |
| 2212 |
\def\knySCALE{1} %default: no change in y scale |
| 2213 |
\def\knYES{1} |
| 2214 |
|
| 2215 |
\if\fPerspective\knYES |
| 2216 |
\def\knySCALE{0.5} |
| 2217 |
\ifodd\fDir %1,3 |
| 2218 |
\def\knxSLANT{-1} |
| 2219 |
\else %even: 0,2 |
| 2220 |
\def\knxSLANT{1} |
| 2221 |
\fi |
| 2222 |
\fi |
| 2223 |
%Details: if perspective is 0 |
| 2224 |
% simple rotation |
| 2225 |
% if perspective is 1: |
| 2226 |
% yscale=0.5 (diagonal lengths are half in perspective) |
| 2227 |
% xslant= 1 if dir is even |
| 2228 |
% xslant=-1 if dir is odd |
| 2229 |
\begin{scope}[rotate={90*\fDir},xslant=\knxSLANT] |
| 2230 |
\coordinate (-fingertip1) at (0.5,\knySCALE*0.5); |
| 2231 |
\draw [gripper 1] (-fingertip1) -- ++(-0.5,0) -- ++(0,-1*\knySCALE) -- ++(0.5,0) coordinate (-fingertip2); |
| 2232 |
\coordinate (-in) at (0,0); |
| 2233 |
\coordinate (-start) at (-in); \coordinate (-out) at (-in); \coordinate (-end) at (-out); |
| 2234 |
\end{scope} |
| 2235 |
} %end of code for this particular pic |
| 2236 |
}, |
| 2237 |
% |
| 2238 |
} |
| 2239 |
|
| 2240 |
%Configurations for rotational 3D joints. Edit at will :-) |
| 2241 |
\def\Lcyl{1} %Cylinder length (1.75) %was 1.5 %was 1.25 |
| 2242 |
\def\Hcyl{0.75} %Cylinder height (diameter) (1) %was 0.75 |
| 2243 |
\def\Wcyl{0.15} %Ellipse minor semi-axis (valid for H and V versions) (0.2) |
| 2244 |
\def\armRight{0.3} %Arm on the right (0.4) |
| 2245 |
\def\armLeft{\armRight} %Arm on the left (similar to right) |
| 2246 |
\def\armGap{0.45} %Gap between cylinder and arm bar (0.7) |
| 2247 |
|
| 2248 |
%==================== NEW VARIANTS OF NON ISO =================== |
| 2249 |
\tikzset{ |
| 2250 |
%This pic can be rotated (and What about a V version to have node names consistent with actual position? Being built below) |
| 2251 |
pics/rotational 3D H/.style={ %rotational joint in 3D in Horizontal position |
| 2252 |
% Arg 1 %if absent a default with simple ends |
| 2253 |
% 0: no ends. A simple cylinder |
| 2254 |
% 1: arm at top |
| 2255 |
% 2: arm at bottom |
| 2256 |
% 3: arm at near (front/closer) |
| 2257 |
% 4: arm at far (back of page) |
| 2258 |
code={ |
| 2259 |
%Draw the horizontal cylinder with visible face on the right |
| 2260 |
\draw [knJointStyle] (\Lcyl/2,0) ellipse ({\Wcyl} and \Hcyl/2); %right ellipse |
| 2261 |
\draw [knJointStyle,fill=white] (\Lcyl/2,\Hcyl/2) -- ++(-\Lcyl,0) arc (90:270:{\Wcyl} and \Hcyl/2) -- ++(\Lcyl,0) arc (270:90:{\Wcyl} and \Hcyl/2) ; %Remainder |
| 2262 |
%Create auxiliary points |
| 2263 |
\coordinate (-center) at (0,0); %center point |
| 2264 |
\coordinate (-O) at (-center); %center point |
| 2265 |
\coordinate (-A) at (\Lcyl/2,0); %right center point |
| 2266 |
\coordinate (-C) at ($(-A) + (\armRight,0)$); %east extremity |
| 2267 |
\coordinate (-B) at (-\Lcyl/2-\Wcyl,0); %right center point |
| 2268 |
\coordinate (-D) at ($(-A) - (\Lcyl,0) - (\armLeft,0)$); %west extremity |
| 2269 |
\coordinate (-E) at (0,\Hcyl/2); %top point on surface |
| 2270 |
\coordinate (-F) at (0,-\Hcyl/2); %bottom point on surface |
| 2271 |
\coordinate (-G) at ($(-E) + (0,\armGap)$); %top arm center |
| 2272 |
\coordinate (-H) at ($(-F) - (0,\armGap)$); %bottom arm center |
| 2273 |
\coordinate (-J) at ($(0,0) + (45:{\armGap+\Hcyl/4})$); %back arm center |
| 2274 |
\coordinate (-K) at ($(0,0) + (-135:{\armGap+\Hcyl/4})$); %front arm center |
| 2275 |
\coordinate (-east) at (-C); |
| 2276 |
\coordinate (-west) at (-D); |
| 2277 |
\coordinate (-label) at ($(-center)-(\Hcyl/6,0pt)$); %adjusted a bit to the left |
| 2278 |
%Define some macros to test argument |
| 2279 |
\def\arg{#1} %if absent a default with simple ends |
| 2280 |
\edef\NOENDS{0}% no ends. A simple cylinder |
| 2281 |
\def\TTT {1} %top |
| 2282 |
\def\BBB {2} %bottom |
| 2283 |
\def\NNN {3} %near (front/closer) |
| 2284 |
\def\FFF {4} %far (back of page) |
| 2285 |
%Adapt behavior depending on argument |
| 2286 |
\if\arg\TTT %1 is to draw arm on the top (use \if not \ifx !!!) |
| 2287 |
\coordinate (-south) at (-F); \coordinate (-start) at (-south); \coordinate (-in) at (-south); |
| 2288 |
\coordinate (-north) at (-G); \coordinate (-end) at (-north); \coordinate (-out) at (-north); |
| 2289 |
\draw [knLinkStyle] (-A) -- (-C) |- (-G); %upper arm |
| 2290 |
\begin{pgfonlayer}{background} |
| 2291 |
\draw [knLinkStyle] (-G) -| (-D) -- (-B); %upper arm |
| 2292 |
\end{pgfonlayer}{background} |
| 2293 |
\else |
| 2294 |
\if\arg\BBB %2 is to draw arm on the bottom |
| 2295 |
\coordinate (-south) at (-H); \coordinate (-end) at (-south); \coordinate (-out) at (-south); |
| 2296 |
\coordinate (-north) at (-E); \coordinate (-in) at (-north); \coordinate (-start) at (-north); |
| 2297 |
\draw [knLinkStyle] (-A) -- (-C) |- (-H); |
| 2298 |
\begin{pgfonlayer}{background} |
| 2299 |
\draw [knLinkStyle] (-H) -| (-D) -- (-B); %lower arm |
| 2300 |
\end{pgfonlayer}{background} |
| 2301 |
\else |
| 2302 |
\if\arg\NNN %3 is to draw arm on the front ()near) |
| 2303 |
\coordinate (-south) at (-F); \coordinate (-in2) at (-south); \coordinate (-start2) at (-south); |
| 2304 |
\coordinate (-north) at (-E); |
| 2305 |
\coordinate (-in) at ($(0,0) + (45:{0.707*\Hcyl})$); |
| 2306 |
\coordinate (-start) at (-in); |
| 2307 |
\coordinate (-out) at (-K); \coordinate (-end) at (-out); |
| 2308 |
% \draw [knJointStyle] (-A) -- (-C) to [45-] (-K) -- ++(-\Lcyl/2-\armRight,0) -- (-D) -- (-B); %front arm |
| 2309 |
\draw [knLinkStyle] (-A) -- (-C) to [45-] (-K); |
| 2310 |
\begin{pgfonlayer}{background} |
| 2311 |
\draw [knLinkStyle] (-K) -- ++(-\Lcyl/2-\armRight,0) -- (-D) -- (-B); %front arm |
| 2312 |
\end{pgfonlayer}{background} |
| 2313 |
\else |
| 2314 |
\if\arg\FFF %4 is to draw arm on the back far) |
| 2315 |
\coordinate (-south) at (-F); |
| 2316 |
\coordinate (-in) at ($(0,0) + (-135:{\Hcyl/4})$); \coordinate (-start) at (-in); |
| 2317 |
\coordinate (-north) at (-J); \coordinate (-out) at (-north); \coordinate (-end) at (-north); |
| 2318 |
% \draw [knJointStyle] (-B) -- (-D) to [45-] (-J) -- ++(\Lcyl/2+\armRight,0) -- (-C) -- (-A); % back arm |
| 2319 |
\draw [knLinkStyle] (-A) -- (-C) -- ++(45:{\Hcyl/4+\armGap}) -- (-J); |
| 2320 |
\begin{pgfonlayer}{background} |
| 2321 |
\draw [knLinkStyle] (-J) -- ++({-\Lcyl/2-\armLeft},0) -- (-D) -- (-B); |
| 2322 |
\end{pgfonlayer} |
| 2323 |
\else |
| 2324 |
\if\arg\NOENDS %0 is not to draw any ends or arms so adjust |
| 2325 |
\coordinate (-east) at (-A); |
| 2326 |
\coordinate (-west) at (-B); |
| 2327 |
\coordinate (-south) at (-F); |
| 2328 |
\coordinate (-north) at (-E); |
| 2329 |
\coordinate (-in) at (-west); \coordinate (-start) at (-in); |
| 2330 |
\coordinate (-out) at (-east); \coordinate (-end) at (-out); |
| 2331 |
\else %other values (or none) is not to draw arm only pins |
| 2332 |
\coordinate (-south) at (-F); |
| 2333 |
\coordinate (-north) at (-E); |
| 2334 |
\coordinate (-in) at (-west); \coordinate (-start) at (-in); |
| 2335 |
\coordinate (-out) at (-east); \coordinate (-end) at (-out); |
| 2336 |
\draw [knLinkStyle] (-A) -- (-C); |
| 2337 |
\begin{pgfonlayer}{background} |
| 2338 |
\draw [knLinkStyle] (-B) -- (-D); |
| 2339 |
\end{pgfonlayer} |
| 2340 |
\fi %of NOENDS |
| 2341 |
\fi %of FFF |
| 2342 |
\fi %of NNN |
| 2343 |
\fi %of BBB |
| 2344 |
\fi %of TTT |
| 2345 |
% For illustration purposed only... |
| 2346 |
% \foreach \n in {A,B,C,D,E,F,G,H,J,K,O} |
| 2347 |
% \foreach \n in {in,out} % |
| 2348 |
% \foreach \n in {start,end} % |
| 2349 |
% \foreach \n in {center,east,west,north,south} % north,south coincide with in/out |
| 2350 |
% \fill (-\n) circle (0.5pt) node [inner sep=0,anchor=south,yshift=1pt,font={\tiny\sffamily}] {\n}; |
| 2351 |
} |
| 2352 |
}, |
| 2353 |
%------------------------------------------------- |
| 2354 |
pics/rotational 3D P/.style={ %rotational 3D joint in perspective |
| 2355 |
% Arg 1 -> direction of the arm coming out of the cylinder |
| 2356 |
% 1 %arm on right |
| 2357 |
% 2 %arm on left |
| 2358 |
% 3 %arm up |
| 2359 |
% 4 %arm down |
| 2360 |
% 0 or no argment % raw cylinder with no ends at all |
| 2361 |
code={ |
| 2362 |
%Create auxiliary points |
| 2363 |
\coordinate (-center) at (0,0); %center point |
| 2364 |
\coordinate (-O) at (-center); %center point |
| 2365 |
\coordinate (-A) at ($(-center) + (-135:{\Lcyl/4})$); %right cyl center, start point of circle |
| 2366 |
% \coordinate (-B) at ($ (-A) + (45:{\Lcyl/2+\Hcyl/2}) $); %Left cyl center |
| 2367 |
\coordinate (-B) at ($ (-A) + (45:{\Lcyl/2}) $); %Left cyl center |
| 2368 |
\coordinate (-C) at ($ (-A) + (-135:{\armRight/2)})$); %right arm extremity |
| 2369 |
\coordinate (-D) at ($ (-A) + (45:{\Lcyl/2+\armLeft/2)})$); %left arm extremity |
| 2370 |
\coordinate (-D) at ($ (-B) + (45:{\armLeft/2)})$); %left arm extremity |
| 2371 |
\coordinate (-E) at (0, \Hcyl/2); %top point of cylinder surface |
| 2372 |
|
| 2373 |
\coordinate (-G) at (0, {\Hcyl/2+\armGap}); % arm center top |
| 2374 |
\coordinate (-H) at (0, {-\Hcyl/2-\armGap}); %Arm center bottom |
| 2375 |
\coordinate (-J) at ({\Hcyl/2+\armGap},0); %Arm center right |
| 2376 |
\coordinate (-K) at ({-\Hcyl/2-\armGap},0); %Arm center left |
| 2377 |
\coordinate (-L) at (\Hcyl/2,0,0); % right side of cylinder surface |
| 2378 |
|
| 2379 |
\path [name path=vsLocalCirc] (-A) ellipse ({\Hcyl/2} and {\Hcyl/2}); |
| 2380 |
\path [name path=vsHorizLine] (-center) -- ++(-\Hcyl,0); |
| 2381 |
\path [name path=vsVertiLine] (-center) -- ++(0,-\Hcyl); |
| 2382 |
\path [name intersections={of={vsHorizLine} and {vsLocalCirc}}] ; |
| 2383 |
\coordinate (-M) at (intersection-1); % left point of cylinder surface |
| 2384 |
\path [name intersections={of={vsVertiLine} and {vsLocalCirc}}] ; |
| 2385 |
\coordinate (-F) at (intersection-1); % Bottom point of cylinder surface |
| 2386 |
|
| 2387 |
\path [name path=vsDiagLine] (-B) -- ++(45:\Hcyl); |
| 2388 |
\path [name path=vsRestOfCyl] ($(-A)+(135:{\Hcyl/2})$) -- |
| 2389 |
++(45:\Lcyl/2) arc (135:-45:{\Hcyl/2} and {\Hcyl/2}) -- |
| 2390 |
++(-135:\Lcyl/2) arc (-45:135:{\Hcyl/2} and {\Hcyl/2}); |
| 2391 |
\path [name intersections={of={vsDiagLine} and {vsRestOfCyl}}] ; |
| 2392 |
\coordinate (-N) at (intersection-1); % far point of cylinder in diag |
| 2393 |
|
| 2394 |
|
| 2395 |
\coordinate (-southwest) at (-C); |
| 2396 |
\coordinate (-northeast) at (-D); |
| 2397 |
\coordinate (-label) at ($(-center)!0.7!(-D)$); %some point to place label with enough clearance |
| 2398 |
\coordinate (-near) at (-C); |
| 2399 |
\coordinate (-far) at (-D); |
| 2400 |
|
| 2401 |
\coordinate (-west) at (-M); %default for simple cylinder |
| 2402 |
\coordinate (-east) at (-L); %default for simple cylinder |
| 2403 |
|
| 2404 |
%Draw the perspective cylinder with visible face on the right (facing out) |
| 2405 |
%Actually it is a circle in ortogonal projection... anyway... |
| 2406 |
\draw [knJointStyle] (-A) ellipse ({\Hcyl/2} and {\Hcyl/2}); %front ellipse |
| 2407 |
\newcommand{\knDrawCylinderLateral}{ |
| 2408 |
\draw [knJointStyle,fill=white] ($(-A)+(135:{\Hcyl/2})$) -- |
| 2409 |
++(45:\Lcyl/2) arc (135:-45:{\Hcyl/2} and {\Hcyl/2}) -- |
| 2410 |
++(-135:\Lcyl/2) arc (-45:135:{\Hcyl/2} and {\Hcyl/2}); %rest of cylinder filled with white |
| 2411 |
} |
| 2412 |
\def\arg{#1} |
| 2413 |
\def\RRR {1} %arm on right |
| 2414 |
\def\LLL {2} %arm on left |
| 2415 |
\def\UUU {3} %arm up |
| 2416 |
\def\DDD {4} %arm down |
| 2417 |
\def\NOENDS{0} %no ends at all |
| 2418 |
|
| 2419 |
% \begin{pgfonlayer}{background} %Needed to take advantage of hidden lines in some arms...) |
| 2420 |
\if\arg\RRR %1 is to draw arm on the right |
| 2421 |
\coordinate (-south) at (-F); \coordinate (-start bottom) at (-south); \coordinate (-in bottom) at (-south); |
| 2422 |
\coordinate (-east) at (-J); \coordinate (-end) at (-east); \coordinate (-out) at (-east); |
| 2423 |
\coordinate (-north) at (-E); \coordinate (-in top) at (-north); \coordinate (-start top) at (-north); |
| 2424 |
\coordinate (-west) at (-M); \coordinate (-in left) at (-west); \coordinate (-start left) at (-west); |
| 2425 |
\coordinate (-in) at (-in left); \coordinate (-start) at (-start left); |
| 2426 |
%Right |
| 2427 |
%Some tricks because to [45-] forces some specific path :-( |
| 2428 |
% \draw [knLinkStyle](-A) -- (-C)(-J) to[45-] (-C)(-J) -- ++(45:{\Lcyl/4+\armLeft/2}) -- (-D) -- (-B); |
| 2429 |
% \begin{pgfonlayer}{background} |
| 2430 |
\draw [knLinkStyle] (-J) -- ++(45:{\Lcyl/4+\armLeft/2}) -- (-D) -- (-B); %back part of arm |
| 2431 |
\knDrawCylinderLateral |
| 2432 |
\draw [knLinkStyle] (-A) -- (-C) -- ++({\Hcyl/2+\armGap},0) -- (-J); %front part of arm |
| 2433 |
% \end{pgfonlayer} |
| 2434 |
\else |
| 2435 |
\if\arg\LLL %2 is to draw arm on the left |
| 2436 |
\coordinate (-south) at (-F); \coordinate (-start bottom) at (-south); \coordinate (-in bottom) at (-south); |
| 2437 |
\coordinate (-east) at (-L); \coordinate (-in right) at (-east); \coordinate (-start right) at (-east); |
| 2438 |
\coordinate (-north) at (-E); \coordinate (-in top) at (-north); \coordinate (-start top) at (-north); |
| 2439 |
\coordinate (-west) at (-K); \coordinate (-out) at (-west); \coordinate (-end) at (-west); |
| 2440 |
\coordinate (-in) at (-in right); \coordinate (-start) at (-start right); |
| 2441 |
%Left |
| 2442 |
%\draw [knJointStyle](-A) -- (-C) -- ++(180:{\Hcyl/2+\armGap}) -- (-K) to[45-] (-D) -- (-B); |
| 2443 |
% \begin{pgfonlayer}{background} |
| 2444 |
\draw [knLinkStyle](-K) to[45-] (-D) -- (-B); |
| 2445 |
% \end{pgfonlayer} |
| 2446 |
\knDrawCylinderLateral |
| 2447 |
\draw [knLinkStyle](-A) -- (-C) -- ++(180:{\Hcyl/2+\armGap}) -- (-K); |
| 2448 |
\else |
| 2449 |
\if\arg\UUU %3 is to draw arm on the upper part |
| 2450 |
\coordinate (-south) at (-F); \coordinate (-start bottom) at (-south); \coordinate (-in bottom) at (-south); |
| 2451 |
\coordinate (-east) at (-L); \coordinate (-in right) at (-east); \coordinate (-start right) at (-east); |
| 2452 |
\coordinate (-north) at (-G); \coordinate (-out) at (-north); \coordinate (-end) at (-north); |
| 2453 |
\coordinate (-west) at (-M); \coordinate (-in left) at (-west); \coordinate (-start left) at (-west); |
| 2454 |
\coordinate (-in) at (-in bottom); \coordinate (-start) at (-start bottom); |
| 2455 |
%Up |
| 2456 |
% \draw [knJointStyle](-A) -- (-C)(-G) to[45-] (-C)(-G) -- ++(45:{\Lcyl/4+\armLeft/2}) -- (-D) -- (-B); |
| 2457 |
% \begin{pgfonlayer}{background} |
| 2458 |
\draw [knLinkStyle] (-G) -- ++(45:{\Lcyl/4+\armLeft/2}) -- (-D) -- (-B); ; |
| 2459 |
% \end{pgfonlayer} |
| 2460 |
\knDrawCylinderLateral |
| 2461 |
\draw [knLinkStyle](-A) -- (-C) -- ++(0,\Hcyl/2+\armGap) -- (-G); |
| 2462 |
\else |
| 2463 |
\if\arg\DDD %4 is to draw arm on the lower part) |
| 2464 |
\coordinate (-south) at (-H); \coordinate (-end) at (-south); \coordinate (-out) at (-south); |
| 2465 |
\coordinate (-east) at (-L); \coordinate (-in right) at (-east); \coordinate (-start right) at (-east); |
| 2466 |
\coordinate (-north) at (-E); \coordinate (-in top) at (-north); \coordinate (-start top) at (-north); |
| 2467 |
\coordinate (-west) at (-M); \coordinate (-in left) at (-west); \coordinate (-start left) at (-west); |
| 2468 |
\coordinate (-in) at (-in top); \coordinate (-start) at (-start top); |
| 2469 |
%Down |
| 2470 |
%\draw [knJointStyle](-A) -- (-C) -- ++(-90:{\Hcyl/2+\armGap}) -- (-H) to[45-] (-D) -- (-B); |
| 2471 |
% \begin{pgfonlayer}{background} |
| 2472 |
\draw [knLinkStyle] (-H)to[45-] (-D) -- (-B); |
| 2473 |
% \end{pgfonlayer} |
| 2474 |
\knDrawCylinderLateral |
| 2475 |
\draw [knLinkStyle](-A) -- (-C) -- ++(-90:{\Hcyl/2+\armGap}) -- (-H); |
| 2476 |
\else |
| 2477 |
\if\arg\NOENDS %0 is to draw no extremities or arm |
| 2478 |
\coordinate (-south) at (-F); |
| 2479 |
\coordinate (-north) at (-E); |
| 2480 |
\coordinate (-southwest) at (-A); |
| 2481 |
\coordinate (-northeast) at (-B); |
| 2482 |
\coordinate (-in near) at (-A); |
| 2483 |
\coordinate (-in left) at (-M); \coordinate (-start left) at (-in left); |
| 2484 |
\coordinate (-in bottom) at (-south); \coordinate (-start bottom) at (-in bottom); |
| 2485 |
\coordinate (-in top) at (-north); \coordinate (-start top) at (-in top); |
| 2486 |
\coordinate (-out far) at (-N); \coordinate (-out right) at (-east); |
| 2487 |
\coordinate (-in) at (-in left); \coordinate (-start) at (-in); |
| 2488 |
\coordinate (-out) at (-out right); \coordinate (-end) at (-out); |
| 2489 |
\knDrawCylinderLateral |
| 2490 |
\else %other values (or none) is not to draw arm; only pins |
| 2491 |
\coordinate (-south) at (-F); |
| 2492 |
\coordinate (-north) at (-E); |
| 2493 |
\coordinate (-in) at (-near); \coordinate (-start) at (-in); |
| 2494 |
\coordinate (-out) at (-N); \coordinate (-end) at (-out); |
| 2495 |
% \begin{pgfonlayer}{background} |
| 2496 |
\draw [knLinkStyle] (-B) -- (-D); |
| 2497 |
% \end{pgfonlayer} |
| 2498 |
\knDrawCylinderLateral |
| 2499 |
\draw [knLinkStyle] (-A) -- (-C); |
| 2500 |
\fi %of NOENDS |
| 2501 |
\fi %of DDD |
| 2502 |
\fi %of UUU |
| 2503 |
\fi %of LLL |
| 2504 |
\fi %of RRR |
| 2505 |
% \end{pgfonlayer} |
| 2506 |
% For illustration purposed only... |
| 2507 |
% \foreach \n in {A,B,C,D,E,F,G,H,J,K,L,M} |
| 2508 |
% \foreach \n in {in,out} % |
| 2509 |
% \foreach \n in {start,end} % |
| 2510 |
% \foreach \n in {center,east,west,north,south} % north,south coincide with in/out |
| 2511 |
% \fill (-\n) circle (0.5pt) node [inner sep=0,anchor=south,yshift=1pt,font={\tiny\sffamily}] {\n}; |
| 2512 |
} |
| 2513 |
}, |
| 2514 |
%------------------------------------------------- |
| 2515 |
pics/rotational 3D V/.style={ %rotational joint in 3D in Vertical position |
| 2516 |
% Arg 1 %if absent a default with simple ends |
| 2517 |
% 0: no ends. A simple cylinder |
| 2518 |
% 1: arm at left |
| 2519 |
% 2: arm at right |
| 2520 |
% 3: arm at near (front/closer) |
| 2521 |
% 4: arm at far (back of page) |
| 2522 |
code={ %copied code orinally from the horizontal and rotated it :-) |
| 2523 |
\begin{scope}[rotate=90,yscale=-1] %use yscale -1 to have arm=1 on the right and the perspective variants in the right direction |
| 2524 |
%Draw the horizontal cylinder with visible face on the right |
| 2525 |
\draw [knJointStyle] (\Lcyl/2,0) ellipse ({\Wcyl} and \Hcyl/2); %right (top) ellipse |
| 2526 |
\draw [knJointStyle,fill=white] (\Lcyl/2,\Hcyl/2) -- ++(-\Lcyl,0) arc (90:270:{\Wcyl} and \Hcyl/2) -- |
| 2527 |
++(\Lcyl,0) arc (270:90:{\Wcyl} and \Hcyl/2) ; %Remainder |
| 2528 |
|
| 2529 |
%%% |
| 2530 |
\path [name path=vsDiagLine] (0,0) -- ++(45:\Hcyl); |
| 2531 |
\path [name path=vsRestOfCyl] (\Lcyl/2,\Hcyl/2) -- ++(-\Lcyl,0) arc (90:270:{\Wcyl} and \Hcyl/2) -- |
| 2532 |
++(\Lcyl,0) arc (270:90:{\Wcyl} and \Hcyl/2) ; |
| 2533 |
\path [name intersections={of={vsDiagLine} and {vsRestOfCyl}}] ; |
| 2534 |
\coordinate (-N) at (intersection-1); % lateral far point of cylinder in diag |
| 2535 |
|
| 2536 |
%Create auxiliary points |
| 2537 |
\coordinate (-center) at (0,0); %center point |
| 2538 |
\coordinate (-O) at (-center); %center point |
| 2539 |
\coordinate (-A) at (\Lcyl/2,0); %right center point |
| 2540 |
\coordinate (-C) at ($(-A) + (\armRight,0)$); %east extremity |
| 2541 |
\coordinate (-B) at (-\Lcyl/2-\Wcyl,0); %right center point |
| 2542 |
\coordinate (-D) at ($(-A) - (\Lcyl,0) - (\armLeft,0)$); %west extremity |
| 2543 |
\coordinate (-E) at (0,\Hcyl/2); %top point on surface |
| 2544 |
\coordinate (-F) at (0,-\Hcyl/2); %bottom point on surface |
| 2545 |
\coordinate (-G) at ($(-E) + (0,\armGap)$); %top arm center |
| 2546 |
\coordinate (-H) at ($(-F) - (0,\armGap)$); %bottom arm center |
| 2547 |
\coordinate (-J) at ($(0,0) + (45:{\armGap+\Hcyl/4})$); %back arm center |
| 2548 |
\coordinate (-K) at ($(0,0) + (-135:{\armGap+\Hcyl/4})$); %front arm center |
| 2549 |
\coordinate (-east) at (-E); |
| 2550 |
\coordinate (-west) at (-F); |
| 2551 |
\coordinate (-label) at ($(-center)-(\Hcyl/6,0pt)$); %adjusted a bit to the bottom |
| 2552 |
%Define some macros to test argument |
| 2553 |
\def\arg{#1} %if absent a default with simple ends |
| 2554 |
\edef\NOENDS{0}% no ends. A simple cylinder |
| 2555 |
\def\TTT {1} %top (when rotated - left) |
| 2556 |
\def\BBB {2} %bottom (when rotated - right) |
| 2557 |
\def\NNN {3} %near (front/closer) |
| 2558 |
\def\FFF {4} %far (back of page) |
| 2559 |
%Adapt behavior depending on argument |
| 2560 |
\if\arg\TTT %1 is to draw arm on the top (right) (use \if not \ifx !!!) |
| 2561 |
\coordinate (-south) at (-D); \coordinate (-start) at (-F); \coordinate (-in) at (-start); |
| 2562 |
\coordinate (-north) at (-C); \coordinate (-end) at (-G); \coordinate (-out) at (-end); |
| 2563 |
% \draw [knLinkStyle] (-A) -- (-C) |- (-G) -| (-D) -- (-B); %upper arm |
| 2564 |
\draw [knLinkStyle] (-A) -- (-C) |- (-G); %upper half arm |
| 2565 |
% \begin{pgfonlayer}{background} %not needed (and does not inherit all passed options :-(! ) |
| 2566 |
\draw [knLinkStyle] (-G) -| (-D) -- (-B); %lower half arm |
| 2567 |
% \end{pgfonlayer}{background} |
| 2568 |
\else |
| 2569 |
\if\arg\BBB %2 is to draw arm on the bottom (left) |
| 2570 |
\coordinate (-south) at (-D); \coordinate (-end) at (-H); \coordinate (-out) at (-end); |
| 2571 |
\coordinate (-west) at (-end); |
| 2572 |
\coordinate (-north) at (-C); \coordinate (-in) at (-E); \coordinate (-start) at (-in); |
| 2573 |
% \draw [knLinkStyle] (-A) -- (-C) |- (-H) -| (-D) -- (-B); %lower arm |
| 2574 |
\draw [knLinkStyle] (-A) -- (-C) |- (-H); |
| 2575 |
% \begin{pgfonlayer}{background} |
| 2576 |
\draw [knLinkStyle] (-H) -| (-D) -- (-B); %lower arm |
| 2577 |
% \end{pgfonlayer}{background} |
| 2578 |
\else |
| 2579 |
\if\arg\NNN %3 is to draw arm on the front (near) |
| 2580 |
\coordinate (-south) at (-D); \coordinate (-in2) at (-south); \coordinate (-start2) at (-south); |
| 2581 |
\coordinate (-north) at (-C); \coordinate (-in) at (-N); \coordinate (-start) at (-in); |
| 2582 |
\coordinate (-out) at (-K); \coordinate (-end) at (-out); |
| 2583 |
% \draw [knLinkStyle] (-A) -- (-C) to [45-] (-K) -- ++(-\Lcyl/2-\armRight,0) -- (-D) -- (-B); %front arm |
| 2584 |
\draw [knLinkStyle] (-A) -- (-C) to [45-] (-K); |
| 2585 |
% \begin{pgfonlayer}{background} |
| 2586 |
\draw [knLinkStyle] (-K) -- ++(-\Lcyl/2-\armRight,0) -- (-D) -- (-B); %front arm |
| 2587 |
% \end{pgfonlayer}{background} |
| 2588 |
\else |
| 2589 |
\if\arg\FFF %4 is to draw arm on the back far) |
| 2590 |
\coordinate (-south) at (-D); \coordinate (-in) at ($(-center)+(-135:\Hcyl/4)$); \coordinate (-start) at (-in); |
| 2591 |
\coordinate (-north) at (-C); \coordinate (-out) at (-J); \coordinate (-end) at (-out); |
| 2592 |
% \draw [knLinkStyle] (-B) -- (-D) to [45-] (-J) -- ++(\Lcyl/2+\armRight,0) -- (-C) -- (-A); % back arm |
| 2593 |
\draw [knLinkStyle] (-A) -- (-C) -- ++(45:{\Hcyl/4+\armGap}) -- (-J); |
| 2594 |
\begin{pgfonlayer}{background} |
| 2595 |
\draw [knLinkStyle] (-J) -- ++({-\Lcyl/2-\armLeft},0) -- (-D) -- (-B); |
| 2596 |
\end{pgfonlayer} |
| 2597 |
\else |
| 2598 |
\if\arg\NOENDS %0 is not to draw any ends or arms so adjust |
| 2599 |
\coordinate (-east) at (-F); |
| 2600 |
\coordinate (-west) at (-E); |
| 2601 |
\coordinate (-south) at (-B); |
| 2602 |
\coordinate (-north) at (-A); |
| 2603 |
\coordinate (-in) at (-south); \coordinate (-start) at (-in); |
| 2604 |
\coordinate (-out) at (-north); \coordinate (-end) at (-out); |
| 2605 |
\else %other values (or none) is not to draw arm only pins |
| 2606 |
\coordinate (-south) at (-D); |
| 2607 |
\coordinate (-north) at (-C); |
| 2608 |
\coordinate (-in) at (-south); \coordinate (-start) at (-in); |
| 2609 |
\coordinate (-out) at (-north); \coordinate (-end) at (-out); |
| 2610 |
\draw [knLinkStyle] (-A) -- (-C); |
| 2611 |
\begin{pgfonlayer}{background} |
| 2612 |
\draw [knLinkStyle] (-B) -- (-D); |
| 2613 |
\end{pgfonlayer} |
| 2614 |
\fi %of NOENDS |
| 2615 |
\fi %of FFF |
| 2616 |
\fi %of NNN |
| 2617 |
\fi %of BBB |
| 2618 |
\fi %of TTT |
| 2619 |
% For illustration purposed only... |
| 2620 |
% \foreach \n in {A,B,C,D,E,F,G,H,J,K,O} |
| 2621 |
% \foreach \n in {in,out} % |
| 2622 |
% \foreach \n in {start,end} % |
| 2623 |
% \foreach \n in {center,east,west,north,south} % north,south coincide with in/out |
| 2624 |
% \fill (-\n) circle (0.5pt) node [inner sep=0,anchor=south,yshift=1pt,font={\tiny\sffamily}] {\n}; |
| 2625 |
\end{scope} |
| 2626 |
} |
| 2627 |
}, |
| 2628 |
%------------------------------------------------- |
| 2629 |
% |
| 2630 |
} %end of tikzset |
| 2631 |
%------------------------------------------------ |
| 2632 |
|
| 2633 |
\endinput |