
Estoy intentando rotar un círculo alrededor de dos ejes. El círculo debe colocarse perpendicular al vector rojo.
Código:
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% xyz axes
\draw[thick,->] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,5) node[anchor=north west]{$z$};
% vector
\draw[->,red] (0,0,0) -- (4,4,4);
% center of circle
\fill (3,3,3) circle (1pt);
% circle
\draw (3,3,3) circle (3); % rotation?
\end{tikzpicture}
\end{document}
Producción:
Me gustaría saber cómo rotar el círculo de manera que el vector rojo y el círculo sean perpendiculares entre sí. Creo que es una rotación de 45° alrededor del eje y y de 45° alrededor del eje z, pero ¿cómo se puede realizar esto usando tikz?
Respuesta1
Yo sugeriría usartikz-3dplot
siRealmente quieres usar TikZ ya que manejará muchos de los cálculos necesarios para simular 3D con un paquete diseñado para dibujar en 2D.
Por ejemplo:
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{110}
\tdplotsetrotatedcoords{180}{-90}{-90}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[tdplot_rotated_coords]
\draw[thick,->] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,5) node[anchor=north west]{$z$};
\draw[->,red] (0,0,0) -- (4,4,4);
\path [fill] (3,3,3) coordinate (c) circle (1pt);
\tdplotdrawarc[tdplot_rotated_coords]{(c)}{3}{0}{360}{}{}
\end{scope}
\end{tikzpicture}
\end{document}
Si quisiéramos sombrear el círculo para dar más sensación de profundidad, podríamos usar la backgrounds
biblioteca y preocuparnos un poco por el orden del dibujo. Por ejemplo:
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds}
\begin{document}
\tdplotsetmaincoords{70}{110}
\tdplotsetrotatedcoords{180}{-90}{-90}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[tdplot_rotated_coords]
\draw[thick,->] (0,0,0) coordinate (o) -- (5,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (o) -- (0,5,0) node[anchor=north west]{$y$};
\draw[thick,->] (o) -- (0,0,5) node[anchor=north west]{$z$};
\draw[red] (o) -- (3,3,3) coordinate (c);
\path [fill] (c) circle (1pt);
\begin{scope}[on background layer]
\draw[->,red] (c) -- (4,4,4);
\tdplotdrawarc[tdplot_rotated_coords, right color=blue!50!cyan, left color=blue!50!cyan!15!white, fill opacity=.25, postaction={top color=blue!50!cyan!15!white, bottom color=blue!50!cyan, fill opacity=.25}]{(c)}{3}{0}{360}{}{}
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}