3d-vector.tex 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{tikz}
  5. \usepackage{tikz-3dplot}
  6. \begin{document}
  7. \begin{preview}
  8. \tdplotsetmaincoords{70}{110}
  9. \begin{tikzpicture}[scale=3,tdplot_main_coords]
  10. \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
  11. \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
  12. \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
  13. \tdplotsetcoord{O}{0}{0}{0}
  14. \tdplotsetcoord{P}{.8}{50}{70}
  15. %draw a vector from origin to point (P)
  16. \draw[-stealth,color=red] (O) -- (P);
  17. %draw projection on xy plane, and a connecting line
  18. \draw[dashed, color=red] (O) -- (Pxy);
  19. \draw[dashed, color=red] (P) -- (Pxy);
  20. \tdplotsetthetaplanecoords{70}
  21. \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0)
  22. -- (.2,0,0) node[anchor=east]{$x'$};
  23. \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0)
  24. -- (0,.2,0) node[anchor=north]{$y'$};
  25. \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0)
  26. -- (0,0,.2) node[anchor=west]{$z'$};
  27. \end{tikzpicture}
  28. \end{preview}
  29. \end{document}