Winkel zur 3D-Drohne hinzufügen

Winkel zur 3D-Drohne hinzufügen

Wie kann ich dem Code Euler-Winkel und XYZ-Winkel wie im Bild hinzufügen?Bildbeschreibung hier eingeben

\documentclass[tikz]{standalone}
%\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{3d, arrows.meta, calc, quotes}
\begin{document}
\begin{tikzpicture}[
  x = ( 20:-2cm), y = (-30: 2cm), z = ( 80: 1.6cm),
  > = Triangle]
\draw coordinate (O) (0,0,-.05) ellipse [radius=.2];

\foreach \xy/\yx in {x/y, y/x} {
  \fill[white] (xyz cs: \xy = -1, \yx = -.05) -- (xyz cs: \xy =  1, \yx=-.05)
            -- (xyz cs: \xy =  1, \yx =  .05) -- (xyz cs: \xy = -1, \yx= .05) -- cycle;
  \foreach \lmr in {-.05, 0, .05}
    \draw[gray] (xyz cs: \xy=-1, \yx = \lmr) -- (xyz cs: \xy=1, \yx=\lmr);
  \draw[fill=white, radius=.15] (xyz cs: \xy = -1) ellipse[]
                                (xyz cs: \xy =  1) ellipse[];
}
\draw[fill=white] (O) ellipse [radius=.2];

\foreach \xyz/\Label/\Ang in {% \Ang needs to start with a ,
  x/left/ {, longitude = 70},
  y/right/{, longitude =-20},
  z/above/{, longitude = 70, latitude=70}%
} {
  \draw[->, densely dashed, red] (0, 0, 0) -- ++(xyz cs: \xyz= 1.5)
    coordinate (ax-\xyz) node[\Label] {$\xyz$};
  \draw[blue, ->]
     (0, 0, 0) -- (xyz spherical cs: radius = 1.5,/tikz/style/.expanded=\Ang)
      coordinate (ax-\xyz') node[\Label] {$\xyz$};
}

\draw[canvas is xy plane at z=0]
  (0, 1) arc[start angle=90, delta angle=20, radius=1]
  node[midway, below right] {$\varphi$};
\end{tikzpicture}
\end{document}

Antwort1

Ich würde empfehlen, das tikz-3dplotPaket zu verwenden. Im Paket ist bereits eine Koordinatentransformation mit Euler-Winkeln definiert. Sie finden eine ähnliche Frage mit einigen hilfreichen AntwortenHier. Grundsätzlich kann man ein Hauptkoordinatensystem definieren, dessen Orientierung man mit zwei Winkeln festlegen kann (z.B. \tdplotsetmaincoords{50}{115}). Dieses Koordinatensystem kann dann mit dem Befehl gedreht werden \tdplotsetrotatedcoords{<angle1>}{<angle2>}{<angle3>}. Innerhalb des Pakets ist dieser Befehl implementiert, um eine Drehung des Koordinatensystems mit den Eulerwinkeln in der Reihenfolge zyz durchzuführen.

Um eine andere Sequenz zu erhalten, kann man den Transformationsbefehl neu definieren, wie bereits inDasUnddiese Antwortzumvorgenannte Frage. Auf diese Weise können Sie letztendlich alle möglichen Sequenzen hinzufügen und zwischen ihnen wechseln. Im folgenden Code habe ich die Zyx-Sequenz verwendet (die Tait-Bryan- oder Kardanwinkel genannt werden (sieheWikipedia für Eulerwinkel)), da es dem gegebenen Bild am nächsten kommt und auch das gebräuchlichste für Tait-Byran-Winkel und auch eine zxz-Folge als die häufigsten klassischen Euler-Winkel ist.

Sie können dann entweder im Haupt- oder im gedrehten Koordinatensystem zeichnen. Auf diese Weise ist es einfach, jede 3D-Zeichnung hinzuzufügen, z. B. Ihre Drohne und auch die Bögen zum Markieren der Winkel. Das tikz-3dplotPaket enthält einen Befehl, aber ich fand es intuitiver, den Bogen mit der Option , die Sie bereits verwendet haben, \tdplotdrawarc[coordinates_frame,->,colo]{origin}{radius}{start angle}{end angle}{node info}{label}einfach manuell auf den Ebenen der gedrehten Koordinatensysteme zu zeichnen .canvas is xy plane at z=0

\documentclass[tikz]{standalone}
%\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, quotes}
%\usetikzlibrary{3d, arrows.meta, calc, quotes}

\usepackage{tikz-3dplot}

% Define new arc command
% Syntax: [draw options] (center) (initial angle:final angle:radius)
% https://tex.stackexchange.com/a/66220
\def\centerarc[#1](#2)(#3:#4:#5){%
    \draw [#1] ($(#2)+({#5*cos(#3)}, {#5*sin(#3)})$) arc (#3:#4:#5)%
}
 
% Redefine the rotation sequence for the tikz3d-plot to Euler-Angles:
% z-x-z with alpha-beta-gamma (psi-theta-phi)
% https://tex.stackexchange.com/q/118069/98906
\newcommand{\tdseteulerzxz}{%
    \renewcommand{\tdplotcalctransformrotmain}{%
        %
        % Determine the sin and cos of the specified angle in degrees
        % \tdplotsinandcos{sin}{cos}{theta}
        % - #1: Returns sin(#3)
        % - #2: Returns cos(#3)
        % - #3: User-specified angle theta
        \tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} 
        \tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta}
        \tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma}
        %
        % Define trigonometric abbreviations
        %
        \tdplotmult{\sasb}{\sinalpha}{\sinbeta}
        \tdplotmult{\sacb}{\sinalpha}{\cosbeta}
        \tdplotmult{\sacbsg}{\sacb}{\singamma}
        \tdplotmult{\sacbcg}{\sacb}{\cosgamma}
        \tdplotmult{\sasg}{\sinalpha}{\singamma}
        \tdplotmult{\sacg}{\sinalpha}{\cosgamma}
        %
        \tdplotmult{\sbsg}{\sinbeta}{\singamma}
        \tdplotmult{\sbcg}{\sinbeta}{\cosgamma}
        %
        \tdplotmult{\casb}{\cosalpha}{\sinbeta}
        \tdplotmult{\cacb}{\cosalpha}{\cosbeta}
        \tdplotmult{\cacbsg}{\cacb}{\singamma}
        \tdplotmult{\cacbcg}{\cacb}{\cosgamma}
        \tdplotmult{\casg}{\cosalpha}{\singamma}
        \tdplotmult{\cacg}{\cosalpha}{\cosgamma}
        %
        % Define the entries for the rotation matrix from the B-System to the I-System
        % This is A_IB = (A_BI)^T
        %
        \pgfmathsetmacro{\raaeul}{+\cacg - \sacbsg}
        \pgfmathsetmacro{\rabeul}{-\casg - \sacbcg}
        \pgfmathsetmacro{\raceul}{+\sasb}
        %
        \pgfmathsetmacro{\rbaeul}{+\sacg + \cacbsg}
        \pgfmathsetmacro{\rbbeul}{-\sasg + \cacbcg}
        \pgfmathsetmacro{\rbceul}{-\casb}
        %
        \pgfmathsetmacro{\rcaeul}{+\sbsg}
        \pgfmathsetmacro{\rcbeul}{+\sbcg}
        \pgfmathsetmacro{\rcceul}{+\cosbeta}
        %
    }
}
 
% Redefine the rotation sequence for the tikz3d-plot to Cardan-Angles:
% z-y-x with alpha-beta-gamma
% https://tex.stackexchange.com/q/118069/98906
\newcommand{\tdsetcardanzyx}{%
    \renewcommand{\tdplotcalctransformrotmain}{%
        %
        % Determine the sin and cos of the specified angle in degrees
        % \tdplotsinandcos{sin}{cos}{theta}
        % - #1: Returns sin(#3)
        % - #2: Returns cos(#3)
        % - #3: User-specified angle theta
        \tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} 
        \tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta}
        \tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma}
        %
        % Define trigonometric abbreviations
        %
        \tdplotmult{\sasb}{\sinalpha}{\sinbeta}
        \tdplotmult{\sasbsg}{\sasb}{\singamma}
        \tdplotmult{\sasbcg}{\sasb}{\cosgamma}
        %
        \tdplotmult{\sacb}{\sinalpha}{\cosbeta}
        \tdplotmult{\sasg}{\sinalpha}{\singamma}
        \tdplotmult{\sacg}{\sinalpha}{\cosgamma}
        %
        \tdplotmult{\casb}{\cosalpha}{\sinbeta}
        \tdplotmult{\casbsg}{\casb}{\singamma}
        \tdplotmult{\casbcg}{\casb}{\cosgamma}
        %
        \tdplotmult{\cacb}{\cosalpha}{\cosbeta}
        \tdplotmult{\casg}{\cosalpha}{\singamma}
        \tdplotmult{\cacg}{\cosalpha}{\cosgamma}
        \tdplotmult{\cbsg}{\cosbeta}{\singamma}
        \tdplotmult{\cbcg}{\cosbeta}{\cosgamma}
        %
        % Define the entries for the rotation matrix from the B-System to the I-System
        % This is A_IB = (A_BI)^T
        %
        \pgfmathsetmacro{\raaeul}{+\cacb}
        \pgfmathsetmacro{\rabeul}{+\casbsg - \sacg}
        \pgfmathsetmacro{\raceul}{+\sasg+\casbcg}
        %
        \pgfmathsetmacro{\rbaeul}{+\sacb}
        \pgfmathsetmacro{\rbbeul}{+\cacg + \sasbsg}
        \pgfmathsetmacro{\rbceul}{\sasbcg-\casg}
        %
        \pgfmathsetmacro{\rcaeul}{-\sinbeta}
        \pgfmathsetmacro{\rcbeul}{+\cbsg}
        \pgfmathsetmacro{\rcceul}{+\cbcg}
        %
    }
}
 
% Plot display orientation
\tdplotsetmaincoords{50}{115}

\begin{document}


% z-y-x Tait-Bryan angles
\begin{tikzpicture}[scale=2,tdplot_main_coords,> = Triangle]
    % change ratation to z-y-x Tait-Bryan / Cardan angles
    \tdsetcardanzyx
    
    \pgfmathsetmacro{\angpsi}{-20}  % or alpha
    \pgfmathsetmacro{\angtheta}{-10}    % or beta
    \pgfmathsetmacro{\angphi}{-5}   % or gamma

    \pgfmathsetmacro{\r}{2} % unit length radius      
    
    \coordinate (O) at (0,0,0);     
    
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{\angphi}    
    \begin{scope}[tdplot_rotated_coords,scale=1.2]
        \draw coordinate (O) (0,0,-.05) ellipse [radius=.2];
        \foreach \xy/\yx in {x/y, y/x} {
          \fill[white] (xyz cs: \xy = -1, \yx = -.05) -- (xyz cs: \xy =  1, \yx=-.05)
                    -- (xyz cs: \xy =  1, \yx =  .05) -- (xyz cs: \xy = -1, \yx= .05) -- cycle;
          \foreach \lmr in {-.05, 0, .05}
            \draw[gray] (xyz cs: \xy=-1, \yx = \lmr) -- (xyz cs: \xy=1, \yx=\lmr);
          \draw[fill=white, radius=.15] (xyz cs: \xy = -1) ellipse[]
                                        (xyz cs: \xy =  1) ellipse[];
        }
        \draw[fill=white] (0,0,0) ellipse [radius=.2];
        
    \end{scope}     
    
    
    % original coordinate system
    \foreach \xyz/\Label in {x/left,y/right,z/above}
        \draw[->,blue] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz$};
    
    % angle of first rotation around z-axis
    \draw[canvas is xy plane at z=0,->] (1.5,0) arc (0:\angpsi:1.5);
    \node at ({1.7*cos(\angpsi/2)},{1.7*sin(\angpsi/2)},0){$\psi$};
    \draw[canvas is xy plane at z=0,->] (0,1.5) arc (90:90+\angpsi:1.5);
    \node at ({-1.7*sin(\angpsi/2)},{1.7*cos(\angpsi/2)},0){$\psi$};    
    \tdplotsetrotatedcoords{\angpsi}{0}{0}
    
    % new coordinate system
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {x/left,y/right}
            \draw[->,green] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz'$};
        
        % angle of second rotation around new y-axis
        \draw[canvas is xz plane at y=0,->] (1.5,0) arc (0:-\angtheta:1.5);
        \node at ({1.7*cos(\angtheta/2)},0,{-1.7*sin(\angtheta/2)}){$\theta$};
        \draw[canvas is xz plane at y=0,->] (0,1.5) arc (90:90-\angtheta:1.5);
        \node at ({1.7*sin(\angtheta/2)},0,{1.7*cos(\angtheta/2)}){$\theta$};
    \end{scope} 
    
        
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{0}  
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {z/above}
            \draw[->,magenta] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz''$};
        
        % angle of third rotation around new x-axis
        \draw[canvas is yz plane at x=0,->] (1.5,0) arc (0:\angphi:1.5);
        \node at (0,{1.7*cos(\angphi/2)},{1.7*sin(\angphi/2)}){$\varphi$};
        \draw[canvas is yz plane at x=0,->] (0,1.5) arc (90:90+\angphi:1.5);
        \node at (0,{-1.7*sin(\angphi/2)},{1.7*cos(\angphi/2)}){$\varphi$};
    \end{scope}     
    
    % rotated coordinate system
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{\angphi}    
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {x/left,y/right,z/above}
            \draw[->,densely dashed,red] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\tilde\xyz$};
    \end{scope}
\end{tikzpicture}

% z-x-z Euler angles
\begin{tikzpicture}[scale=2,tdplot_main_coords,> = Triangle]
    % change ratation to z-y-x Tait-Bryan / Cardan angles
    \tdseteulerzxz
    
    \pgfmathsetmacro{\angpsi}{-10}  % or alpha
    \pgfmathsetmacro{\angtheta}{-20}    % or beta
    \pgfmathsetmacro{\angphi}{-10}  % or gamma

    \pgfmathsetmacro{\r}{2} % unit length radius      
    
    \coordinate (O) at (0,0,0);     
    
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{\angphi}    
    \begin{scope}[tdplot_rotated_coords,scale=1.2]
        \draw coordinate (O) (0,0,-.05) ellipse [radius=.2];
        \foreach \xy/\yx in {x/y, y/x} {
          \fill[white] (xyz cs: \xy = -1, \yx = -.05) -- (xyz cs: \xy =  1, \yx=-.05)
                    -- (xyz cs: \xy =  1, \yx =  .05) -- (xyz cs: \xy = -1, \yx= .05) -- cycle;
          \foreach \lmr in {-.05, 0, .05}
            \draw[gray] (xyz cs: \xy=-1, \yx = \lmr) -- (xyz cs: \xy=1, \yx=\lmr);
          \draw[fill=white, radius=.15] (xyz cs: \xy = -1) ellipse[]
                                        (xyz cs: \xy =  1) ellipse[];
        }
        \draw[fill=white] (0,0,0) ellipse [radius=.2];
        
    \end{scope}     
    
    
    % original coordinate system
    \foreach \xyz/\Label in {x/left,y/right,z/above}
        \draw[->,blue] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz$};
    
    % angle of first rotation around z-axis
    \draw[canvas is xy plane at z=0,->] (1.5,0) arc (0:\angpsi:1.5);
    \node at ({1.7*cos(\angpsi/2)},{1.7*sin(\angpsi/2)},0){$\psi$};
    \draw[canvas is xy plane at z=0,->] (0,1.5) arc (90:90+\angpsi:1.5);
    \node at ({-1.7*sin(\angpsi/2)},{1.7*cos(\angpsi/2)},0){$\psi$};    
    \tdplotsetrotatedcoords{\angpsi}{0}{0}
    
    % new coordinate system
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {x/left,y/right}
            \draw[->,green] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz'$};
        
        % angle of second rotation around new x-axis
        \draw[canvas is yz plane at x=0,->] (1.5,0) arc (0:\angtheta:1.5);
        \node at (0,{1.7*cos(\angtheta/2)},{1.7*sin(\angtheta/2)}){$\theta$};
        \draw[canvas is yz plane at x=0,->] (0,1.5) arc (90:90+\angtheta:1.5);
        \node at (0,{-1.7*sin(\angtheta/2)},{1.7*cos(\angtheta/2)}){$\theta$};
    \end{scope} 
    
        
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{0}  
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {y/right}
            \draw[->,magenta] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\xyz''$};
        
        % angle of third rotation around new z-axis
        \draw[canvas is xy plane at z=0,->] (1.5,0) arc (0:\angphi:1.5);
        \node at ({1.7*cos(\angphi/2)},{1.7*sin(\angphi/2)},0){$\varphi$};
        \draw[canvas is xy plane at z=0,->] (0,1.5) arc (90:90+\angphi:1.5);
        \node at ({-1.7*sin(\angphi/2)},{1.7*cos(\angphi/2)},0){$\varphi$};
    \end{scope}     
    
    % rotated coordinate system
    \tdplotsetrotatedcoords{\angpsi}{\angtheta}{\angphi}    
    \begin{scope}[tdplot_rotated_coords]
        \foreach \xyz/\Label in {x/left,y/right,z/above}
            \draw[->,densely dashed,red] (O) -- (xyz cs: \xyz=\r) node[\Label]{$\tilde\xyz$};
    \end{scope}
\end{tikzpicture}


\end{document}

Ergebnisse:

Tait-Bryann zyx Tait-Bryan_zyx Euler zxz Euler_zxz

verwandte Informationen