Making a Quadcopter Axis System in Tikz

tikz-pgf

I am facing difficulties in making this type of quadcopter system in Tikz.
enter image description here

I want to generate this type of picture, since i am beginner, i don't know how to draw it in tikz. I am starting with this code Aircraft Shapes. Kindly help me out here.

Thanks in advance!

Best Answer

Welcome to TeX.SE!!!

Here is my version of the quadcopter. I use a \pic for the cylinders (motors) which is useful to place a lot of coordinates. Everything else is done with \foreach statements, except for the booms.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,perspective}

\tikzset
{%
  pics/cylinder/.style n args={3}{% #1 = radius, #2 = height, #3 = angle
    code={%
      \draw[pic actions] (135:#1) arc (135:315:#1) --++ (0,0,#2) arc (315:135:#1) -- cycle;
      \draw[pic actions] (0,0,#2) circle (#1);
      \foreach\z in {0,1}
      {
        \begin{scope}[canvas is xy plane at z=\z*\h]
          \coordinate (-cen\z) at       (0,0);
          \coordinate (-ESE\z) at    (-#3:#1);
          \coordinate (-ENE\z) at     (#3:#1);
          \coordinate (-NNE\z) at  (90-#3:#1);
          \coordinate (-NNW\z) at  (90+#3:#1);
          \coordinate (-WNW\z) at (180-#3:#1);
          \coordinate (-WSW\z) at (180+#3:#1);
          \coordinate (-SSW\z) at (270-#3:#1);
          \coordinate (-SSE\z) at (270+#3:#1);
        \end{scope}
      }
    }},
}

\begin{document}
\begin{tikzpicture}[isometric view,line cap=round,line join=round]
% dimensions
\def\l{4}    % boom length
\def\R{1}    % body radius
\def\r{0.15} % motor radius
\def\h{0.3}  % boom and body height
\pgfmathsetmacro\A{asin(\r*sin(45)/\R)}
% paths to situate the coordinates
\foreach[count=\i]\j in {E,N,W,S}
  \pic[draw=none] (\j) at (90*\i-90:\l) {cylinder={\r}{\h}{45}};
\pic[draw=none] (O) {cylinder={\R}{\h}{\A}};
% rotations
\foreach[count=\i]\j in {-1,1,-1,1}
{
  \draw[dashed] (90*\i:\l) + (0,0,-\h) --++ (0,0,-7*\h);
  \begin{scope}[shift={(180-90*\i:\l)},canvas is xy plane at z=-4*\h,x=\j cm]
    \draw[red,-latex] (.7,0) arc (0:270:0.7) node [right] {$M_\i$};
  \end{scope}
}
% z-axis
\draw[-latex] (0,0,\h) --++ (0,0,-2)  node [below] {$z$};
% motors
\foreach\i in {E,N,W,S}
  \pic[fill=white,shift={(0,0,-\h)}] at (\i-cen0) {cylinder={\r}{2*\h}{45}};
% boom, east
\draw[fill=white] (E-SSW1) arc (225:135:\r) -- (O-ENE1) arc (\A:-\A:\R) -- cycle;
\draw[fill=white] (E-SSW1) -- (E-SSW0) -- (O-ESE0) -- (O-ESE1) -- cycle;
% boom, north
\draw[fill=white] (N-SSE1) arc (315:225:\r) -- (O-NNW1) arc (90+\A:90-\A:\R) -- cycle;
\draw[fill=white] (N-SSW1) -- (N-SSW0) -- (O-NNW0) -- (O-NNW1) -- cycle;
% frame
\pic[fill=white] {cylinder={\R}{\h}{\A}};
% boom, west
\draw[fill=white] (W-NNE1) arc (45:-45:\r) -- (O-WSW1) arc (180+\A:180-\A:\R) -- cycle;
\draw[fill=white] (W-SSE1) -- (W-SSE0) -- (O-WSW0) -- (O-WSW1) -- cycle;
% boom, south
\draw[fill=white] (S-NNW1) arc (135:45:\r) -- (O-SSE1) arc (270+\A:270-\A:\R) -- cycle;
\draw[fill=white] (S-NNW1) -- (S-NNW0) -- (O-SSW0) -- (O-SSW1) -- cycle;
% propellers
\foreach[count=\i]\j in {140,10,60,15}
{
  \begin{scope}[shift={(90*\i-90:\l)},rotate around z=\j,canvas is xy plane at z=\h]
    \draw[fill=gray!30] (0,0) sin  (0.5,0.1) cos  (1,0) sin  (0.5,-0.1) cos (0,0)
                              sin (-0.5,0.1) cos (-1,0) sin (-0.5,-0.1) cos (0,0);
    \fill (0,0) circle (0.05);
  \end{scope}
}
% forces
\foreach\i in {1,2,3,4}
  \draw[ultra thick,blue,-latex] (90*\i:\l) + (0,0,2*\h) --++ (0,0,6*\h) node [right] {$F_\i$};
% axes
\draw[-latex] (0,0,\h) --++ (1.5,0,0) node [yshift=3mm] {\strut$y$};
\draw[-latex] (0,0,\h) --++ (0,1.5,0) node [yshift=3mm] {\strut$x$};
\draw[dashed] (O-cen1) --++ (-3,-4,0) coordinate (O');
\draw[-latex] (O') --++ (0,1, 0) node [left]  {$N$};
\draw[-latex] (O') --++ (1,0, 0) node [right] {$E$};
\draw[-latex] (O') --++ (0,0,-1) node [below] {$D$};
\end{tikzpicture}
\end{document}

enter image description here

Related Question