tikz 2D rotieren für 3D Perspektive der Achsen

Tabellen und Grafiken erstellen und anordnen


godi
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 75
Registriert: Mi 11. Feb 2015, 13:49

tikz 2D rotieren für 3D Perspektive der Achsen

Beitrag von godi »

Hallo,
ich habe eine 2D-Zeichnung die ich gerne ein wenig rotieren würde, so dass eine 3D Perspektive zum einzeichnen der z-Achse möglich ist.

Dazu habe ich das tikz-3dplot Paket gefunden. Jedoch habe ich das Proplem, dass ich in meiner Zeichnung ein \pgftransformrotate ausführe und dann passen die Koordinaten nicht mehr.

Bsp:
\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}
        
\begin{document}

\begin{tikzpicture} [thick, scale=4]

% Coordinate system:
\draw[gray, <->] (-0.5,0) node[below]{$-x$} -- (0.5,0) node[below]{$x$};
\draw[gray, <->] (0,-0.5) node[left]{$-y$} -- (0, 0.5) node[left]{$y$};

\draw (0.26,-0.26) circle (0.21);

\pgftransformrotate{-45}
\draw [fill] (0,-0.015) rectangle (0.155, 0.015);
\draw [fill] ({0.26*sqrt(2)},0.0) ellipse (.20 and .02);

\end{tikzpicture}

\tdplotsetmaincoords{45}{15}

\begin{tikzpicture} [tdplot_main_coords, thick, scale=4]

% Coordinate system:
\draw[gray, <->] (-0.5,0,0) node[below]{$-x$} -- (0.5,0) node[below]{$x$};
\draw[gray, <->] (0,-0.5,0) node[left]{$-y$} -- (0,0.5,0) node[left]{$y$};
\draw[gray, <->] (0,0,-0.5) node[left]{$-z$} -- (0,0,0.5) node[left]{$z$};

\draw (0.26,-0.26) circle (0.21);

\pgftransformrotate{-45}
\draw [fill] (0,-0.015) rectangle (0.155, 0.015);
\draw [fill] ({0.26*sqrt(2)},0.0) ellipse (.20 and .02);

\end{tikzpicture}

\end{document}
Wie kann ich \pgftransformrotate umgehen bzw die richtige Rotation hinbekommen?

godi
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 75
Registriert: Mi 11. Feb 2015, 13:49

Beitrag von godi »

Hallo,
ich habe eine Lösung gefunden, indem ich alle Rotationen mit tikz-3Dplot ausführe und das Rechteck mit Linien gezeichnet habe. Das Rechteck hat sich sonst nicht gedreht.
\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}
        
\begin{document}

\tdplotsetmaincoords{0}{0}

\begin{tikzpicture} [tdplot_main_coords, thick, scale=10]

% Coordinate system:
\draw[gray, <->] (-0.5,0) node[below]{$-x$} -- (0.5,0) node[below]{$x$};
\draw[gray, <->] (0,-0.5) node[left]{$-y$} -- (0, 0.5) node[left]{$y$};

\draw (0.26,-0.26) circle (0.21);

\tdplotsetrotatedcoords{-45}{0}{0}
\begin{scope}[tdplot_rotated_coords]
\draw [fill] (0,0.015) -- (0.155,0.015) -- (0.155,-0.015) -- (0,-0.015) -- cycle;
\draw [fill] ({0.26*sqrt(2)},0.0) ellipse (.20 and .02);
\end{scope}

\end{tikzpicture}

\tdplotsetmaincoords{45}{15}

\begin{tikzpicture} [tdplot_main_coords, thick, scale=10]

% Coordinate system:
\draw[gray, <->] (-0.5,0,0) node[below]{$-x$} -- (0.5,0) node[below]{$x$};
\draw[gray, <->] (0,-0.5,0) node[left]{$-y$} -- (0,0.5,0) node[left]{$y$};
\draw[gray, <->] (0,0,-0.5) node[left]{$-z$} -- (0,0,0.5) node[left]{$z$};

\draw (0.26,-0.26) circle (0.21);

\tdplotsetrotatedcoords{-45}{0}{0}
\begin{scope}[tdplot_rotated_coords]
\draw [fill] (0,0.015) -- (0.155,0.015) -- (0.155,-0.015) -- (0,-0.015) -- cycle;
\draw [fill] ({0.26*sqrt(2)},0) ellipse (.20 and .02);
\end{scope}

\end{tikzpicture}


\end{document}

Antworten