10

I would like to create images similar to these ones: enter image description here enter image description here

However I would like to be able to do so in a coordinate system specific way so that I don't have to think about how the 2D projection of the image relates to the 3D image it is supposed to represent. For example: In the second image, Is there a way to specify a circle of a given radius centred at a particular z coordinate such that when viewed from different angles the circle changes (becomes an ellipse) so that perspective is honoured?

Basically I want to define objects in 3D and let tikz do all the work concerning rotations etc.

  • 1
    tikz-3dplot package has some nice/handy macros, although I'm not sure it's what you want. By the way, it's much more likely that you get help if you post a compilable example (from \documentclass to \end{document}) of the code you already have pointing out what is what you don't know how to do. – Manuel Jul 18 '14 at 23:05
  • You might want to check out Asymptote which has built-in facilities for doing this. – Charles Staats Jul 19 '14 at 14:08
11

This is an attempt. On the first plot, the first quadrant is the same as the second plot, but x-axis and y-axis are labeled interchangeably, then draw the x-axis line on the negative direction. For detail usages of the commands, they can be found in the documentation of tikz-3dplot.

enter image description here

Code

\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
% ----- First plot    
\tdplotsetmaincoords{70}{145}
\begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,blue,thick},
vector/.style={-stealth,black,very thick},
vector guide/.style={dotted,black,thick},
]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%tikz-3dplot coordinate definition using r, theta, phi coords
\pgfmathsetmacro{\ax}{1}
\pgfmathsetmacro{\ay}{-1}
\pgfmathsetmacro{\az}{0.5}

\coordinate (P) at (\ax,\ay,\az){};

%draw axes
    \draw[axis] (0,0,0) -- (2,0,0) node[anchor=north east]{$y$};   % x-axis becomes y axis
    \draw[axis] (0,0,0) -- (0,-2,0) node[anchor=south]{$x$}; %minius y-axis becomes positive x axis
    \draw[axis] (0,0,0) -- (0,0,2) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[vector guide] (O) -- (P)node{$\bullet$} node[left](){$(x,y,z)$};

% draw guide lines to components
\draw[vector guide] (O) -- (\ax,\ay,0);
\draw[vector guide] (\ax,\ay,0) -- (P);
\draw[vector guide] (\ax,\ay,0) -- (0,\ay,0);
\draw[vector guide] (\ax,\ay,0) -- (0,\ay,0);
\draw[vector guide] (\ax,\ay,0) -- (\ax,0,0);
\node[tdplot_main_coords,anchor=east]  at (\ax,0,0){};
\node[tdplot_main_coords,anchor=west]  at (0,\ay,0){};

\draw[thick,tdplot_main_coords] (1.5,0.5,0)-- (1.5,-0.5,0) -- (-1.5,-0.5,0)--(-1.5,0.5,0)--cycle;
\node[above] at (-0.6,0.1,0){$\bullet$};
\node at (-1,0,0) {$(x_0,y_0)$};

\draw[tdplot_main_coords,->,>=latex'] (0,2,0)--node[midway,above]{$U$} (0,1,0);
\end{tikzpicture}

% Second plot

\tdplotsetmaincoords{70}{115}
\begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,blue,thick},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,black,thick}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%tikz-3dplot coordinate definition using r, theta, phi coords

\pgfmathsetmacro{\ax}{1}
\pgfmathsetmacro{\ay}{1}
\pgfmathsetmacro{\az}{1}

\coordinate (P) at (\ax,\ay,\az){};

%draw axes
    \draw[axis] (0,0,0) -- (2,0,0) node[anchor=north east]{$\mathbf{e_x}$};
    \draw[axis] (0,0,0) -- (0,2,0) node[anchor=north west]{$\mathbf{e_y}$};
    \draw[axis] (0,0,0) -- (0,0,2) node[anchor=south]{$\mathbf{e_z}$};

%draw a vector from O to P
\draw[vector] (O) -- (P);% node(){$\bullet$};

\tdplotdrawarc[tdplot_main_coords]{(0,0,1)}{1.414}{0}{360}{anchor=north}{}

% draw guide lines to components
\draw[vector guide] (O) -- (\ax,\ay,0);
\draw[vector guide] (\ax,\ay,0) -- (P);
\draw[thick, <-,>=latex']  (P) --node[midway,above]{$r'$} (0,0,\az);
\node[tdplot_main_coords,above,left] at (0,-0.2,\az){$\zeta_3$};

\draw[thick,tdplot_main_coords,->,>=latex'] (1,1,1)-- (1,1,0.5) node[anchor=west]{$F_T$};
\draw[thick,tdplot_main_coords,->,>=latex'] (1,1,1)-- (1.5,0.8,1) node[anchor=east]{$F_D$};
\draw[thick,tdplot_main_coords,->,>=latex'] (1,1,1)
-- (1.5,1.5,1) node[anchor=south]{$F_R$};

\draw[dashed,tdplot_main_coords] (0.2,0,1)-- (-0.2,0,1);
\draw[dashed,tdplot_main_coords] (0,0.2,1)-- (0,-0.2,1);

\tdplotdrawarc[tdplot_main_coords,color=blue,->]{(0,0,0)}{0.5}{0}%
{45}{anchor=north,color=black}{$\Omega t+\phi'$}
\end{tikzpicture}

\end{document}
  • Thanks, for some reason the second tikz picture from your code does not run in my TexStudio due to the line "\draw[thick, <-,>=latex'] (P) --node[midway,above]{$r\rq{}$} (0,0,\az)" Any ideas what that could be? – Dipole Jul 19 '14 at 13:03
  • OK, I saw the problem, change \rq{} to '. Mine is TexWorks editor. – Jesse Jul 19 '14 at 13:09
  • Thanks now everything works beautifully, however I think there is a missing ";" on that line mentioned above and I think "latex'" should just be "latex" again in the line mentioned in the above comment. – Dipole Jul 19 '14 at 13:43
  • Ya, not until you mentioned it. My code in PC has it though. Thanks. – Jesse Jul 19 '14 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.