1

i need some help to complete a 3d kinematic diagram (see attached image)

enter image description here I know how to draw almost everything but I would like to find a clean solution to draw the contact planes on each side of the 3 balls. I drew the two plans for the top ball (easy to calculate!), I can calculate the others, but is there a Tikz or pgf solution that will automate the calculation.

\documentclass[10pt,a4paper]{standalone}

\usepackage{tikz} \usetikzlibrary{3d,calc,positioning}

\begin{document}

\begin{tikzpicture} [z={(-0.866cm,-0.5cm)}, x={(0.866cm,-0.5cm)}, y={(0cm,1cm)}, scale=2] \draw[->,red] (0,0,0) -- (3,0,0) node[above]{x}; \draw[->,blue] (0,0,0) -- (0,3,0) node[left]{y};
\draw[->,black] (0,0,0) -- (0,0,3) node[above]{z};

\foreach \aa/\nn in {90/1,-30/2,-150/3}{ \draw (0,0,0) coordinate(O) circle (1.5); \node[circle,draw,fill=blue,minimum size=1.4cm] (Ca\nn) at ({1.5cos(\aa)},{1.5sin(\aa)},0){}; \draw[dashed] (Ca\nn) -- (O); \draw[thick,red] (Ca\nn) --++(0,0,1.8) coordinate(B\nn)-- ($(O)+(0,0,1.8)$)-- ++(0,0,1); \draw[thick,green] (Ca\nn) --++(0,0,-1.8) coordinate(B\nn)-- ($(O)+(0,0,-1.8)$)-- ++(0,0,-1); }

\begin{scope}[shift={(Ca1)}] \path[thick,red] (0,0.5,-0.5) -- ++({0.5cos(15)},0,{-0.5sin(15)})coordinate(a1)--++({-cos(15)},0,{+sin(15)})coordinate(a2); \path[thick,red] (0,-0.5,-0.5) -- ++({0.5cos(15)},0,{-0.5sin(15)})coordinate(a3)--++({-cos(15)},0,{+sin(15)})coordinate(a4); \draw[fill=green,opacity=0.5] (a1) -- (a3) -- (a4) -- (a2) -- cycle;

\node[circle,draw,fill=blue,minimum size=1.4cm] at (Ca1){};

\path[thick,red] (0,0.5,0.5) -- ++({0.5cos(15)},0,{-0.5sin(15)})coordinate(a1)--++({-cos(15)},0,{+sin(15)})coordinate(a2); \path[thick,red] (0,-0.5,0.5) -- ++({0.5cos(15)},0,{-0.5sin(15)})coordinate(a3)--++({-cos(15)},0,{+sin(15)})coordinate(a4); \draw[fill=red,opacity=0.5] (a1) -- (a3) -- (a4) -- (a2) -- cycle;

\draw[->] (Ca1) --++ ({1.5sin(15)},0,{1.5cos(15)})node[right]{na1}; \end{scope}

% % \begin{scope}[canvas is xy plane at z=0] % % % % \draw[blue,shift={(1.5,0)}] (0,0) -- (1,0)--(1,1)--(0,1)--cycle; % \draw[blue,shift={(3,0)}] (0,0) -- (1,0)--(1,1)--(0,1)--cycle; % \end{scope}

\end{tikzpicture}

\end{document}

enter image description here

enter image description here

rpapa
  • 12,350
  • Something looks wrong - it is like there is much more space between the plates than the ball. Is the plates not to touch the ball!? – hpekristiansen Feb 18 '22 at 16:13

2 Answers2

2

I did not want to spend time understanding your calculations, so I started over - hope your can use it:

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{3d}
\tikzset{viewport/.style 2 args={
    z={({cos(-#1)*1cm},{sin(-#1)*sin(#2)*1cm})},
    x={({-sin(-#1)*1cm},{cos(-#1)*sin(#2)*1cm})},
    y={(0,{cos(#2)*1cm})}
}}
\begin{document}
\begin{tikzpicture}[viewport={135}{40}] %[z={(-0.866cm,-0.5cm)}, x={(0.866cm,-0.5cm)}, y={(0cm,1cm)}]
\draw[->, red] (0,0,0) -- (4,0,0) node[above]{x};
\draw[->, blue] (0,0,0) -- (0,4,0) node[left]{y};
\draw[->, black] (0,0,0) -- (0,0,4) node[above]{z};
\foreach \angle in {90,210,330}
  \draw[green, thick] ([shift={(0,0,-0.5)}] \angle:2) -- ([shift={(0,0,-2.5)}] \angle:2) -- (0,0,-2.5) -- (0,0,-3.5);
\begin{scope}[canvas is xy plane at z=-0.5]
\foreach \angle in {90,210,330}
  \draw[fill=green, opacity=0.5, shift={(\angle:2)}] (-0.6,-0.6) rectangle (0.6,0.6);
\end{scope}
\begin{scope}[canvas is xy plane at z=0]
\draw (0,0) circle[radius=2];
\foreach \angle in {90,210,330}{
  \draw[dashed]  (0,0) -- (\angle:2);
  \node[circle, draw, fill=blue, minimum size=1cm] at (\angle:2) {};
}
\end{scope}
\begin{scope}[canvas is xy plane at z=0.5]
\foreach \angle in {90,210,330}
  \draw[fill=red, opacity=0.5, shift={(\angle:2)}] (-0.6,-0.6) rectangle (0.6,0.6);
\end{scope}
\foreach \angle in {90,210,330}
  \draw[red, thick] ([shift={(0,0,0.5)}] \angle:2) -- ([shift={(0,0,2.5)}] \angle:2) -- (0,0,2.5) -- (0,0,3.5);
\end{tikzpicture}
\end{document}

viewport={135}{40}

3D diagram with balls and plates

viewport={155}{20}

3D diagram with balls and plates

viewport is adapted from here: https://tex.stackexchange.com/a/199715/8650 where it is used in another context for another reason. You do not need it, and can just set x, y and z unit vectors explicitly if you wish.

Edit:

Here I use tikz-3dplot to rotate the planes 15 deg. I had to use the std. coordinate system with z-axis pointing up, but the labels can be changed:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords]
\newcommand{\rw}{0.6}
\draw[->, red] (0,0,0) -- (4,0,0) node[above]{x};
\draw[->, blue] (0,0,0) -- (0,4,0) node[above]{y};
\draw[->, black] (0,0,0) -- (0,0,4) node[above]{z};
\begin{scope}[canvas is yz plane at x=0]
\draw (0,0) circle[radius=2];
\end{scope}
\foreach \point in {(0,{2*cos(90)},{2*sin(90)}) , (0,{2*cos(210)},{2*sin(210)}) , (0,{2*cos(330)},{2*sin(330)}) }{
\draw[dashed]  (0,0,0) -- \point;
\tdplotsetrotatedcoordsorigin{\point}
\tdplotsetrotatedcoords{0}{0}{15}
\draw[fill=green, opacity=0.5, tdplot_rotated_coords] (-0.5,-\rw,-\rw) -- (-0.5,-\rw,\rw) -- (-0.5,\rw,\rw) -- (-0.5,\rw,-\rw) -- cycle; 
\node[circle, draw, fill=blue, minimum size=1cm] at \point {};    
\draw[->, shift={\point}] (0.5,0,0) -- (2,0,0); 
\draw[->, tdplot_rotated_coords] (0.5,0,0) -- (2,0,0);
\draw[fill=red, opacity=0.5, tdplot_rotated_coords] (0.5,-\rw,-\rw) -- (0.5,-\rw,\rw) -- (0.5,\rw,\rw) -- (0.5,\rw,-\rw) -- cycle; 
}
\end{tikzpicture}
\end{document}

Diagram with balls and rotated planes

Seen from top \tdplotsetmaincoords{0}{0}

Balls and planes seen from top

  • merci but the planes are not perpendicular to z, but inclined by 15° around the axis passing through the center. – rpapa Feb 18 '22 at 16:37
  • Ups - did not see that. -see edit. – hpekristiansen Feb 18 '22 at 18:14
  • Correct the order in which the elements are drawn - the ring should not be behind everything like in the code or in front like my picture. Draw green planes first, then ring and lastly red planes. – hpekristiansen Feb 18 '22 at 19:23
  • Thanks, but that's not quite it yet, if the foreground revolves around y (actually ua), the others revolve around ub and uc respectively. That's what I have a problem with, this double rotation. – rpapa Feb 19 '22 at 09:34
  • Do one ball at a time and change \tdplotsetrotatedcoords{0}{0}{15} to \tdplotsetrotatedcoords{0}{15}{0} or \tdplotsetrotatedcoords{15}{0}{0}. I can not do it as you do not supply a picture of desired result - or the picture is so bad I do not understand it. – hpekristiansen Feb 19 '22 at 13:25
  • I added a 3d cad model to better explain the orientation of the planes – rpapa Feb 19 '22 at 18:09
2

I answer my question!

I relied on a previous question (how to draw pitch, yaw and roll with 3d plot) to define the different angles.

% !TeX encoding = utf8
\documentclass[10pt,a4paper]{article}

\usepackage{tikz} \usetikzlibrary{3d,calc,positioning} \usepackage{tikz-3dplot}

\begin{document}

\makeatletter

%along y axis \define@key{y sphericalkeys}{radius}{\def\myradius{#1}} \define@key{y sphericalkeys}{theta}{\def\mytheta{#1}} \define@key{y sphericalkeys}{phi}{\def\myphi{#1}} \tikzdeclarecoordinatesystem{y spherical}{% %%%rotation around x \setkeys{y sphericalkeys}{#1}% \pgfpointxyz{\myradiussin(\mytheta)cos(\myphi)}{\myradiuscos(\mytheta)}{\myradiussin(\mytheta)*sin(\myphi)}}

\makeatother

% definitions to make your life easier \tikzset{rotate axes about y axis/.code={ \path (y spherical cs:radius=1,theta=90,phi=0+#1) coordinate(xpp) (y spherical cs:radius=1,theta=00,phi=90+#1) coordinate(ypp) (y spherical cs:radius=1,theta=90,phi=90+#1) coordinate(zpp); },rotate axes about x axis/.code={ \path (x spherical cs:radius=1,theta=00,phi=90+#1) coordinate(xpp) (x spherical cs:radius=1,theta=90,phi=00+#1) coordinate(ypp) (x spherical cs:radius=1,theta=90,phi=90+#1) coordinate(zpp); }, pitch/.style={rotate axes about y axis=#1,x={(xpp)},y={(ypp)},z={(zpp)}}, roll/.style={rotate axes about x axis=#1,x={(xpp)},y={(ypp)},z={(zpp)}} }

\tdplotsetmaincoords{60}{130}

%[tangage - pitch ] { \begin{tikzpicture}[scale=1] \begin{scope}[tdplot_main_coords] %axes principaux \begin{scope} \draw[thick,->] (0,0,0)node[above right]{$O$} -- (8,0,0) node[left]{$z$}; \draw[thick,->] (0,0,0) -- (0,5,0) node[below]{$x$}; \draw[thick,->] (0,0,0) --(0,0,5) node[right]{$y$}; \end{scope}

\def\rr{0.5} \newcommand{\planar}[1][]{ \draw[fill,#1] (aa) ++(0,{0.5cos(15)},{0.5sin(15)}) --++ (0,{\rrcos(-75)},{\rrsin(-75)}) coordinate(bb)--++(\rr,0,0) --++(0,{2\rrcos(105)},{2\rrsin(105)}) --++({-2\rr},0,0) --++ (0,{2\rrcos(-75)},{2\rr*sin(-75)}) -- (bb); }

\newcommand{\planav}[1][]{ \draw[fill,#1] (aa) ++(0,{0.5cos(-165)},{0.5sin(-165)}) --++ (0,{\rrcos(-75)},{\rrsin(-75)}) coordinate(bb)--++(\rr,0,0) --++(0,{2\rrcos(105)},{2\rrsin(105)}) --++({-2\rr},0,0) --++ (0,{2\rrcos(-75)},{2\rr*sin(-75)}) -- (bb); }

\newcommand{\plansetbille}[1][]{ \coordinate(aa) at (3,0,0); \planar[green!50] \nodedraw,fill=red,minimum size=1cm,circle at (aa){}; \planav[blue!50,opacity=0.5] \draw[-latex] (aa) -- ++(0,-6,0)coordinatepos=0.35 node[left]{$z$}; \draw[-latex,blue] (bille) -- ++(0,{3cos(-165)},{3sin(-165)}) coordinatepos=0.6node[right]{${n_{a\ind}}$};

\draw[thick,blue] (bille) --++ (0,-5,0) --++(-3,0,0) --++(0,-2,0); \draw[thick,green] (bille) --++ (0,3,0) --++(-3,0,0) --++(0,2,0);

\draw[thick,color=blue,->] (0,0,0) --(4.5,0,0)coordinatepos=0.6 node[right]{${u_{a\ind}}$}; }

\tdplotsetrotatedcoords{90}{00}{00} % kept here the yaw rotation \begin{scope}[tdplot_rotated_coords]

\foreach \rot/\ind in {90/1,-30/2,-150/3} { \begin{scope}[pitch=\rot] \plansetbille[\ind] \end{scope} } \end{scope} \end{scope}

\draw-latex to[bend right=8] node[below,pos=0.2]{$\theta$} (yy1) ; \end{tikzpicture} }

\end{document}

enter image description here

rpapa
  • 12,350