For the following schematic of an electromechanical system, I would like to:
1- reduce and optimize the code as much as possible for the following:
drawing a line from its center by specifying its length and rotation (e.g. the line below
N_1and aboveN_2)find a more compact way to position and draw the pattern-filled rectangle instead of defining coordinates
find a more optimized way to place the twisted arrows halfway between the vertical lines and the motor and cylinder
2- center the current arrow i_a between the resistance and the inductance,
3- understand the reason behind the existence of the gap between (M1.east) and the horizontal line next to it.
4- know why do I need to write down the unit mm for xshift and yshift to make it work as expected.
5- move E_a with its positive and negative signs to the right to be horizontally aligned with the circuit terminals. i.e. both signs and terminals and E_a should be horizontally aligned.
Further recommendations and code reductions are highly appreciated.
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc, positioning, patterns, decorations, decorations.markings}
\newcommand{\mymotor}[2] % #1 = name , #2 = rotation angle
{\draw[thick,rotate=#2] (#1) circle (10pt)
node[]{$\mathsf M$}
++(-12pt,3pt)--++(0,-6pt) --++(2.5pt,0) ++(-2.8pt,6pt)-- ++(2.5pt,0pt);
\draw[thick,rotate=#2] (#1) ++(12pt,3pt)--++(0,-6pt) --++(-2.5pt,0) ++(2.8pt,6pt)-- ++(-2.5pt,0pt);
}
\begin{document}
\begin{tikzpicture}[damper/.style={thick,
decorate,
decoration={markings,
mark connection node=dmp,
mark=at position 0.5 with
{
\node (dmp) [thick, inner sep=0pt,
transform shape,
rotate=-90,
minimum width=15pt,
minimum height=10pt, draw=none] {};
\draw [thick] ($(dmp.north east)+(4pt,0)$) --
(dmp.south east) -- (dmp.south west) --
($(dmp.north west)+(4pt,0)$);
\draw [thick] ($(dmp.north)+(0,-8pt)$) --
($(dmp.north)+(0,8pt)$);
}}},]
\draw (0,2) to[R=$R_a$,o-, f=$i_a$] ++(2,0) to[L,cute inductor, l=$L_a$,] ++(2,0) to[sV, color=white, name=M1] ++(0,-2) to[short,-o] ++(-4,0);
\mymotor{M1}{90}
\draw (0,2) to [open, v=$E_a$] (0,0);
\draw[thick] (M1.north) -- ++(1.5,0) -- +(0,0.5) node [anchor=south] {$N_1$} -- +(0,-0.5) coordinate (N1);
\draw[->] ([xshift=7.5mm,yshift=-2mm]M1.north) to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {$T_m, \theta_m$};
\draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} ++(0,0.75) -- ++(1,0) node [cylinder, black, shape border rotate=180, draw,
minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = gray!20,anchor=west] (c) {Load Inertia};
\draw[->] ([xshift=-5mm,yshift=-2mm]c.west) to [out=-120,in=120, looseness=4] ++(0,0.4) node [above=1mm] {$\theta_L$};
\draw [damper] (c.east) -- node[above=3mm] {$d_1$} ++(0:2) ++(0,-1) coordinate (pttrn);
\draw[preaction={fill=gray!10},pattern=north east lines,pattern=bricks] (pttrn) rectangle ++(0.5,2);
\end{tikzpicture}
\end{document}


\draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} coordinate[midway] (aux) (aux) -- ++ (1,0) node [anchor=top,right,cylinder, black, shape border rotate=180, draw, minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = gray!20, path picture={\draw($(c.before top)!0.5!(c.after top)$) -- (c.top);}] (c) {Load Inertia};. – Nov 01 '19 at 18:09cylinder end fillis rather "violent", so it always goes in front, which prevents simpler solutions. If you want simpler solutions, you may need something like this definition of a filled cylinder, which also allows more fancy shadings. Similar ordering problems appear here. – Nov 01 '19 at 18:12coordinate[midway] (aux) (aux)means to be used instead of++(0,0.75)? – Diaa Nov 01 '19 at 18:16