2

I am used to drawing basic mechanical components (spring, damper) using the tikz and circuitikz this way:

\coordinate (A) at (0,0);
\coordinate (B) at (3,0);

[..]

\draw (A) to[spring] (B);
\draw (C) to[damper] (D);

Now I am in a configuration where I want to draw the same component but on an arc, not a line:

\draw (0,0) + (30:3cm) arc (30:80:3cm);

I've tried without success using to[spring] positioned before and after the arc command (see figure) and also:

\draw[damper] (0,0) + (30:3cm) arc (30:80:3cm);

The last command just draw this arc, without the mechanical component. Failed attempt to draw spring on arc

I've seen here, here and here that it is possible with coils using decorations, but I wish to keep the same spring representation, and the solution for the dampers seems quite complicated, is there a simpler way to achieve that ?

EDIT: working example

\usepackage{tikz}
\usepackage{circuitikz}
%
\begin{figure} [h]
\begin{tikzpicture}         
    \coordinate (elbow) at (0,0);
    \coordinate (shoulder) at ($(elbow) + (0, 3.25)$);
    %
    \draw[rounded corners=1ex, rotate around={-60:(elbow)}] (0.175, 0) rectangle (-0.175, 3.25); 
    \draw[rounded corners=0.5ex] ($(elbow) + (0.175, 0)$) rectangle ($(shoulder) + (-0.175, 0)$) node (wrist){};
\node[circle, draw, minimum size=1.25cm, fill=white] (joint) at (elbow) {};
\node[circle, draw, minimum size=0.15cm, inner sep=0, fill=white] (jointBis) at (elbow) {};
%
\draw[white, line width=1.5pt] (0,0) + (15:0.625cm) arc (15:45:0.625cm);
%
\draw (0,0) + (33:3cm) arc (33:87:3cm); %to[spring]
\draw[damper] (0,0) + (35:2cm) arc (35:85:2cm);
%
\draw[gray, dashed] (0.625,0) -- (3,0);
\draw[-{Latex[length=2mm]}] (0,0) + (0:2cm) arc (0:25:2cm) node[midway, right]{$\theta$};

\end{tikzpicture} \end{figure}

fo fu
  • 23
  • Hello and welcome to TeX-SE. Please, add a complete Minimal Working Example to let users copy/paste and look for improvements to help you out. – SebGlav Jul 28 '21 at 13:26
  • You can position a spring in the middle of the arc, but the element will not be bent; circuitikz elements are rigid. The only way would be to use a non-linear coordinate transformation, but that's quite complex to do. – Rmano Jul 28 '21 at 13:39
  • @Rmano it could be a back up solution (the element that do not bent), but I don't even manage to achieve this. – fo fu Jul 28 '21 at 14:02

1 Answers1

3

Positioning a node along an arc is not so difficult --- the problem is that circuitikz elements can only be automatically positioned along a straight line, with the to statement.

So to position an element on an arc we must rely on using the "naked" node and position it. For example

\path (0,0) +(30:3cm) arc (30:80:3cm) 
   node[draw, springshape, pos=0.5, sloped](S){};

will give:

enter image description here

Now, the big problem is to connect the element and remove the line underneath. I used a bit of trigonometry here (and for sure it could be automated in some macro...); for example --- I let in red the help lines that guided me in the construction:

\begin{tikzpicture}[]
    % these are to show the construction
    \draw[red,thin]  (0,0) + (30:3cm) coordinate(B) 
         arc (30:80:3cm) coordinate(E);
    \node[red] at (B){B}; \node[red] at (E){E};
    \path (B) arc (30:80:3cm) node[draw, springshape, pos=0.5, sloped](S){};
    % from B the circle starts at 120 degree, let's se e the landing angle and use a spline
    \draw let \p1=(S.right), \n1={-90+acos(\x1/3cm)} 
          in (B) to[out=120,in=\n1] (S.right);
    % from E it starts at -10, let's caluclate the landing angle
    \draw let \p1=(S.left), \n1={90+acos(\x1/3cm)} 
          in (E) to[out=-10,in=\n1] (S.left);
\end{tikzpicture}

enter image description here

So the arcs are not really arcs, but the final result (removing the red parts) seems acceptable to me:

\path (0,0) +(30:3cm) coordinate(B)
        arc (30:80:3cm) coordinate(E)
        node[draw, springshape, pos=0.5, sloped](S){};
    % from B the circle starts at 120 degree, let's se e the landing angle and use a spline
    \draw let \p1=(S.right), \n1={-90+acos(\x1/3cm)}
          in (B) to[out=120,in=\n1] (S.right);
    % from E it starts at -10, let's caluclate the landing angle
    \draw let \p1=(S.left), \n1={90+acos(\x1/3cm)}
          in (E) to[out=-10,in=\n1] (S.left);

enter image description here

with a damper, use the nodename for the element you find in the manual:

enter image description here

to obtain:

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125
  • Would 'dampershape' also work ? – fo fu Jul 28 '21 at 14:53
  • Yes --- and every component in circuitikz. The "nodename" is normally the path name with a shape appended --- it's marked in the manual anyway for each element. – Rmano Jul 28 '21 at 14:58
  • 1
    Notice that the code is supersimplyfied and works only for arcs centered in 0 and with a 3cm diameter... I've been too lazy to generalize it. The trick is getting the orientation of the arc near the points where the component left and right anchors are. – Rmano Jul 29 '21 at 08:07