1

I need to draw two coordinate systems: first main rectangular the second one is inside the first one and is set by the offset along each of the axes from the first coordinate system and three rotations around each of the axes. The angles of rotation are assumed to be known.

I found a similar example, but here spherical coordinates are used, and I need initially rectangular:

% Author: Izaak Neutelings (June 2017)
% taken from https://tex.stackexchange.com/questions/159445/draw-in-cylindrical-and-spherical-coordinates
\documentclass[border=3pt,tikz]{standalone}
\usepackage{physics}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage[outline]{contour} % glow around text
\usepackage{xcolor}

\colorlet{veccol}{green!50!black} \colorlet{projcol}{blue!70!black} \colorlet{myblue}{blue!80!black} \colorlet{myred}{red!90!black} \colorlet{mydarkblue}{blue!50!black} \tikzset{>=latex} % for LaTeX arrow head \tikzstyle{proj}=[projcol!80,line width=0.08] %very thin \tikzstyle{area}=[draw=veccol,fill=veccol!80,fill opacity=0.6] \tikzstyle{vector}=[-stealth,myblue,thick,line cap=round] \tikzstyle{unit vector}=[->,veccol,thick,line cap=round] \tikzstyle{dark unit vector}=[unit vector,veccol!70!black] \usetikzlibrary{angles,quotes} % for pic (angle labels) \contourlength{1.3pt}

\begin{document}

% 3D AXIS with spherical coordinates
\tdplotsetmaincoords{60}{110} 
%
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}
%
\begin{tikzpicture}[scale=5,tdplot_main_coords]
    \coordinate (O) at (0,0,0);
    \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$Z$};
    \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$X$};

    \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$Y$};
    \tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
    \draw[-stealth,color=red] (O) -- (P);
    \draw[dashed, color=red] (O) -- (Pxy);
    \draw[dashed, color=red] (P) -- (Pxy);
    \tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$}
    \tdplotsetthetaplanecoords{\phivec}
    \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}%
    {\thetavec}{anchor=south west}{$\theta$}
    \draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec);
    \draw[dashed] (\rvec,0,0) arc (0:90:\rvec);
    \tdplotsetrotatedcoords{\phivec}{\thetavec}{0}
    \tdplotsetrotatedcoordsorigin{(P)}
    \draw[thick,tdplot_rotated_coords,->] (0,0,0)
    -- (.5,0,0) node[anchor=north west]{$Z’$};
    \draw[thick,tdplot_rotated_coords,->] (0,0,0)
    -- (0,.5,0) node[anchor=west]{$X’$};
    \draw[thick,tdplot_rotated_coords,->] (0,0,0)
    -- (0,0,.5) node[anchor=south]{$Y’$};
    \draw[-stealth,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,.2);
    \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,0);
    \draw[dashed,color=blue,tdplot_rotated_coords] (.2,.2,0) -- (.2,.2,.2);
    \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}%
    {45}{anchor=north west,color=black}{$\phi’$}
    \tdplotsetrotatedthetaplanecoords{45}
    \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}%
    {55}{anchor=south west,color=black}{$\theta’$}
\end{tikzpicture}

\end{document}

enter image description here

I also found a similar example for coordinate rotation. But I can't do right: Change from one cartesian 3D co-ordinate system to another by translation and rotation

1 Answers1

1

If it's only a rotation and a translation in the plane, the simplest solution is to use a scope

\documentclass{article}
\usepackage{tikz}
\usepackage{esvect}
\begin{document}
\begin{tikzpicture}
\draw[-latex] (0,0,0) coordinate(O) node[left]{$O_0$}-- ++ (10,0,0) node[above]{$\vv{x_0}$};
\draw[-latex] (O) -- ++ (0,10,0) node[right]{$\vv{y_0}$};

\draw[-latex] (O) -- ++ (0,0,10,0) node[above]{$\vv{z_0}$}; \draw[blue] (1,2,0) node[above]{$A_0$} -- (-2,4,0) node[above]{$B_0$};

\begin{scope}[shift={(4,3,0)}, rotate=15] \draw[-latex,red] (0,0,0) coordinate(O1) node[left]{$O_1$}-- ++ (7,0,0) node[above]{$\vv{x_1}$};

\draw[-latex,red] (O1) -- ++ (0,7,0) node[right]{$\vv{y_1}$}; \draw[-latex,red] (O1) -- ++ (0,0,7,0) node[above]{$\vv{z_1}$}; \draw[blue] (1,2,0) node[above]{$A_1$} -- (-2,4,0) node[above]{$B_1$}; \end{scope}

\end{tikzpicture}

\end{document}

enter image description here

rpapa
  • 12,350
  • Thanks, but I need to do it mathematically, using transformation matrices - translation and rotation. I provided a link – Антон Feb 02 '22 at 10:32