%% tikzlibrarytikzphysics.mechanics.code.tex %% ----------------------------------------------------------- %% Mechanics module for tikzphysics. %% %% Native mechanics primitives and connections: %% - physicsblock : simple rectangular block style %% - physicspulley : circle with optional axle-dot %% - spring : configurable coil node or two-point path style %% - \physicsstringoverpulley : tangent string segments plus circular wrap %% %% Also provides particle/disk/ring nodes, vector/rod styles, support and %% pendulum pics, and the native over-pulley to path. %% %% Internal namespace : \tikzphysics@mech@... %% Requires : tikz, calc, tikzphysics.core %% %% Author : Vaibhav Blayer %% Version : v1.8.0 (2026-10-11) %% License : LPPL 1.3c %% ----------------------------------------------------------- \usetikzlibrary{calc,decorations.pathmorphing} \usetikzlibrary{tikzphysics.core} \makeatletter \tikzphysics@declarehook{block} \tikzphysics@declarehook{pulley} \tikzphysics@declarehook{spring} \tikzphysics@declarehook{rope} %% ============================================================ %% INTERNAL STATE %% ============================================================ \def\tikzphysics@mech@pulleycenterfill{1.5pt} \def\tikzphysics@mech@pulleycenterfillcolor{black} \def\tikzphysics@mech@stringstartsolution{2} \def\tikzphysics@mech@stringendsolution{1} \def\tikzphysics@mech@stringdelta{-(Mod(\n1-\n2,360))} \newdimen\tikzphysics@mech@springkeydim %% Freeze the resolved length before forwarding it: PGF stores pre/post %% length as values, so keeping a reference to the scratch register would %% let a later amplitude or segment-length option change both leads. \def\tikzphysics@mech@setspringkey#1{% \edef\tikzphysics@mech@springkeycall{% \noexpand\pgfkeysalso{/pgf/decoration/#1={\the\tikzphysics@mech@springkeydim}}}% \tikzphysics@mech@springkeycall } %% TikZ runs this hook inside the node-options group. Remember its level so %% the same spring key can select a node or a path, including inline nodes, %% node contents=..., and nested paths inside node text. No public TikZ %% command or user every-node/every-path style is replaced. \def\tikzphysics@mech@nodelevel{-1} \pgfutil@g@addto@macro\tikz@node@reset@hook{% \edef\tikzphysics@mech@nodelevel{\the\currentgrouplevel}% } %% Optional command arguments are often split over lines. Trim only their %% leading/trailing spaces before handing the unchanged key list to TikZ. \ExplSyntaxOn \cs_new_protected:Npn \tikzphysics_mech_tikzset_trim:n #1 { \tl_set:Nn \l_tmpa_tl {#1} \tl_trim_spaces:N \l_tmpa_tl \exp_args:NV \tikzset \l_tmpa_tl } \cs_new_eq:NN \tikzphysics@mech@tikzsettrim \tikzphysics_mech_tikzset_trim:n \ExplSyntaxOff %% ============================================================ %% TIKZ KEYS (scoped, unit-aware) %% ============================================================ \tikzset{ %% ---- block sizing ---- physics block width/.code = {\tikzphysics@length@keyhandler{/pgf/minimum width}{#1}}, physics block height/.code = {\tikzphysics@length@keyhandler{/pgf/minimum height}{#1}}, block width/.style = {physics block width={#1}}, block height/.style = {physics block height={#1}}, %% ---- pulley sizing ---- physics pulley diameter/.code = {\tikzphysics@length@keyhandler{/pgf/minimum size}{#1}}, pulley diameter/.style = {physics pulley diameter={#1}}, %% ---- spring geometry ---- physics spring pre length/.code={% \tikzphysics@resolve@nonnegative{\tikzphysics@mech@springkeydim}{#1}% \tikzphysics@mech@setspringkey{pre length}}, physics spring post length/.code={% \tikzphysics@resolve@nonnegative{\tikzphysics@mech@springkeydim}{#1}% \tikzphysics@mech@setspringkey{post length}}, physics spring amplitude/.code={% \tikzphysics@resolve@length{\tikzphysics@mech@springkeydim}{#1}% \tikzphysics@mech@setspringkey{amplitude}}, physics spring segment length/.code={% \tikzphysics@resolve@length{\tikzphysics@mech@springkeydim}{#1}% \tikzphysics@mech@setspringkey{segment length}}, physics spring aspect/.style={/pgf/decoration/aspect={#1}}, pre length/.style={physics spring pre length={#1}}, post length/.style={physics spring post length={#1}}, amplitude/.style={physics spring amplitude={#1}}, segment length/.style={physics spring segment length={#1}}, aspect/.style={physics spring aspect={#1}}, physics spring length/.code={\tikzphysics@length@keyhandler{/pgf/minimum width}{#1}}, spring length/.style={physics spring length={#1}}, %% ---- pulley axle-dot ---- physics pulley axle radius/.code = {\def\tikzphysics@mech@pulleycenterfill{#1}}, physics pulley axle color/.code = {\def\tikzphysics@mech@pulleycenterfillcolor{#1}}, pulley axle radius/.style = {physics pulley axle radius={#1}}, pulley axle color/.style = {physics pulley axle color={#1}}, physics pulley axle radius = 1.5pt, physics pulley axle color = black, %% ---- tangent string construction ---- physics string start solution/.code = {\def\tikzphysics@mech@stringstartsolution{#1}}, physics string end solution/.code = {\def\tikzphysics@mech@stringendsolution{#1}}, physics string wrap/.is choice, physics string wrap/clockwise/.code = {\def\tikzphysics@mech@stringdelta{-(Mod(\n1-\n2,360))}}, physics string wrap/counterclockwise/.code = {\def\tikzphysics@mech@stringdelta{Mod(\n2-\n1,360)}}, physics string wrap/shortest/.code = {\def\tikzphysics@mech@stringdelta{Mod(\n2-\n1+180,360)-180}}, %% Named routes for the common case in which the first endpoint lies %% generally to the left of the pulley and the second lies to its right. %% The explicit solution/wrap keys remain available for every orientation. physics string route/.is choice, physics string route/over/.style={ physics string start solution=2, physics string end solution=1, physics string wrap=clockwise, }, physics string route/under/.style={ physics string start solution=1, physics string end solution=2, physics string wrap=counterclockwise, }, physics string route/surface-right/.style={ physics string start solution=2, physics string end solution=1, physics string wrap=clockwise, }, physics string route/shortest/.style={physics string wrap=shortest}, string start solution/.style={physics string start solution={#1}}, string end solution/.style={physics string end solution={#1}}, string wrap/.style={physics string wrap={#1}}, string route/.style={physics string route={#1}}, physics string/.style={every physics connection, every rope, }, } %% ============================================================ %% SPRING SHAPE %% %% The background is one straight axis. TikZ applies the exact same coil %% decoration used by the path form; the shape only supplies geometry and %% anchors. All anchor dimensions are saved per node. %% ============================================================ \def\tikzphysics@mech@setspringdims{% \pgfmathsetlength{\pgf@x}{\pgfkeysvalueof{/pgf/minimum width}}% \@tempdima=\wd\pgfnodeparttextbox \pgfmathsetlength{\@tempdimb}{2*\pgfkeysvalueof{/pgf/inner xsep}}% \advance\@tempdima by\@tempdimb \ifdim\@tempdima>\pgf@x \pgf@x=\@tempdima\fi \ifdim\pgf@x>0pt\else \PackageError{tikzphysics}{spring node length must be positive}{Set spring length or minimum width to a positive length.}% \pgf@x=3cm \fi \edef\tikzphysics@mech@springwidth{\the\pgf@x}% \pgfmathsetlength{\@tempdima}{\pgfkeysvalueof{/pgf/decoration/pre length}}% \pgfmathsetlength{\@tempdimb}{\pgfkeysvalueof{/pgf/decoration/post length}}% \edef\tikzphysics@mech@springpre{\the\@tempdima}% \edef\tikzphysics@mech@springpost{\the\@tempdimb}% \advance\@tempdima by\@tempdimb \ifdim\@tempdima<\pgf@x\else \PackageError{tikzphysics}{spring node leads must be shorter than its length}{Reduce pre length/post length or increase spring length.}% \fi \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}/2}% \ifdim\pgfdecorationsegmentamplitude>\pgf@y \pgf@y=\pgfdecorationsegmentamplitude \fi \@tempdima=\ht\pgfnodeparttextbox \advance\@tempdima by\dp\pgfnodeparttextbox \@tempdima=.5\@tempdima \pgfmathsetlength{\@tempdimb}{\pgfkeysvalueof{/pgf/inner ysep}}% \advance\@tempdima by\@tempdimb \ifdim\@tempdima>\pgf@y \pgf@y=\@tempdima\fi \edef\tikzphysics@mech@springheight{\the\pgf@y}% } \pgfdeclareshape{physicsspring}{ \savedmacro{\tikzphysics@mech@springwidth}{\tikzphysics@mech@setspringdims} \savedmacro{\tikzphysics@mech@springheight}{\tikzphysics@mech@setspringdims} \savedmacro{\tikzphysics@mech@springpre}{\tikzphysics@mech@setspringdims} \savedmacro{\tikzphysics@mech@springpost}{\tikzphysics@mech@setspringdims} \savedanchor{\northeast}{% \pgfmathsetlength{\pgf@x}{\tikzphysics@mech@springwidth/2+\pgfkeysvalueof{/pgf/outer xsep}}% \pgfmathsetlength{\pgf@y}{\tikzphysics@mech@springheight+\pgfkeysvalueof{/pgf/outer ysep}}% } \savedanchor{\southwest}{% \pgfmathsetlength{\pgf@x}{-\tikzphysics@mech@springwidth/2-\pgfkeysvalueof{/pgf/outer xsep}}% \pgfmathsetlength{\pgf@y}{-\tikzphysics@mech@springheight-\pgfkeysvalueof{/pgf/outer ysep}}% } \inheritanchorborder[from=rectangle] \anchor{center}{\pgfpointorigin} \anchor{start}{\pgfmathsetlength{\pgf@x}{-\tikzphysics@mech@springwidth/2}\pgf@y=0pt} \anchor{end}{\pgfmathsetlength{\pgf@x}{\tikzphysics@mech@springwidth/2}\pgf@y=0pt} \anchor{coil-start}{\pgfmathsetlength{\pgf@x}{-\tikzphysics@mech@springwidth/2+\tikzphysics@mech@springpre}\pgf@y=0pt} \anchor{coil-end}{\pgfmathsetlength{\pgf@x}{\tikzphysics@mech@springwidth/2-\tikzphysics@mech@springpost}\pgf@y=0pt} \anchor{north}{\northeast\pgf@x=0pt} \anchor{south}{\southwest\pgf@x=0pt} \anchor{east}{\northeast\pgf@y=0pt} \anchor{west}{\southwest\pgf@y=0pt} \anchor{north east}{\northeast} \anchor{south west}{\southwest} \anchor{north west}{\northeast\pgf@x=-\pgf@x} \anchor{south east}{\southwest\pgf@x=-\pgf@x} \anchor{text}{\pgf@x=-.5\wd\pgfnodeparttextbox\pgf@y=-.5\ht\pgfnodeparttextbox\advance\pgf@y by.5\dp\pgfnodeparttextbox} \tikzphysics@declareedgeanchors{axis}{-\tikzphysics@mech@springwidth/2}{0pt}{\tikzphysics@mech@springwidth/2}{0pt} \backgroundpath{% \pgfpathmoveto{\pgfpoint{-\tikzphysics@mech@springwidth/2}{0pt}}% \pgfpathlineto{\pgfpoint{\tikzphysics@mech@springwidth/2}{0pt}}% } } %% Private shapes preserve native rectangle/circle sizing and anchors. %% Percentage names never change ordinary TikZ rectangles or circles. \pgfdeclareshape{physicsblock}{ \inheritsavedanchors[from=rectangle] \foreach \a in {center,north,south,east,west,north east,north west,south east,south west,base,base east,base west,mid,mid east,mid west,text}{\inheritanchor[from=rectangle]{\a}} \inheritanchorborder[from=rectangle] \inheritbackgroundpath[from=rectangle] \tikzphysics@declarepercentanchors{bottom}{\southwest\edef\bx{\the\pgf@x}\edef\by{\the\pgf@y}\northeast\edef\tx{\the\pgf@x}\edef\ty{\the\pgf@y}}{\bx+\tikzphysics@percent*(\tx-\bx)}{\by} \tikzphysics@declarepercentanchors{right}{\southwest\edef\bx{\the\pgf@x}\edef\by{\the\pgf@y}\northeast\edef\tx{\the\pgf@x}\edef\ty{\the\pgf@y}}{\tx}{\by+\tikzphysics@percent*(\ty-\by)} \tikzphysics@declarepercentanchors{top}{\southwest\edef\bx{\the\pgf@x}\edef\by{\the\pgf@y}\northeast\edef\tx{\the\pgf@x}\edef\ty{\the\pgf@y}}{\tx-\tikzphysics@percent*(\tx-\bx)}{\ty} \tikzphysics@declarepercentanchors{left}{\southwest\edef\bx{\the\pgf@x}\edef\by{\the\pgf@y}\northeast\edef\tx{\the\pgf@x}\edef\ty{\the\pgf@y}}{\bx}{\ty-\tikzphysics@percent*(\ty-\by)} } \tikzphysics@registerfamilies{physicsblock}{bottom,right,top,left} \def\tikzphysics@mech@declarecircleshape#1{% \pgfdeclareshape{#1}{% \inheritsavedanchors[from=circle] \foreach \a in {center,north,south,east,west,north east,north west,south east,south west,base,base east,base west,mid,mid east,mid west,text}{\inheritanchor[from=circle]{\a}} \inheritanchorborder[from=circle] \inheritbackgroundpath[from=circle] \tikzphysics@declarepercentanchors{rim}{\centerpoint\edef\cx{\the\pgf@x}\edef\cy{\the\pgf@y}}{\cx+\radius*cos(360*\tikzphysics@percent)}{\cy+\radius*sin(360*\tikzphysics@percent)} }% \expandafter\let\csname tikz@tangent@#1\endcsname\tikz@tangent@circle } \tikzphysics@mech@declarecircleshape{physicspulley} \tikzphysics@mech@declarecircleshape{physicsparticle} \tikzphysics@mech@declarecircleshape{physicsdisk} \tikzphysics@mech@declarecircleshape{physicsring} \tikzphysics@registerfamilies{physicspulley}{rim} \tikzphysics@registerfamilies{physicsparticle}{rim} \tikzphysics@registerfamilies{physicsdisk}{rim} \tikzphysics@registerfamilies{physicsring}{rim} %% ============================================================ %% BLOCK, PULLEY, AND SPRING STYLES %% ============================================================ \tikzset{ physicsblock/.style={ shape=physicsblock, physics logical shape=physicsblock, draw=black, fill=none, inner sep=0pt, outer sep=0pt, minimum width=1cm, minimum height=1cm, physics debug setup, every physics object, every block, }, physicspulley/.style={ shape=physicspulley, physics logical shape=physicspulley, draw=black, fill=none, inner sep=0pt, outer sep=0pt, minimum size=1cm, path picture={% \def\tikzphysics@mech@pulley@none{none}% \ifx\tikzphysics@mech@pulleycenterfill\tikzphysics@mech@pulley@none\relax \else \fill[\tikzphysics@mech@pulleycenterfillcolor] (path picture bounding box.center) circle[radius=\tikzphysics@mech@pulleycenterfill];% \fi }, physics debug setup, every physics object, every pulley, }, physics spring coil/.style={ draw=black, decorate, decoration={ coil, pre length=5pt, post length=5pt, amplitude=4.5pt, segment length=4.5pt, aspect=0.5, }, }, physics spring node/.style={ physics spring coil, shape=physicsspring, physics logical shape=physicsspring, inner sep=0pt, outer sep=0pt, minimum width=3cm, minimum height=0pt, physics debug setup, every physics object, every physics connection, every spring, }, physics spring path/.style={physics spring coil, every physics connection, every spring}, physics spring/.code={% \ifnum\currentgrouplevel=\tikzphysics@mech@nodelevel\relax \pgfkeysalso{physics spring node}% \else \pgfkeysalso{physics spring path}% \fi }, physicsspring/.style={physics spring}, } %% Short public names; use the physics-prefixed forms if a document already %% defines generic block, pulley, or spring styles. \tikzset{ block/.style={physicsblock}, pulley/.style={physicspulley}, spring/.style={physics spring}, } %% ============================================================ %% TANGENT STRING OVER A PULLEY %% %% Usage: %% \physicsstringoverpulley[]{}{}{} %% %% The start and end arguments are coordinate names without parentheses; %% the pulley argument is the name of a physicspulley node. The two straight %% portions terminate at exact tangent points computed by TikZ's calc %% library. Between them, the path follows the pulley's true circular arc. %% %% The default surface-right route (solutions 2/1, clockwise wrap) matches a %% block approaching parallel to a horizontal or rising surface. The string %% passes over the pulley's upper rim before descending on its right. The %% three component keys remain available for other configurations. %% ============================================================ %% The native to path is shared by the compatibility command. TikZ supplies %% the resolved start/target coordinates, so ordinary coordinate expressions %% and node labels work without a new drawing language. \tikzset{ rope/.style={physics string}, physics over pulley/.style={to path={ let \p1=(tangent cs:node=#1,point={(\tikztostart)},solution=\tikzphysics@mech@stringstartsolution), \p2=(#1.center), \p3=(tangent cs:node=#1,point={(\tikztotarget)},solution=\tikzphysics@mech@stringendsolution), \n1={atan2(\y1-\y2,\x1-\x2)}, \n2={atan2(\y3-\y2,\x3-\x2)}, \n3={veclen(\x1-\x2,\y1-\y2)}, \n4={\tikzphysics@mech@stringdelta} in (\tikztostart) -- (\p1) arc[start angle=\n1,delta angle=\n4,radius=\n3] -- (\tikztotarget) \tikztonodes }}, physics over pulley/.value required, over pulley/.style={physics over pulley={#1}}, over pulley/.value required, } \newcommand{\physicsstringoverpulley}[4][]{% \begin{scope}[physics string] \tikzphysics@mech@tikzsettrim{#1}% \draw (#2) to[physics over pulley=#3] (#4); \end{scope}% } %% ============================================================ %% ANCHOR AND KEY REGISTRATION (for debug overlays) %% %% physicsblock and physicspulley are thin styles over rectangle and %% circle, so we register a curated list of anchors that are %% most useful in mechanics diagrams. %% ============================================================ \tikzphysics@registeranchors{physicsblock}{% center, north, south, east, west, north east, north west, south east, south west} \tikzphysics@registeranchors{physicspulley}{% center, north, south, east, west, north east, north west, south east, south west} \tikzphysics@registerdisplayname{physicsblock}{block} \tikzphysics@registerdisplayname{physicspulley}{pulley} \tikzphysics@registerkeys{physicsblock}{% minimum width, minimum height} \tikzphysics@registerkeydefaults{physicsblock}{% minimum width/1cm, minimum height/1cm} \tikzphysics@registerkeys{physicspulley}{% minimum size, pulley axle radius, pulley axle color} \tikzphysics@registerkeydefaults{physicspulley}{% minimum size/1cm, pulley axle radius/1.5pt, pulley axle color/black} \tikzset{ physics block width/.value required, physics block height/.value required, physics pulley diameter/.value required, physics pulley axle radius/.value required, physics pulley axle color/.value required, physics string start solution/.value required, physics string end solution/.value required, physics string route/.value required, physics string wrap/.value required, physics spring pre length/.value required, physics spring post length/.value required, physics spring amplitude/.value required, physics spring segment length/.value required, physics spring length/.value required, physics spring aspect/.value required, } %% ============================================================ %% MECHANICS PRIMITIVES: NODES, PATH STYLES, AND NAMED PICS %% ============================================================ \tikzphysics@declarehook{particle} \tikzphysics@declarehook{disk} \tikzphysics@declarehook{ring} \tikzphysics@declarehook{force} \tikzphysics@declarehook{velocity} \tikzphysics@declarehook{acceleration} \tikzphysics@declarehook{torque} \tikzphysics@declarehook{rod} \tikzphysics@declarehook{support} \tikzphysics@declarehook{pendulum} \tikzset{ physicsparticle/.style={shape=physicsparticle,draw=black,fill=black, inner sep=0pt,outer sep=0pt,minimum size=3mm, physics logical shape=physicsparticle, physics debug setup, every physics object,every particle}, physicsdisk/.style={shape=physicsdisk,draw=black,fill=white,inner sep=0pt,outer sep=0pt,minimum size=15mm, physics logical shape=physicsdisk, physics debug setup, every physics object,every disk}, physicsring/.style={shape=physicsring,draw=black,fill=none,inner sep=0pt,outer sep=0pt,minimum size=15mm, physics logical shape=physicsring, physics debug setup, every physics object,every ring}, particle/.style={physicsparticle}, disk/.style={physicsdisk}, ring/.style={physicsring}, physics force/.style={draw=black,>=latex,->,every physics connection,every force}, physics velocity/.style={draw=black,>=latex,->,every physics connection,every velocity}, physics acceleration/.style={draw=black,>=latex,->,every physics connection,every acceleration}, physics torque/.style={draw=black,>=latex,->,every physics connection,every torque}, physics rod/.style={draw=black,line cap=round, every physics connection,every rod}, force/.style={physics force}, velocity/.style={physics velocity}, acceleration/.style={physics acceleration}, torque/.style={physics torque}, rod/.style={physics rod}, support size/.initial=6mm, support size/.value required, physics support size/.style={support size={#1}}, pendulum length/.initial=2cm, pendulum length/.value required, pendulum angle/.initial=30, pendulum angle/.value required, physics pendulum length/.style={pendulum length={#1}}, physics pendulum angle/.style={pendulum angle={#1}}, pics/pin-support/.style={/tikz/.cd,every support,/tikz/pics/code={ \tikzphysics@resolve@length{\@tempdima}{\pgfkeysvalueof{/tikz/support size}}% \edef\tikzphysics@mech@supportsize{\the\@tempdima}% \coordinate (-pivot) at (0,0); \coordinate (-base) at (0,-\tikzphysics@mech@supportsize); \coordinate (-left) at (-.5*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize); \coordinate (-right) at (.5*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize); \draw (0,0) -- (-left) -- (-right) -- cycle; \draw (-.7*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize) -- (.7*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize); }}, pics/roller-support/.style={/tikz/.cd,every support,/tikz/pics/code={ \tikzphysics@resolve@length{\@tempdima}{\pgfkeysvalueof{/tikz/support size}}% \edef\tikzphysics@mech@supportsize{\the\@tempdima}% \coordinate (-pivot) at (0,0); \coordinate (-base) at (0,-\tikzphysics@mech@supportsize); \coordinate (-left) at (-.5*\tikzphysics@mech@supportsize,-.7*\tikzphysics@mech@supportsize); \coordinate (-right) at (.5*\tikzphysics@mech@supportsize,-.7*\tikzphysics@mech@supportsize); \draw (0,0) -- (-left) -- (-right) -- cycle; \draw (-.3*\tikzphysics@mech@supportsize,-.85*\tikzphysics@mech@supportsize) circle[radius=.15*\tikzphysics@mech@supportsize]; \draw (.3*\tikzphysics@mech@supportsize,-.85*\tikzphysics@mech@supportsize) circle[radius=.15*\tikzphysics@mech@supportsize]; \draw (-.7*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize) -- (.7*\tikzphysics@mech@supportsize,-\tikzphysics@mech@supportsize); }}, pics/pendulum/.style={/tikz/.cd,every pendulum,/tikz/pics/code={ \tikzphysics@resolve@length{\@tempdima}{\pgfkeysvalueof{/tikz/pendulum length}}% \edef\tikzphysics@mech@pendulumlength{\the\@tempdima}% \coordinate (-pivot) at (0,0); \node[physicsparticle] (-bob) at ({\pgfkeysvalueof{/tikz/pendulum angle}-90}:\tikzphysics@mech@pendulumlength) {}; \draw[physics string] (-pivot) -- (-bob); }}, pics/physics pin-support/.style={pin-support}, pics/physics roller-support/.style={roller-support}, pics/physics pendulum/.style={pendulum}, } \tikzphysics@registeranchors{physicsparticle}{center,north,south,east,west} \tikzphysics@registeranchors{physicsdisk}{center,north,south,east,west} \tikzphysics@registeranchors{physicsring}{center,north,south,east,west} \tikzphysics@registerdisplayname{physicsparticle}{particle} \tikzphysics@registerdisplayname{physicsdisk}{disk} \tikzphysics@registerdisplayname{physicsring}{ring} \tikzphysics@registerkeys{physicsparticle}{minimum size} \tikzphysics@registerkeys{physicsdisk}{minimum size} \tikzphysics@registerkeys{physicsring}{minimum size} \tikzphysics@registerkeydefaults{physicsparticle}{minimum size/3mm} \tikzphysics@registerkeydefaults{physicsdisk}{minimum size/15mm} \tikzphysics@registerkeydefaults{physicsring}{minimum size/15mm} \tikzphysics@registerdisplayname{physicsspring}{spring} \tikzphysics@registeranchors{physicsspring}{start,end,center,coil-start,coil-end,north,south,east,west} \tikzphysics@registerkeys{physicsspring}{minimum width,minimum height,spring length,pre length,post length,amplitude,segment length,aspect} \tikzphysics@registerkeydefaults{physicsspring}{minimum width/3cm (node),minimum height/0pt (node),pre length/5pt,post length/5pt,amplitude/4.5pt,segment length/4.5pt,aspect/0.5} \tikzphysics@registerdisplayname{physicsrope}{rope} \tikzphysics@registerkeydefaults{physicsrope}{line width/inherited,over pulley/required node name,string route/surface-right,string start solution/2,string end solution/1,string wrap/clockwise} \tikzphysics@registerdisplayname{physicsforce}{force} \tikzphysics@registerkeydefaults{physicsforce}{line width/inherited} \tikzphysics@registerdisplayname{physicsvelocity}{velocity} \tikzphysics@registerkeydefaults{physicsvelocity}{line width/inherited} \tikzphysics@registerdisplayname{physicsacceleration}{acceleration} \tikzphysics@registerkeydefaults{physicsacceleration}{line width/inherited} \tikzphysics@registerdisplayname{physicstorque}{torque} \tikzphysics@registerkeydefaults{physicstorque}{line width/inherited} \tikzphysics@registerdisplayname{physicsrod}{rod} \tikzphysics@registerkeydefaults{physicsrod}{line width/inherited} \tikzphysics@registerdisplayname{physicspinsupport}{pin-support} \tikzphysics@registerkeydefaults{physicspinsupport}{support size/6mm} \tikzphysics@registerdisplayname{physicsrollersupport}{roller-support} \tikzphysics@registerkeydefaults{physicsrollersupport}{support size/6mm} \tikzphysics@registerdisplayname{physicspendulum}{pendulum} \tikzphysics@registerkeydefaults{physicspendulum}{pendulum length/2cm,pendulum angle/30 degrees} \tikzset{ physics block width/.value required, physics block height/.value required, physics pulley diameter/.value required, physics spring pre length/.value required, physics spring post length/.value required, physics spring amplitude/.value required, physics spring segment length/.value required, physics pulley axle radius/.value required, physics pulley axle color/.value required, physics string start solution/.value required, physics string end solution/.value required, } %% BEGIN NATIVE COMPONENT EXTENSIONS %% beam \tikzset{ beam length/.initial=3cm, physics beam length/.style={beam length={#1}}, beam thickness/.initial=.25cm, physics beam thickness/.style={beam thickness={#1}}, } \pgfdeclareshape{physicsbeamnode}{ \savedmacro\tikzphysics@component@physicsbeamnodestate{% \tikzphysics@component@length\cw{beam length} \tikzphysics@component@length\ch{beam thickness} \tikzphysics@component@check{\cw>0 && \ch>0}{Beam dimensions must be positive} \addtosavedmacro\cw \addtosavedmacro\ch } \anchor{center}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{0}{0}} \anchor{north}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{0}{\ch/2}} \anchor{south}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{0}{-(\ch/2)}} \anchor{east}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{\cw/2}{0}} \anchor{west}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{-(\cw/2)}{0}} \anchor{north east}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{\cw/2}{\ch/2}} \anchor{north west}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{-(\cw/2)}{\ch/2}} \anchor{south east}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{\cw/2}{-(\ch/2)}} \anchor{south west}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{-(\cw/2)}{-(\ch/2)}} \anchor{start}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{-\cw/2}{0}} \anchor{end}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{\cw/2}{0}} \anchor{pivot}{\tikzphysics@component@physicsbeamnodestate\tikzphysics@component@point{-\cw/2}{0}} \anchor{text}{\pgf@x=-.5\wd\pgfnodeparttextbox\pgf@y=-.5\ht\pgfnodeparttextbox\advance\pgf@y by.5\dp\pgfnodeparttextbox} \tikzphysics@declarepercentanchors{bottom}{\tikzphysics@component@physicsbeamnodestate}{(-\cw/2+\tikzphysics@percent*\cw)*1cm}{(-\ch/2)*1cm} \tikzphysics@declarepercentanchors{right}{\tikzphysics@component@physicsbeamnodestate}{(\cw/2)*1cm}{(-\ch/2+\tikzphysics@percent*\ch)*1cm} \tikzphysics@declarepercentanchors{top}{\tikzphysics@component@physicsbeamnodestate}{(\cw/2-\tikzphysics@percent*\cw)*1cm}{(\ch/2)*1cm} \tikzphysics@declarepercentanchors{left}{\tikzphysics@component@physicsbeamnodestate}{(-\cw/2)*1cm}{(\ch/2-\tikzphysics@percent*\ch)*1cm} \tikzphysics@declarepercentanchors{axis}{\tikzphysics@component@physicsbeamnodestate}{(-\cw/2+\tikzphysics@percent*\cw)*1cm}{(0)*1cm} \anchorborder{\edef\cpx{\the\pgf@x}\edef\cpy{\the\pgf@y}\tikzphysics@component@physicsbeamnodestate\pgfpointborderrectangle{\pgfpoint{\cpx}{\cpy}}{\tikzphysics@component@point{\cw/2}{\ch/2}}} \backgroundpath{\tikzphysics@component@physicsbeamnodestate \tikzphysics@component@move{-\cw/2}{-\ch/2} \tikzphysics@component@line{\cw/2}{-\ch/2} \tikzphysics@component@line{\cw/2}{\ch/2} \tikzphysics@component@line{-\cw/2}{\ch/2} \pgfpathclose } } \tikzphysics@declarehook{beam} \tikzphysics@registerdisplayname{physicsbeamnode}{beam} \tikzphysics@registeranchors{physicsbeamnode}{center,north,south,east,west,start,end,pivot} \tikzphysics@registerfamilies{physicsbeamnode}{bottom,right,top,left,axis} \tikzphysics@registerkeys{physicsbeamnode}{beam length,beam thickness} \tikzphysics@registerkeydefaults{physicsbeamnode}{beam length/3cm,beam thickness/.25cm} \tikzset{physicsbeamnode/.style={shape=physicsbeamnode,physics logical shape=physicsbeamnode,anchor=center,draw=black,fill=none,inner sep=0pt,outer sep=0pt,physics debug setup,every physics object,every beam},beam/.style={physicsbeamnode},rod node/.style={physicsbeamnode}} %% damper \tikzset{ damper length/.initial=3cm, physics damper length/.style={damper length={#1}}, damper width/.initial=.7cm, physics damper width/.style={damper width={#1}}, damper position/.initial=.5, physics damper position/.style={damper position={#1}}, } \pgfdeclareshape{physicsdampernode}{ \savedmacro\tikzphysics@component@physicsdampernodestate{% \tikzphysics@component@length\cw{damper length} \tikzphysics@component@length\ch{damper width} \pgfmathsetmacro\cp{\pgfkeysvalueof{/tikz/damper position}} \tikzphysics@component@check{\cw>0 && \ch>0 && \cp>0 && \cp<1}{Damper dimensions must be positive and position between 0 and 1} \pgfmathsetmacro\cx{(-.2+.4*\cp)*\cw} \addtosavedmacro\cw \addtosavedmacro\ch \addtosavedmacro\cp \addtosavedmacro\cx } \anchor{center}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{0}{0}} \anchor{north}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{0}{\ch/2}} \anchor{south}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{0}{-(\ch/2)}} \anchor{east}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{\cw/2}{0}} \anchor{west}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{-(\cw/2)}{0}} \anchor{north east}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{\cw/2}{\ch/2}} \anchor{north west}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{-(\cw/2)}{\ch/2}} \anchor{south east}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{\cw/2}{-(\ch/2)}} \anchor{south west}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{-(\cw/2)}{-(\ch/2)}} \anchor{start}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{-\cw/2}{0}} \anchor{end}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{\cw/2}{0}} \anchor{piston}{\tikzphysics@component@physicsdampernodestate\tikzphysics@component@point{\cx}{0}} \anchor{text}{\pgf@x=-.5\wd\pgfnodeparttextbox\pgf@y=-.5\ht\pgfnodeparttextbox\advance\pgf@y by.5\dp\pgfnodeparttextbox} \tikzphysics@declarepercentanchors{axis}{\tikzphysics@component@physicsdampernodestate}{((-.5+\tikzphysics@percent)*\cw)*1cm}{(0)*1cm} \tikzphysics@declarepercentanchors{piston}{\tikzphysics@component@physicsdampernodestate}{(\cx)*1cm}{((-.4+.8*\tikzphysics@percent)*\ch)*1cm} \tikzphysics@declarepercentanchors{top}{\tikzphysics@component@physicsdampernodestate}{((.2-.4*\tikzphysics@percent)*\cw)*1cm}{(.5*\ch)*1cm} \tikzphysics@declarepercentanchors{bottom}{\tikzphysics@component@physicsdampernodestate}{((-.2+.4*\tikzphysics@percent)*\cw)*1cm}{(-.5*\ch)*1cm} \anchorborder{\edef\cpx{\the\pgf@x}\edef\cpy{\the\pgf@y}\tikzphysics@component@physicsdampernodestate\pgfpointborderrectangle{\pgfpoint{\cpx}{\cpy}}{\tikzphysics@component@point{\cw/2}{\ch/2}}} \backgroundpath{\tikzphysics@component@physicsdampernodestate \tikzphysics@component@move{-\cw/2}{0} \tikzphysics@component@line{-.2*\cw}{0} \tikzphysics@component@move{.2*\cw}{\ch/2} \tikzphysics@component@line{-.2*\cw}{\ch/2} \tikzphysics@component@line{-.2*\cw}{-\ch/2} \tikzphysics@component@line{.2*\cw}{-\ch/2} \tikzphysics@component@move{\cx}{-.4*\ch} \tikzphysics@component@line{\cx}{.4*\ch} \tikzphysics@component@move{\cx}{0} \tikzphysics@component@line{\cw/2}{0} } } \tikzphysics@declarehook{damper} \tikzphysics@registerdisplayname{physicsdampernode}{damper} \tikzphysics@registeranchors{physicsdampernode}{center,north,south,east,west,start,end,piston} \tikzphysics@registerfamilies{physicsdampernode}{axis,piston,top,bottom} \tikzphysics@registerkeys{physicsdampernode}{damper length,damper width,damper position} \tikzphysics@registerkeydefaults{physicsdampernode}{damper length/3cm,damper width/.7cm,damper position/.5} \tikzset{physicsdampernode/.style={shape=physicsdampernode,physics logical shape=physicsdampernode,anchor=center,draw=black,fill=none,inner sep=0pt,outer sep=0pt,physics debug setup,every physics object,every damper},damper/.style={physicsdampernode}} %% compound pulley \tikzset{ compound pulley radius/.initial=1cm, physics compound pulley radius/.style={compound pulley radius={#1}}, compound pulley inner radius/.initial=.55cm, physics compound pulley inner radius/.style={compound pulley inner radius={#1}}, } \pgfdeclareshape{physicscompoundpulleynode}{ \savedmacro\tikzphysics@component@physicscompoundpulleynodestate{% \tikzphysics@component@length\cr{compound pulley radius} \tikzphysics@component@length\cir{compound pulley inner radius} \tikzphysics@component@check{\cr>0 && \cir>0 && \cir<\cr}{Pulley radii must satisfy 0 < inner < outer} \addtosavedmacro\cr \addtosavedmacro\cir } \anchor{center}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{0}{0}} \anchor{north}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{0}{\cr}} \anchor{south}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{0}{-(\cr)}} \anchor{east}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{\cr}{0}} \anchor{west}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{-(\cr)}{0}} \anchor{north east}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{\cr}{\cr}} \anchor{north west}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{-(\cr)}{\cr}} \anchor{south east}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{\cr}{-(\cr)}} \anchor{south west}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{-(\cr)}{-(\cr)}} \anchor{axle}{\tikzphysics@component@physicscompoundpulleynodestate\tikzphysics@component@point{0}{0}} \anchor{text}{\pgf@x=-.5\wd\pgfnodeparttextbox\pgf@y=-.5\ht\pgfnodeparttextbox\advance\pgf@y by.5\dp\pgfnodeparttextbox} \tikzphysics@declarepercentanchors{rim}{\tikzphysics@component@physicscompoundpulleynodestate}{(\cr*cos(360*\tikzphysics@percent))*1cm}{(\cr*sin(360*\tikzphysics@percent))*1cm} \tikzphysics@declarepercentanchors{inner-rim}{\tikzphysics@component@physicscompoundpulleynodestate}{(\cir*cos(360*\tikzphysics@percent))*1cm}{(\cir*sin(360*\tikzphysics@percent))*1cm} \anchorborder{\edef\cpx{\the\pgf@x}\edef\cpy{\the\pgf@y}\tikzphysics@component@physicscompoundpulleynodestate\pgfpointborderrectangle{\pgfpoint{\cpx}{\cpy}}{\tikzphysics@component@point{\cr}{\cr}}} \backgroundpath{\tikzphysics@component@physicscompoundpulleynodestate \tikzphysics@component@ellipse{0}{0}{\cr}{\cr} \tikzphysics@component@ellipse{0}{0}{\cir}{\cir} \tikzphysics@component@ellipse{0}{0}{.04}{.04} } } \tikzphysics@declarehook{compound pulley} \tikzphysics@registerdisplayname{physicscompoundpulleynode}{compound pulley} \tikzphysics@registeranchors{physicscompoundpulleynode}{center,north,south,east,west,axle} \tikzphysics@registerfamilies{physicscompoundpulleynode}{rim,inner-rim} \tikzphysics@registerkeys{physicscompoundpulleynode}{compound pulley radius,compound pulley inner radius} \tikzphysics@registerkeydefaults{physicscompoundpulleynode}{compound pulley radius/1cm,compound pulley inner radius/.55cm} \tikzset{physicscompoundpulleynode/.style={shape=physicscompoundpulleynode,physics logical shape=physicscompoundpulleynode,anchor=center,draw=black,fill=none,inner sep=0pt,outer sep=0pt,physics debug setup,every physics object,every compound pulley},compound pulley/.style={physicscompoundpulleynode}} %% physical pendulum \tikzset{ physical pendulum length/.initial=3cm, physics physical pendulum length/.style={physical pendulum length={#1}}, physical pendulum width/.initial=.45cm, physics physical pendulum width/.style={physical pendulum width={#1}}, physical pendulum pivot/.initial=.1, physics physical pendulum pivot/.style={physical pendulum pivot={#1}}, } \pgfdeclareshape{physicsphysicalpendulumnode}{ \savedmacro\tikzphysics@component@physicsphysicalpendulumnodestate{% \tikzphysics@component@length\ch{physical pendulum length} \tikzphysics@component@length\cw{physical pendulum width} \pgfmathsetmacro\cp{\pgfkeysvalueof{/tikz/physical pendulum pivot}} \tikzphysics@component@check{\ch>0 && \cw>0 && \cp>=0 && \cp<=1}{Pendulum dimensions must be positive and pivot between 0 and 1} \addtosavedmacro\ch \addtosavedmacro\cw \addtosavedmacro\cp } \anchor{center}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{0}} \anchor{north}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{\ch/2}} \anchor{south}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{-(\ch/2)}} \anchor{east}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{\cw/2}{0}} \anchor{west}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{-(\cw/2)}{0}} \anchor{north east}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{\cw/2}{\ch/2}} \anchor{north west}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{-(\cw/2)}{\ch/2}} \anchor{south east}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{\cw/2}{-(\ch/2)}} \anchor{south west}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{-(\cw/2)}{-(\ch/2)}} \anchor{pivot}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{(.5-\cp)*\ch}} \anchor{mass-center}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{0}} \anchor{tip}{\tikzphysics@component@physicsphysicalpendulumnodestate\tikzphysics@component@point{0}{-\ch/2}} \anchor{text}{\pgf@x=-.5\wd\pgfnodeparttextbox\pgf@y=-.5\ht\pgfnodeparttextbox\advance\pgf@y by.5\dp\pgfnodeparttextbox} \tikzphysics@declarepercentanchors{bottom}{\tikzphysics@component@physicsphysicalpendulumnodestate}{(-\cw/2+\tikzphysics@percent*\cw)*1cm}{(-\ch/2)*1cm} \tikzphysics@declarepercentanchors{right}{\tikzphysics@component@physicsphysicalpendulumnodestate}{(\cw/2)*1cm}{(-\ch/2+\tikzphysics@percent*\ch)*1cm} \tikzphysics@declarepercentanchors{top}{\tikzphysics@component@physicsphysicalpendulumnodestate}{(\cw/2-\tikzphysics@percent*\cw)*1cm}{(\ch/2)*1cm} \tikzphysics@declarepercentanchors{left}{\tikzphysics@component@physicsphysicalpendulumnodestate}{(-\cw/2)*1cm}{(\ch/2-\tikzphysics@percent*\ch)*1cm} \tikzphysics@declarepercentanchors{axis}{\tikzphysics@component@physicsphysicalpendulumnodestate}{(0)*1cm}{((.5-\tikzphysics@percent)*\ch)*1cm} \anchorborder{\edef\cpx{\the\pgf@x}\edef\cpy{\the\pgf@y}\tikzphysics@component@physicsphysicalpendulumnodestate\pgfpointborderrectangle{\pgfpoint{\cpx}{\cpy}}{\tikzphysics@component@point{\cw/2}{\ch/2}}} \backgroundpath{\tikzphysics@component@physicsphysicalpendulumnodestate \tikzphysics@component@move{-\cw/2}{-\ch/2} \tikzphysics@component@line{\cw/2}{-\ch/2} \tikzphysics@component@line{\cw/2}{\ch/2} \tikzphysics@component@line{-\cw/2}{\ch/2} \pgfpathclose \tikzphysics@component@ellipse{0}{(.5-\cp)*\ch}{.04}{.04} } } \tikzphysics@declarehook{physical pendulum} \tikzphysics@registerdisplayname{physicsphysicalpendulumnode}{physical pendulum} \tikzphysics@registeranchors{physicsphysicalpendulumnode}{center,north,south,east,west,pivot,mass-center,tip} \tikzphysics@registerfamilies{physicsphysicalpendulumnode}{bottom,right,top,left,axis} \tikzphysics@registerkeys{physicsphysicalpendulumnode}{physical pendulum length,physical pendulum width,physical pendulum pivot} \tikzphysics@registerkeydefaults{physicsphysicalpendulumnode}{physical pendulum length/3cm,physical pendulum width/.45cm,physical pendulum pivot/.1} \tikzset{physicsphysicalpendulumnode/.style={shape=physicsphysicalpendulumnode,physics logical shape=physicsphysicalpendulumnode,anchor=center,draw=black,fill=none,inner sep=0pt,outer sep=0pt,physics debug setup,every physics object,every physical pendulum},physical pendulum/.style={physicsphysicalpendulumnode}} %% END NATIVE COMPONENT EXTENSIONS \makeatother \endinput %% %% End of file `tikzlibrarytikzphysics.mechanics.code.tex'. .