I managed to position some cubes defined as pics on a single plane, and now I'd like to determine the position of the lower frame in every box, so that a vector from origin to this location can be drawn. But the command rotate around z=...
seems to change the known vector end position (=lower frame in box).
If the box is not rotated and nothing (frame offset inside box) is added, the position is correct (except of offset to frame in box), but how do I manage to follow this position along, even after the rotation and add the frame offset (denoted M
in my box pic).
Note: Even the yellow box arrow only points to the box not the lower frame inside. Therefore vector addition would be needed in all cases. (I think so at least. But for whichever reason this also doesn't point to the correct position.)
Goal: Don't point to box corner, but to frame inside, even after rotation.
\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{backgrounds,perspective,calc}
\begin{document}
\begin{tikzpicture}[>=latex,line cap=round,line join=round,scale=2]
\newcommand{\simpleaxes}[6]{% 1-3 position, 4-6 size
\draw[->] (-0.5+#1,#2,#3) -- (#1+#4,#2,#3) node[pos=1.1]{x};
\draw[->] (#1,-0.5+#2,#3) -- (#1,#2+#5,#3) node[pos=1.1]{y};
\draw[->] (#1,#2,-0.5+#3) -- (#1,#2,#3+#6) node[pos=1.1]{z};}
\tikzset{pics/coordsys/.style={
code = {\tikzset{coordsys/.cd,#1}
\draw [->,pic actions] (0,0,0) -- (1,0,0)[red] node[pos=1.4]
{$\pgfkeysvalueof{/tikz/coordsys/x}$};
\draw [->,pic actions] (0,0,0) -- (0,1,0)[green!60!black] node[pos=1.2]
{$\pgfkeysvalueof{/tikz/coordsys/y}$};
\draw [->,pic actions] (0,0,0) -- (0,0,1)[blue] node[pos=1.2]
{$\pgfkeysvalueof{/tikz/coordsys/z}$};
}
},coordsys/.cd,x/.initial=x,y/.initial=y,z/.initial=z}
\tikzset{pics/coordsysshift/.style={
code = {\tikzset{coordsysshift/.cd,#1}
\begin{scope}[rotate around z=45, rotate around y=45, rotate around x=45]
\draw [->,pic actions] (0,0,0) -- (1,0,0)[red] node[pos=1.3]
{$\pgfkeysvalueof{/tikz/coordsysshift/x}$};
\draw [->,pic actions] (0,0,0) -- (0,1,0)[green!60!black] node[pos=1.2]
{$\pgfkeysvalueof{/tikz/coordsysshift/y}$};
\draw [->,pic actions] (0,0,0) -- (0,0,1)[blue] node[pos=1.2]
{$\pgfkeysvalueof{/tikz/coordsysshift/z}$};
\end{scope}
}
},coordsysshift/.cd,x/.initial=x,y/.initial=y,z/.initial=z}
\tikzset{
pics/complicated/.style={
code={
\tikzset{complicated/.cd,#1}
\begin{scope}[transparency group, fill opacity=0.8]
\draw[\boxframecolor,fill=\boxfillcolor] (0,0,\cubez) %xy plane/top face
-- ++(\cubex,0,0)
-- ++(0,\cubey,0)
-- ++(-\cubex,0,0) -- cycle;
\draw[\boxframecolor,fill=\boxfillcolor] (0,0,0) %yz plane/left face
-- ++(0,0,\cubez)
-- ++(0,\cubey,0)
-- ++(0,0,-\cubez) -- cycle;
\draw[\boxframecolor,fill=\boxfillcolor] (0,0,0) %xz plane/front face
-- ++(\cubex,0,0)
-- ++(0,0,\cubez)
-- ++(-\cubex,0,0) -- cycle;
%%%% define positioning of M,B frames inside box
\pgfmathsetmacro{\dx}{0.5};
\pgfmathsetmacro{\dy}{0.5};
\pgfmathsetmacro{\dz}{0.4};
\coordinate (origin) at (-5,0,0);
%\coordinate (M) at (\dx,\cubey-\dy,\dz);
%\coordinate (B) at (\cubex-\dx,\dy,\cubez-\dz);
\coordinate (M) at (\dx,\dy,\dz);
\coordinate (B) at (\cubex-\dx,\cubey-\dy,\cubez-\dz);
\draw (M) pic[thick] {coordsys={x=x_M,y=y_M,z=z_M}};
\node [below right] at (M.south) {\textit{M}};
\draw (B) pic[dotted] {coordsys={x=x_M',y=y_M',z=z_M'}};
\node [above left] at (B.west) {\textit{B}};
\draw (B) pic[thick] {coordsysshift={x=x_{B},y=y_{B},z=z_{B}}};
\draw [->, thick] (M) -- (B) node [midway,fill=\boxfillcolor] {$q_{MB}, r_{MB}$};
\end{scope}
}
},
complicated/.cd,
cube x/.store in=\cubex,
cube x=8,
cube y/.store in=\cubey,
cube y=8,
cube z/.store in=\cubez,
cube z=2,
box fill color/.store in=\boxfillcolor,
box fill color=yellow!25,
box frame color/.store in=\boxframecolor,
box frame color=gray!25
}
\begin{scope}[3d view={-80}{15}]
\simpleaxes{0}{0}{0}{8}{8}{2};
\coordinate (posyellow) at (0,5,0);
\coordinate (posblue) at (2,4,0);
\path (0,5,0) pic(yellow) {complicated={box frame color=yellow}};
% in line below: [rotate around z=-50] is the problem, how to follow rot. ?
\path [rotate around z=-50](2,4,0) pic (blue) {complicated={box fill color=blue!25,box frame color=blue}};
\path (0,0,-5) pic {coordsys};
\draw [->,dotted, opacity=0.8] (0,0,-5) -- ($(posyellow)$); % +yellowM
\draw [->,dotted, opacity=0.8] (0,0,-5) -- ($(posblue)$);%,rotate around z=-50 % ($(posblue)+(blueM)$)
\end{scope}
\end{tikzpicture}
\end{document}