diff options
author | Karl Berry <karl@freefriends.org> | 2010-01-18 23:43:19 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-01-18 23:43:19 +0000 |
commit | e65c74e7551529b3db597eef51915ea683e96e7e (patch) | |
tree | c1595910d5ae13fb4718e353a6b348bf23daa9e3 /Master/texmf-dist/doc | |
parent | 45919681c5a1d4dd078abbabac51a5de84aa75b2 (diff) |
new tikz package tikz-3dplot (18jan10)
git-svn-id: svn://tug.org/texlive/trunk@16779 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/README | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf | bin | 0 -> 330990 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex | 1402 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation_figures.tex | 296 |
4 files changed, 1705 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-3dplot/README b/Master/texmf-dist/doc/latex/tikz-3dplot/README new file mode 100644 index 00000000000..4350ec4e649 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/README @@ -0,0 +1,7 @@ +Package Name: tikz-3dplot + +Author Name: Jeff Hein + +License: LaTeX Project Public License + +Description: The tikz-3dplot package provides straightforward ways to define three-dimensional coordinate frames through which to plot in TikZ. The user can specify the orientation of the main coordinate frame, and use standard TikZ commands and coordinates to render their tikzfigure. A secondary coordinate frame is provided to allow rotations and translations with respect to the main coordinate frame. In addition, The 3dplot package can plotting user-specified functions in spherical polar coordinates, where both the radius and fill color can be expressed as parametric functions of polar angles. diff --git a/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf Binary files differnew file mode 100644 index 00000000000..8ec752ce378 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf diff --git a/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex new file mode 100644 index 00000000000..55cdf2ad083 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex @@ -0,0 +1,1402 @@ +%% tikz-3dplot_documentation.tex +%% Copyright 2010 Jeffrey D. Hein +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Jeffrey D. Hein. +% +% This work consists of the files tikz-3dplot.sty and tikz-3dplot_documentation.tex + +%Description +%----------- + +%tikz-3dplot_documentation.tex - documentation for tikz-3dplot.sty: package for plotting three dimensional axes and coordinates in TikZ. The user can specify orientation of the display, and also define rotated coordinate systems within the 3d display coordinate system. + +%Created 2009-11-07 by Jeff Hein. Last updated: 2010-01-17 +%---------------------------------------------------------- + +%Requirements +%------------ +%This requires the tikz package. + +%Update Notes +%------------ + +%As of Jan 17, 2010, this package has been renamed from ``3dplot'' to ``tikz-3dplot''. + + +\documentclass[10pt,letterpaper,oneside]{memoir} + +\usepackage{tikz} %for TikZ graphics +\usepackage{tikz-3dplot} %for tikz-3dplot functionality +\usepackage{amsmath} %for align equation environment +\usepackage{url} +%\usepackage{hyperref} + +\pgfrealjobname{tikz-3dplot_documentation} + +\input{tikz-3dplot_documentation_figures.tex} + + +\newcommand{\tikzname}{Ti\emph{k}Z} +\newcommand{\tdplot}{\texttt{tikz-3dplot}} + + +\title{The \texttt{\tdplot} Package} + +\author{Jeff Hein} + + + + +\newcommand{\tdplotlocation}{\url{http://www.ctan.org}} + +\settocdepth{subsection} + +\setsecnumdepth{subsection} +\maxsecnumdepth{subsection} +\settocdepth{subsection} +\maxtocdepth{subsection} + + + + + +%**************** Example Box ********************* + +\definecolor{shadecolor}{rgb}{0.90,0.90,0.90} +%this defines an environment for presenting code in an indented, shaded, verbatim, multipage region. Requires framed, alltt, and color environments, and \definecolor{shadecolor}{rgb}{0.90,0.90,0.90} + +%this sets the verbatim font and size, based on the memoir class usage +\setverbatimfont{\normalfont\ttfamily\footnotesize} +%this turns tabs on in the verbatim environment +\tabson[4] +%this sets the frequency of line numbers displayed in a boxedverbatim environment +%\linenumberfrequency{1} +%this sets the font size of line numbers in a boxedverbatim environment +\linenumberfont{\normalfont\ttfamily\tiny} +%this positions line numbers outside the box of a boxedverbatim environment +%\bvnumbersoutside +%this turns off the box of a boxedverbatim environment +\nobvbox + + +\begin{document} + +\frontmatter +\pagestyle{empty} + +\maketitle + + + +\begin{figure}[h] + \begin{center} + \tdplotmainfig + \threedsurfaceplot + + \threedalphabetagamma + %A 3d coordinate system rendered in \tikzname using the \tdplot\ package. The user can specify the display perspective by specifying angles $\theta_d$ and $\phi_d$, which rotate the coordinate frame from the ``standard'' display position where $x$ points to the right, $y$ points up. + \end{center} +\end{figure} + +\cleardoublepage + +{ + Document Version History + + \begin{description} + \item[2009-11-09] Initial release + \item[2009-11-21] Added spherical polar parametric surface plotting functionality with the \verb|\tdplotsphericalsurfaceplot| command. + \item[2009-12-04] Touched up on a few drawing issues in \verb|\tdplotsphericalsurfaceplot|, and added the \verb|\tdplotshowargcolorguide| command. + \item[2010-01-17] Changed package name from \texttt{3dplot} to \texttt{\tdplot}, and updated document accordingly. + \end{description} + + \vfill + \parindent=0pt + Copyright 2009 by Jeff Hein + + \medskip + Permission is granted to distribute and/or modify \emph{both + the documentation and the code} under the conditions of the LaTeX + Project Public License, either version 1.3 of this license or (at + your option) any later version. The latest version of this license is in + http://www.latex-project.org/lppl.txt + + \clearpage +} + +%copyright page, ripped from PGF manual +%{ +% \vbox{} +% %\vskip0pt plus 1fill +% %Für meinen Vater, damit er noch viele schöne \TeX-Graphiken +% erschaffen kann. +% %\vskip1em +% %\hfill\emph{Till} +% \vskip0pt plus 3fill +% +% \parindent=0pt +% Copyright 2009 by Jeff Hein +% +% \medskip +% Permission is granted to copy, distribute and/or modify \emph{the documentation} +% under the terms of the \textsc{gnu} Free Documentation License, Version 1.2 +% or any later version published by the Free Software Foundation; +% with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +% %A copy of the license is included in the section entitled \textsc{gnu} +% Free Documentation License. +% +% \medskip +% Permission is granted to copy, distribute and/or modify \emph{the +% code of the package} under the terms of the \textsc{gnu} Public License, Version 2 +% or any later version published by the Free Software Foundation. +% %A copy of the license is included in the section entitled \textsc{gnu} +% Public License. +% +% \medskip +% Permission is also granted to distribute and/or modify \emph{both +% the documentation and the code} under the conditions of the LaTeX +% Project Public License, either version 1.3 of this license or (at +% your option) any later version. %A copy of the license is included in +% the section entitled \LaTeX\ Project Public License. +% +% \vbox{} +% \clearpage +%} + + + +\pagenumbering{roman} +\tableofcontents +\cleardoublepage +\pagenumbering{arabic} + +\mainmatter + +\chapter{Introduction}\label{cha:intro} + +\section{Overview of the \tdplot\ Package} +The \tdplot\ package offers commands and coordinate tranformation styles for \tikzname, providing relatively straightforward tools to draw three-dimensional coordinate systems and simple three-dimensional diagrams. The package is currently in its infancy, and is subject to change. Comments or suggetions are encouraged. + +This document describes the basics of the \tdplot\ package and provides information about the various available commands. Examples are given where possible. + +\subsection{What \tdplot\ is} + +\tdplot\ provides commands to easily specify coordinate transformations for \tikzname, allowing for relatively easy plotting. I needed to draw accurate 3d vector images for a physics thesis, and this package was developed to meet this need. + +In a recent addition, the \verb|\tdplotsphericalsurfaceplot| renders three dimensional surfaces, where both the radius and the surface fill hue can be expressed as user-specified functions of $\theta$ and $\phi$. This command is discussed in Section \ref{sec:spherical_surface_plot}. + +\begin{figure}[h] + \begin{center} + \threedconventions + \end{center} + \caption{\tdplot\ coordinate and positive angle convention.}\label{fig:conventions} +\end{figure} + +In \tdplot, a right-handed coordinate system convention is used. In addition, all positive angles constitute a right-hand screw sense of rotation (see Figure \ref{fig:conventions}). This means that a positive rotation about a given axis refers to a clockwise rotation when viewing along the direction the axis, or counterclockwise when viewing against the direction of the axis. + +\subsection{What \tdplot\ is not} + +\tdplot\ does not, in general, consider polygons, surfaces, or object opacity. The one exception is the \verb|\tdplotsphericalsurfaceplot| command, specifically designed to render spherical polar surfaces. The \verb|\tdplotsphericalsurfaceplot| command is discussed in Section \ref{sec:spherical_surface_plot}. + +Tools like Sketch by Gene Ressler are better suited for more rigorous surface rendering. These can be found at \url{http://www.frontiernet.net/~eugene.ressler/} + +\subsection{Similar Work} + +To my knowledge, there is no other package available which allows straightforward rendering of 3d coordinates in \tikzname, directly in a \LaTeX\ document. Since this project is in its infancy, this may be subject to change based on feedback. + +\subsubsection{Sketch} + +The Sketch project can provide three-dimensional rendering of axes, points, and lines, but (as far as I understand the program) cannot draw arcs without using a series of line segments. Further, Sketch requires an external program to render the image, while \tdplot\ can be developed and maintained right in a \LaTeX\ document. + +\subsubsection{\TeX ample.net} + +There are a variety of \tikzname\ examples listed at \url{http://www.texample.net/tikz/examples}. Some of these examples gave me inspiration to make this package. Some examples of note include the following: + +\begin{itemize} + \item 3D cone + \begin{description} + \item[Author:] Eugene Ressler + \item[url:] \url{http://www.texample.net/tikz/examples/3d-cone/} + \item[Notes:] This demonstrates the use of Sketch in TikZ figures. + \end{description} + \item Annotated 3D box + \begin{description} + \item[Author] Alain Matthes + \item[url] \url{http://www.texample.net/tikz/examples/annotated-3d-box/} + \item[Notes] This example demonstrates the direct use of coordinate transformations, as well as performing math directly within coordinates. + \end{description} + \item Cluster of atoms + \begin{description} + \item[Author] Agustin E. Bolzan + \item[url] \url{http://www.texample.net/tikz/examples/clusters-of-atoms/} + \item[Notes] This uses shifts and slants rather than rotations to render an isometric look. + \end{description} + \item Plane partition + \begin{description} + \item[Author] Jang Soo Kim + \item[url] \url{http://www.texample.net/tikz/examples/plane-partition/} + \item[Notes] This example draws solid surfaces with coordinate axes defined by rotations around the \tikzname\ standard coordinate frame. + \end{description} + \item Spherical and cartesian grids + \begin{description} + \item[Author] Marco Miani + \item[url] \url{http://www.texample.net/tikz/examples/spherical-and-cartesian-grids/} + \item[Notes] This example renders arcs and lines in three dimensions using explicit calculations. It takes into account the opacity of the spherical example, by showing hidden lines behind the sphere as dashed lines. + \end{description} + \item Stereographic and cylindrical map projections + \begin{description} + \item[Author] Thomas M. Trzeciak + \item[url] \url{http://www.texample.net/tikz/examples/map-projections/} + \item[Notes] This example illustrates the use of coordinate transformations to draw planes and arcs for spherical coordinates. + \end{description} +\end{itemize} + + +\section{Installing the \tdplot\ Package} + +Get a copy of \tdplot\ from \tdplotlocation. Place the style file in the same directory as your \LaTeX\ project. In your preamble, add the following line: +% +\begin{shaded} +\begin{verbatim} +\include{tikz-3dplot} +\end{verbatim} +\end{shaded} + +Make sure this line is written after all other required packages. + + +\subsection{\tdplot\ Requirements} + +To use this package, the following other packages must be loaded in the preamble first: +\begin{itemize} +\item \tikzname +\item \texttt{ifthen} (for the \texttt{tdplotsphericalsurfaceplot} command) +\end{itemize} + + +\subsection{\tdplot\ Package Options} + +Currently there are no options available for the \tdplot\ package. + +\section{Using the \tdplot\ Package} + +\tdplot\ provides styles and commands which are useful in a \texttt{tikzpicture} environment. These commands and styles are described in Chapter \ref{cha:using_tdplot}. + + + + + + + + + +\chapter{Overview of 3d in \tdplot}\label{cha:overview3d} + +\section{\tikzname\ 3d Plotting} \label{sec:tikzplotting} + +When setting up a tikzpicture or a drawing style, the $x$, $y$, and $z$ axes can be specified directly in terms of the original coordinate system. The following example shows how a \texttt{tikzpicture} environment can be configured to use customized axes. + +\begin{shaded} +\begin{verbatim} +\begin{tikzpicture}[% + x={(\raarot cm,\rbarot cm)},% + y={(\rabrot cm, \rbbrot cm)},% + z={(\racrot, \rbcrot cm)}] +\end{verbatim} +\end{shaded} + +In this example, the terms \verb|\raarot| and so on specify how the coordinates are represented in the original \tikzname\ coordinate system, and are calculated by the \tdplot\ package. Note that units are explicitly required so \tikzname\ understands that these are absolute coordinates, not scales on the existing axis. See the PGF manual Version 2.00, section 21.2 on pages 217-218 for details on \tikzname\ coordinate transformations. + +\section{The \tdplot\ Main Coordinate System}\label{sec:main_theory} + +\tdplot\ offers two coordinate systems, namely the \emph{main} coordinate system $(x,y,z)$, and the \emph{rotated} coordinate system $(x',y',z')$. The latter system is described in Section \ref{sec:rotated_theory}. + +As the name suggests, the main coordinate system provides a user-specified transformation to render 3d points in a \texttt{tikzpicture} environment. The orientation of the main coordinate system is defined by the angles $\theta_{d}$ and $\phi_{d}$. In the unrotated ($\theta_{d} = \phi_{d} = 0$) position, the $xy$ plane of the main coordinate system coincides with the default orientation for a \texttt{tikzpicture} environment, while $z$ points ``out of the page''. +% +The coordinate system is positioned by the following operations: +% +\begin{itemize} + \item Rotate the coordinate system about the body $x$ axis by the amount $\theta_d$, and + \item Rotate the coordinate system about the (rotated) body $z$ axis by the amount $\phi_d$. +\end{itemize} + +In this rotation sense, the $z$ axis will always point in the vertical page direction. This transformation is given by the rotation matrix $R_d(\theta_d,\phi_d)$, as +% +\begin{align}\begin{split} + R^d(\theta_d,\phi_d) &= R^{z'}(\phi_d)R^{x}(\theta_d)\\ + &= \begin{pmatrix} + \cos\phi_d & -\sin\phi_d & 0\\ + \sin\phi_d & \cos\phi_d & 0\\ + 0 & 0 & 1 + \end{pmatrix} + \begin{pmatrix} + 1 & 0 & 0\\ + 0 & \cos\theta_d & -\sin\theta_d\\ + 0 & \sin\theta_d & \cos\theta_d\\ + \end{pmatrix}\\ + &= \begin{pmatrix} + \cos\phi_d & \sin\phi_d & 0\\ + -\cos\theta_d\sin\phi_d & \cos\theta_d\cos\phi_d & -\sin\theta_d\\ + \sin\theta_d\sin\phi_d & -\sin\theta_d\cos\phi_d & \cos\theta_d\\ + \end{pmatrix} +\end{split}\end{align} + +\begin{figure}[b] + \begin{center} + \threedcoord{0}{0} + \threedcoord{10}{50} + \threedcoord{30}{110} + + \threedcoord{40}{150} + \threedcoord{60}{170} + \threedcoord{90}{180} + \end{center} + \caption{Examples of coordinate systems for various choices of $\theta_d$ and $\phi_d$.} +\end{figure} + +Using this matrix, the \tikzname\ coordinate transformation can be applied as described in Section \ref{sec:tikzplotting} by the various matrix elements, as +% +\begin{align}\begin{split} + x &= (R^d_{1,1}, R^d_{2,1})\\ + y &= (R^d_{1,2}, R^d_{2,2})\\ + z &= (R^d_{1,3}, R^d_{2,3}) +\end{split}\end{align} + +Note that the third row of the rotation matrix is not needed for this transformation, since a screen coordinate is a 2d value. Once the transformed axes have been established, any 3d coordinate specified in \tikzname\ will adhere to the transformation, yeilding a 3d representation. Lines and nodes can readily be drawn by using these 3d coordinates. + +This coordinate transformation is accessible through \tdplot\ using the command \texttt{tdplotsetmaincoords}, as described in Chapter \ref{cha:using_tdplot}. + +\section{The \tdplot\ Rotated Coordinate System}\label{sec:rotated_theory} + +Along with the main coordinate system, described in Section \ref{sec:main_theory}, \tdplot\ offers a \emph{rotated} coordinate system that is defined with respect to the main coordinate system. This system can be rotated to any position using Euler rotations, and can be translated so the origin of the rotated coordinate system sits on an arbitrary point in the main coordinate system. + +Three rotations can be performed to give any arbitrary orientation of a rotated coordinate system. By convention, the following rotations are chosen: +% +\begin{itemize} + \item Rotate by angle $\gamma$ about the world $z$ axis, + \item Rotate by angle $\beta$ about the (unrotated) world $y$ axis, and + \item Rotate by angle $\alpha$ about the (unrotated) world $z$ axis. +\end{itemize} + +These rotations are shown in Figure \ref{fig:euler_angles}. + +\begin{figure}[h] + \begin{center} + \threedalphabetagamma + \end{center} + \caption{Positioning the rotated coordinate frame $(x', y', z')$ using Euler angles $(\alpha, \beta, \gamma)$.}\label{fig:euler_angles} +\end{figure} + + +This rotation matrix $D(\alpha,\beta,\gamma)$ is given by +% +\begin{align}\begin{split} + D(\alpha,\beta,\gamma) &= R^z(\alpha)R^y(\beta)R^z(\gamma)\\ + &= \begin{pmatrix} + \cos\alpha & -\sin\alpha & 0\\ + \sin\alpha & \cos\alpha & 0\\ + 0 & 0 & 1\\ + \end{pmatrix} + \begin{pmatrix} + \cos\beta & 0 & \sin\beta \\ + 0 & 1 & 0 \\ + -\sin\beta & 0 & \cos\beta\\ + \end{pmatrix} + \begin{pmatrix} + \cos\gamma & -\sin\gamma & 0\\ + \sin\gamma & \cos\gamma & 0\\ + 0 & 0 & 1\\ + \end{pmatrix}\\ + &= \begin{pmatrix} + \cos\alpha\cos\beta\cos\gamma - \sin\alpha\sin\gamma & -\cos\alpha\cos\beta\sin\gamma - \sin\alpha\cos\beta & \cos\alpha\sin\beta\\ + \sin\alpha\cos\beta\cos\gamma + \cos\alpha\sin\gamma & -\sin\alpha\cos\beta\sin\gamma + \cos\alpha\cos\gamma & \sin\alpha\sin\beta\\ + -\sin\beta\cos\gamma & \sin\beta\sin\gamma & \cos\beta + \end{pmatrix} +\end{split}\end{align} + +To define the rotated coordinate frame, this rotation matrix is applied after rotation matrix $R^d(\theta_d,\phi_d)$ used to define the main coordinate frame. The full transformation for the rotated coordinate frame is then given by +% +\begin{align} + R'^d(\theta_d,\phi_d,\alpha,\beta,\gamma) &= D(\alpha,\beta,\gamma)R^d(\theta_d,\phi_d) +\end{align} + +Using this matrix, the \tikzname\ coordinate transformation can be applied as described in Section \ref{sec:tikzplotting} by the various matrix elements, as +% +\begin{align}\begin{split} + x' &= (R'^d_{1,1}, R'^d_{2,1})\\ + y' &= (R'^d_{1,2}, R'^d_{2,2})\\ + z' &= (R'^d_{1,3}, R'^d_{2,3}) +\end{split}\end{align} + +This coordinate transformation is accessible through \tdplot\ using the command \texttt{tdplotsetrotatedcoords}, as described in Chapter \ref{cha:using_tdplot}. + +\begin{figure}[h] + \begin{center} + \threedrotcoordsystem + \end{center} + \caption{The rotated coordinate frame $(x', y', z')$ displayed within the main coordinate frame $(x,y,z)$. Both are completely specified by user-defined angles: $(\theta_d, \phi_d)$ for the main coordinate frame, and $(\alpha, \beta, \gamma)$ for the rotated coordinate frame.} +\end{figure} + + +\section{Arcs in 3d, and the ``Theta Plane''} + +Arcs can be drawn in \tikzname\ using commands described in the PGF manual Version 2.00, section 2.10 on pages 25-26. However, the arc commands accept 2d coordinates, and thus can only be drawn in the $xy$ plane. + +To draw an arc in any position other than within the $xy$ plane of the main coordinate frame, the rotated coordinate frame must be used, where the $x'y'$ plane lies in the desired orientation within the main coordinate frame. Such an arc is needed, for example, when illustrating the polar angle $\theta$ of some vector. This $\theta$ arc exists in a plane which contains the $z$ axis, and is rotated about the $z$ axis by the angle $\phi$ from the $xz$ plane. For lack of a better name, this plane is referred to as the ``theta plane'' within a given coordinate system. + +\begin{figure}[h] + \begin{center} + \threedthetaarc + \end{center} + \caption{Drawing arcs outside the $xy$ plane by using a rotated coordinate frame in the ``theta plane'' of the main coordinate frame.} +\end{figure} + +As described in Chapter \ref{cha:using_tdplot}, \tdplot\ offers the commands \texttt{tdplotsetthetaplanecoords} and \texttt{tdplotsetrotatedthetaplanecoords} to easily configure the rotated coordinate frame to lie within the desired theta plane. + + + + + + + + +\chapter{Using the \tdplot\ Package} \label{cha:using_tdplot} + +The \tdplot\ package was developed to handle the number crunching described in Chapter \ref{cha:overview3d}, and provide a relatively simple and straightforward frontend for users. + +The main and rotated coordinate frames are configured by using commands described in Section \ref{sec:tdplotcommands}. These commands generate \tikzname\ styles which can be used either in defining the \texttt{tikzpicture} environment, or directly in any \tikzname\ command. The styles are described further in Section \ref{sec:tikzstyles}. + +\section{The \tdplot\ \tikzname\ Styles} \label{sec:tikzstyles} + + +\subsection{\texttt{tdplot\_main\_coords}} + +The \verb|tdplot_main_coords| style stores the coordinate transformation required to generate the main coordinate system. This style can either be used when the \texttt{tikzpicture} environment is started, or when an individual \tikzname\ plotting command is used. + +\subsection{\texttt{tdplot\_rotated\_coords}} + +The \verb|tdplot_rotated_coords| style stores the coordinate transformation (translation and rotation) required to generate the rotated coordinate system within the main coordinate system. This style can either be used when the \texttt{tikzpicture} environment is started, or when an individual \tikzname\ plotting command is used. + +\subsection{\texttt{tdplot\_screen\_coords}} + +The \verb|tdplot_screen_coords| style provides the standard, unrotated \tikzname\ coordinate frame. This is useful to escape out of the user-defined 3d coordinates used at the beginning of the \texttt{tikzpicture} environment, and place something on an absolute scale in the figure. Tables, legends, and captions contained within the same figure as a 3d plot can make use of this style. + +\section{The \tdplot\ Commands} \label{sec:tdplotcommands} + +This section lists the various commands provided by the \tdplot\ package. Examples are provided where it is useful. + +\subsection{Coordinate Configuration Commands} + +\subsubsection{\texttt{tdplotsetmaincoords}} + +\begin{description} + \item[Description:] Generates the style \verb|tdplot_main_coords| which provides the coordinate transformation for the main coordinate frame, based on a user-specified orientation $(\theta_d,\phi_d)$. $\theta_d$ denotes the rotation around the $x$ axis, while $\phi_d$ denotes the rotation around the $z$ axis. Note that $(0,0)$ is the default orientation, where $x$ points right, $y$ points up, and $z$ points ``out of the page''. + + \item[Syntax:] \verb|\tdplotsetmaincoords{| $\theta_d$ \verb|}{| $\phi_d$ \verb|}| + + \item[Parameters:]~ + \begin{description} + \item[$\theta_d$] The angle (in degrees) through which the coordinate frame is rotated about the $x$ axis. + \item[$\phi_d$] The angle (in degrees) through which the coordinate frame is rotated about the $z$ axis. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; +\end{tikzpicture} +\end{shaded} + +\end{description} + +\subsubsection{\texttt{tdplotsetrotatedcoords}} + +\begin{description} + \item[Description:] Generates the style \verb|tdplot_rotated_coords| which provides the coordinate transformation for rotated coordinate frame within the current main coordinate frame, based on user-specified Euler angles $(\alpha,\beta,\gamma)$. Rotations use the $z(\alpha)y(\beta)z(\gamma)$ convention of Euler rotations, where the system is rotated by $\gamma$ about the $z$ axis, then $\beta$ about the (world) $y$ axis, and then $\alpha$ about the (world) $z$ axis. + \item[Syntax:] \verb|\tdplotsetrotatedcoords{|$\alpha$\verb|}{|$\beta$\verb|}{|$\gamma$\verb|}| + \item[Parameters:]~ + \begin{description} + \item[$\alpha$] The angle (in degrees) through which the rotated frame is rotated about the world $z$ axis. + \item[$\beta$] The angle (in degrees) through which the rotated frame is rotated about the world $y$ axis. + \item[$\gamma$] The angle (in degrees) through which the rotated frame is rotated about the world $z$ axis. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{60}{40}{30} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (0,0,.7) node[anchor=south]{$z'$}; +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{60}{40}{30} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; +\end{tikzpicture} +\end{shaded} +\end{description} + + +\subsubsection{\texttt{tdplotsetrotatedcoordsorigin}} + +\begin{description} + \item[Description:] Sets the origin of the rotated coordinate system specified by \verb|tdplot_rotated_coords| using a user-defined point. This point can be either a literal or predefined point. + \item[Syntax:] \verb|\tdplotsetrotatedcoordsorigin{point}| + \item[Parameters:]~ + \begin{description} + \item[\texttt{point}] A point predefined using the \tikzname\ \verb|\coordinate| command. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{60}{40}{30} + + \coordinate (Shift) at (0.5,0.5,0.5); + \tdplotsetrotatedcoordsorigin{(Shift)} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- + (0,0,.7) node[anchor=south]{$z'$}; +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{60}{40}{30} + + \coordinate (Shift) at (0.5,0.5,0.5); + \tdplotsetrotatedcoordsorigin{(Shift)} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; +\end{tikzpicture} +\end{shaded} +\end{description} + +\subsubsection{\texttt{tdplotresetrotatedcoordsorigin}} + +\begin{description} + \item[Description:] Resets the origin of the rotated coordinate system back to the origin of the main coordinate system. + \item[Syntax:] \verb|\tdplotresetrotatedcoordsorigin| + \item[Parameters:] None +\end{description} + +\subsubsection{\texttt{tdplotsetthetaplanecoords}} + +\begin{description} + \item[Description:] Generates a rotated coordinate system such that the $x'y'$ plane is coplanar to a plane containing the polar angle $\theta$ projecting from the main coordinate system $z$ axis. This coordinate system is particularly useful for drawing within this ``theta plane'', as \tikzname\ draws arcs in the $xy$ plane. As with \texttt{tdplotsetrotatedcoords}, this coordinate system is accessible through the \verb|tdplot_rotated_coords| style. Note that any rotated coordinate frame offset previously set by \texttt{tdplotsetrotatedcoordsorigin} is automatically reset when this command is used. + \item[Syntax:] \verb|\tdplotsetthetaplanecoords{|$\phi$\verb|}| + \item[Parameters:]~ + \begin{description} + \item[$\phi$] The angle (in degrees) through which the ``theta plane'' makes with the $xz$ plane of the main coordinate system. + \end{description} + \item[Example:]~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{110} + +\begin{tikzpicture}[scale=3,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetcoord{P}{.8}{50}{70} + + %draw a vector from origin to point (P) + \draw[-stealth,color=red] (O) -- (P); + + %draw projection on xy plane, and a connecting line + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + + \tdplotsetthetaplanecoords{70} + + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (.2,0,0) node[anchor=east]{$x'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (0,.2,0) node[anchor=north]{$y'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (0,0,.2) node[anchor=west]{$z'$}; + +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{70}{110} + +\begin{tikzpicture}[scale=3,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetcoord{P}{.8}{50}{70} + + \coordinate (O) at (0,0,0); + + %draw a vector from origin to point (P) + \draw[-stealth,color=red] (O) -- (P); + + %draw projection on xy plane, and a connecting line + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + \tdplotsetthetaplanecoords{70} + + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (.2,0,0) node[anchor=east]{$x'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (0,.2,0) node[anchor=north]{$y'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) + -- (0,0,.2) node[anchor=west]{$z'$}; + +\end{tikzpicture} +\end{shaded} +\end{description} + + +\subsubsection{\texttt{tdplotsetrotatedthetaplanecoords}} + +\begin{description} + \item[Description:] Just like \texttt{tdplotsetthetaplanecoords}, except this works for the rotated coordinate system. Generates a rotated coordinate system such that the $x'-y'$ plane is coplanar to a plane containing the polar angle $\theta'$ projecting from the current rotated coordinate system $z'$ axis. Note that the current rotated coordinate system is overwritten by this theta plane coordinate system after the command is completed. + \item[Syntax:] \verb|\tdplotsetrotatedthetaplanecoords{|$\phi'$\verb|}| + \item[Parameters:]~ + \begin{description} + \item[$\phi'$] The angle (in degrees) through which the ``theta plane'' makes with the $x'-z'$ plane of the current rotated coordinate system. + \end{description} + \item[Example:]~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \coordinate (Shift) at (2,2,2); + + \tdplotsetrotatedcoords{-20}{10}{0} + \tdplotsetrotatedcoordsorigin{(Shift)} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (1,0,0) node[anchor=south east]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (0,1,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (0,0,1) node[anchor=south]{$z'$}; + + \tdplotsetrotatedthetaplanecoords{30} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (.5,0,0) node[anchor=south east]{$x''$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (0,.5,0) node[anchor=west]{$y''$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) + -- (0,0,.5) node[anchor=south]{$z''$}; +\end{tikzpicture} +\end{verbatim} +\ifpdf +\beginpgfgraphicnamed{Figures/exampleshowargcolorguide} +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \coordinate (Shift) at (2,2,2); + + \tdplotsetrotatedcoords{-20}{10}{0} + \tdplotsetrotatedcoordsorigin{(Shift)} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (1,0,0) node[anchor=south east]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z'$}; + + \tdplotsetrotatedthetaplanecoords{30} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=south east]{$x''$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=west]{$y''$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z''$}; +\end{tikzpicture} +\endpgfgraphicnamed +\fi +\end{shaded} + +\end{description} + + + +\subsection{Point Calculation Commands} + +\subsubsection{\texttt{tdplotsetcoord}} + +\begin{description} + \item[Description:] Generates a coordinate of specified name, along with coordinates for the $x-$, $y-$, $z-$, $xy-$, $xz-$, and $yz-$ projections of the coordinate, based on user-specified spherical coordinates. Note that this coordinate only works in the main coordinate system. All points in the rotated coordinate system must be specified as literal points. + \item[Syntax:] \verb|\tdplotsetcoord{point}{|$r$\verb|}{|$\theta$\verb|}{|$\phi$\verb|}| + \item[Parameters:]~ + \begin{description} + \item[\texttt{point}] The name of the point to be assigned. Note that the $()$ parentheses must be excluded. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{60}{130} +\begin{tikzpicture}[scale=2,tdplot_main_coords] + + \coordinate (O) at (0,0,0); + + \tdplotsetcoord{P}{.8}{55}{60} + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \draw[-stealth,color=red] (O) -- (P); + + \draw[dashed, color=red] (O) -- (Px); + \draw[dashed, color=red] (O) -- (Py); + \draw[dashed, color=red] (O) -- (Pz); + \draw[dashed, color=red] (Px) -- (Pxy); + \draw[dashed, color=red] (Py) -- (Pxy); + \draw[dashed, color=red] (Px) -- (Pxz); + \draw[dashed, color=red] (Pz) -- (Pxz); + \draw[dashed, color=red] (Py) -- (Pyz); + \draw[dashed, color=red] (Pz) -- (Pyz); + \draw[dashed, color=red] (Pxy) -- (P); + \draw[dashed, color=red] (Pxz) -- (P); + \draw[dashed, color=red] (Pyz) -- (P); +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{60}{130} +\begin{tikzpicture}[scale=2,tdplot_main_coords] + + \coordinate (O) at (0,0,0); + + \tdplotsetcoord{P}{.8}{55}{60} + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \draw[-stealth,color=red] (O) -- (P); + + \draw[dashed, color=red] (O) -- (Px); + \draw[dashed, color=red] (O) -- (Py); + \draw[dashed, color=red] (O) -- (Pz); + \draw[dashed, color=red] (Px) -- (Pxy); + \draw[dashed, color=red] (Py) -- (Pxy); + \draw[dashed, color=red] (Px) -- (Pxz); + \draw[dashed, color=red] (Pz) -- (Pxz); + \draw[dashed, color=red] (Py) -- (Pyz); + \draw[dashed, color=red] (Pz) -- (Pyz); + \draw[dashed, color=red] (Pxy) -- (P); + \draw[dashed, color=red] (Pxz) -- (P); + \draw[dashed, color=red] (Pyz) -- (P); +\end{tikzpicture} +\end{shaded} +\end{description} + +\subsection{Drawing Commands} + +Along with all the conventional \tikzname\ drawing commands, the following \tdplot\ commands can be used. + +\subsubsection{\texttt{tdplotdrawarc}} + +\begin{description} + \item[Description:] Draws an arc in the $xy$ (or optionally $x'y'$) plane starting from the specified polar angle $\phi$, of specified radius and angular length, at specified center point, and labels the arc with specified node text and options. By default, draws in the main coordinate frame, but can draw in the rotated coordinate frame by specifying \verb|tdplot_rotated_coords| in the option field. + \item[Syntax:] \verb|\tdplotdrawarc[coordinate system, draw styles]{center}{r}|\\\verb|{angle start}{angle end}{label options}{label}| + \item[Parameters:]~ + \begin{description} + \item[(\textit{Optional}) coordinate system,draw styles] Optional argument containing the name of the coordinate system to use (default is main coordinate system), and any optional draw styles. + \item[center] Center point through which to draw the arc. If using the rotated coordinate system, this must be a literal value. + \item[angle start] the initial angle (in degrees) through which to draw. 0 points along the $x$ (or $x'$) axis. + \item[angle end] the final angle (in degrees) through which to draw. + \item[label options] any style options for a \tikzname \verb|\node| object. If none, make sure to leave a blank delimiter \verb|{}| in its place. + \item[label] any text for the \tikzname\ \verb|\node| which appears at the center of the arc. If none, make sure to leave a blank delimiter \verb|{}| in its place. + \end{description} + \item[Example:]~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{60}{110} +% +\pgfmathsetmacro{\rvec}{.8} +\pgfmathsetmacro{\thetavec}{30} +\pgfmathsetmacro{\phivec}{60} +% +\begin{tikzpicture}[scale=5,tdplot_main_coords] + + \coordinate (O) at (0,0,0); + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec} + \draw[-stealth,color=red] (O) -- (P); + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + \tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$} + + \tdplotsetthetaplanecoords{\phivec} + + \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}% + {\thetavec}{anchor=south west}{$\theta$} + + \draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec); + \draw[dashed] (\rvec,0,0) arc (0:90:\rvec); + + \tdplotsetrotatedcoords{\phivec}{\thetavec}{0} + \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (.5,0,0) node[anchor=north west]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,.5,0) node[anchor=west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,0,.5) node[anchor=south]{$z'$}; + + \draw[-stealth,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,.2); + \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,0); + \draw[dashed,color=blue,tdplot_rotated_coords] (.2,.2,0) -- (.2,.2,.2); + + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}% + {45}{anchor=north west,color=black}{$\phi'$} + + \tdplotsetrotatedthetaplanecoords{45} + + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}% + {55}{anchor=south west,color=black}{$\theta'$} +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{60}{110} +% +\pgfmathsetmacro{\rvec}{.8} +\pgfmathsetmacro{\thetavec}{30} +\pgfmathsetmacro{\phivec}{60} +% +\begin{tikzpicture}[scale=5,tdplot_main_coords] + + \coordinate (O) at (0,0,0); + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec} + \draw[-stealth,color=red] (O) -- (P); + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + \tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$} + + \tdplotsetthetaplanecoords{\phivec} + + \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{anchor=south west}{$\theta$} + + \draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec); + \draw[dashed] (\rvec,0,0) arc (0:90:\rvec); + + \tdplotsetrotatedcoords{\phivec}{\thetavec}{0} + \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north west]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z'$}; + + \draw[-stealth,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,.2); + \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,0); + \draw[dashed,color=blue,tdplot_rotated_coords] (.2,.2,0) -- (.2,.2,.2); + + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{45}{anchor=north west,color=black}{$\phi'$} + + \tdplotsetrotatedthetaplanecoords{45} + + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{55}{anchor=south west,color=black}{$\theta'$} +\end{tikzpicture} +\end{shaded} +\end{description} + +%make more! +%\subsubsection{} + +%\begin{description} +% \item[Description:] +% \item[Syntax:] +% \item[Parameters:] +% \begin{description} +% \item[] +% \end{description} +%\end{description} + +\subsection{The \texttt{tdplotsphericalsurfaceplot} Command}\label{sec:spherical_surface_plot} + +The \verb|\tdplotsphericalsurfaceplot| command is quite complicated, and it seemed appropriate to occupy its own section. This command was developed to provide a method of rendering complex polar functions, $z = z(\theta,\phi)$, where the magnitude of the function is expressed by the radius, and the phase of the function is expressed by the hue. + +\begin{align}\begin{split} + r &= \left|z(\theta,\phi)\right|\\ + hue &= \mathrm{Arg}\left[z(\theta,\phi)\right] +\end{split}\end{align} + +\subsubsection{How \texttt{tdplotsphericalsurfaceplot} Works} + +To achieve the illusion of 3d surface with proper depth perception, the \tdplot\ package divides the drawing task into smaller sections. This division provides a cheap and dirty way of ensuring the surface on the far side of the viewing perspective is drawn first, ensuring proper opacity and object occlusion. + +For a given perspective assigned by the main coordinate frame, a ``view orientation'' can be defined, giving the angles $(\theta_{view},\phi_{view})$ that describe the orientation of the view. These angles determine how to dubdivide the surface rendering process. The following divisions are made: +% +\begin{itemize} + \item Divide the surface into ``front'' and ``back'', where the back is drawn before the front. + \item Subdivide into ``left'' and ``right'' + \item Subdivide further into ''top'' and ''bottom'' +\end{itemize} + +The entire back half is drawn before the front front half. For each half, the entire left or right side is drawn. For each side, the theta angles are drawn for each angle of phi. When on the back half, the theta angle is swept from $\theta_{view}$ toward the poles. When on the front half, the theta angle is swept from the poles toward $\theta_{view}$. + +To improve the illusion of proper depth perception, a set of commands can be specified to render the $x$, $y$, and $z$ axis. While drawing the surface, the user-specified instructions is performed at the appropriate time, ensuring the axes pass through the surface of the object in an expected manner. + + +\subsubsection{Using \texttt{tdplotsphericalsurfaceplot}} + +\begin{description} + \item[Description:] Draws a user-specified spherical polar function, with user-specified fill hues. Angular range to be displayed is specified with the \verb|\tdplotsetpolarplotrange| command. + \item[Syntax:] \verb|\tdplotsphericalsurfaceplot[fill color style]{theta steps}{phi steps}{function}|\\\verb|{line color}{fill color}{x axis}{y axis}{z axis}| + \item[Parameters:]~ + \begin{description} + \item[(\emph{Optional}) fill color style] Specifies whether \texttt{fill color} is a function of \verb|\tdplottheta| and \verb|\tdplotphi|, or a direct \tikzname\ color. Set to \texttt{parametricfill} to enable functional coloring. + \item[theta steps] The number of steps used to render the surface along the $\theta$ direction. For best results, this number should not be smaller than 12, and should be a factor of 360. + \item[phi steps] The number of steps used to render the surface along the $\phi$ direction. For best results, this number should not be smaller than 12, and should be a factor of 360. + \item[function] A mathematical expression, containing the variables \verb|\tdplottheta| and \verb|\tdplotphi|, used to define the radius of the surface for given angles. Note that the absolute value of the function is plotted. + \item[line color] \tikzname\ color expression for surface lines. + \item[fill color] When the option \textit{parametricfill} is used then this can be some mathematical expression containing \verb|\tdplottheta| and \verb|\tdplotphi|. If not, then this can be any \tikzname\ expression for color. Note that if the function specified by \texttt{function} is negative, a shift of 180 is applied to the color. Bonus points to anyone who can guess why I chose to do this! If you don't like it, then make sure \texttt{function} is always positive. + \item[x axis] Any draw commands used to render an $x$ axis. + \item[y axis] Any draw commands used to render an $y$ axis. + \item[z axis] Any draw commands used to render an $z$ axis. + \end{description} + \item[Example:]~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{135} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,% + fill opacity=.5] + +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{sin(\tdplottheta)*cos(\tdplottheta)}{black}{\tdplotphi}% + {\draw[color=black,thick,->] (0,0,0) + -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,% + fill opacity=.7] +\tdplotsphericalsurfaceplot{72}{24}% +{0.5*cos(\tdplottheta)^2}{black}{red!80!black}% + {\draw[color=black,thick,->] (0,0,0) + -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\end{verbatim} +\ifpdf +\beginpgfgraphicnamed{Figures/examplesurfaceplot} +\tdplotsetmaincoords{70}{135} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.5] + +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{sin(\tdplottheta)*cos(\tdplottheta)}{black}{\tdplotphi}% + {\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7] +\tdplotsphericalsurfaceplot{72}{24}% +{0.5*cos(\tdplottheta)^2}{black}{red!80!black}% + {\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\endpgfgraphicnamed +\fi +\end{shaded} +\end{description} + +\subsubsection{The \texttt{tdplotsetpolarplotrange} Command} + +\begin{description} + \item[Description:] Defines the range of angles to be displayed when using \verb|\tdplotsphericalsurfaceplot| + \item[Syntax:] \verb|\tdplotsetpolarplotrange{lowertheta}{uppertheta}{lowerphi}{upperphi}| + \item[Parameters:]~ + \begin{description} + \item[lowertheta] The lower limit for \verb|\tdplottheta|, in degrees. + \item[uppertheta] The upper limit for \verb|\tdplottheta|, in degrees. + \item[lowerphi] The lower limit for \verb|\tdplotphi|, in degrees. + \item[upperphi] The upper limit for \verb|\tdplotphi|, in degrees. + \end{description} + \item[Example:]~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,% + fill opacity=.5] + +\tdplotsetpolarplotrange{90}{180}{180}{360} +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{.5}{black}{\tdplotphi + 3*\tdplottheta}% + {\draw[color=black,thick,->] (0,0,0) + -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) + -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\end{verbatim} +\ifpdf +\beginpgfgraphicnamed{Figures/examplesurfaceplotrange} +\tdplotsetmaincoords{70}{135} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.5] + +\tdplotsetpolarplotrange{90}{180}{180}{360} +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{.5}{black}{\tdplotphi + 3*\tdplottheta}% + {\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}% +\end{tikzpicture} +\endpgfgraphicnamed +\fi +\end{shaded} +\end{description} + +\subsubsection{The \texttt{tdplotresetpolarplotrange} Command} + +\begin{description} + \item[Description:] Resets the range of angles to the default full range when using \verb|\tdplotsphericalsurfaceplot| + \item[Syntax:] \verb|\tdplotresetpolarplotrange| +\end{description} + +\subsubsection{The \texttt{tdplotshowargcolorguide} Command} + +\begin{description} + \item[Description:] Draws a color guide table which associates the hue of a parametric polar plot with an angle. Guide is drawn at user-specified coordinates with user-specified size. + \item[Syntax:] \verb|\tdplotshowargcolorguide{x position}{y position}{x size}{y size}| + \item[Parameters:]~ + \begin{description} + \item[x position] The x screen coordinate to place the lower-left corner of the guide. + \item[y position] The y screen coordinate to place the lower-left corner of the guide. + \item[x size] The width of the color guide. + \item[y size] The height of the color guide. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{40}{0} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,% + fill opacity=1] +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% + {sqrt(15/2)/2*sin(\tdplottheta)^2}{black}% + {2*\tdplotphi - 6 * \tdplottheta}{}{}{}% +\tdplotshowargcolorguide{3}{-.2}{.1}{1} +\end{tikzpicture} +\end{verbatim} +\ifpdf +\beginpgfgraphicnamed{Figures/exampleshowargcolorguide} +\tdplotsetmaincoords{40}{0} +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=1] +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{sqrt(15/2)/2*sin(\tdplottheta)^2}{black}{2*\tdplotphi - 6 * \tdplottheta}{}{}{}% +\tdplotshowargcolorguide{3}{-.2}{.1}{1} +\end{tikzpicture} +\endpgfgraphicnamed +\fi +\end{shaded} +\end{description} + +\subsection{Miscellaneous Math Commands} + +The following commands are used to streamline the \tdplot\ calculations in the background. There is generally no need to use these directly, but may be useful on their own for any desired calculations. + +\subsubsection{\texttt{tdplotsinandcos}} + +\begin{description} + \item[Description:] Determines the sine and cosine of the specified angle, and stores in specified macros. + \item[Syntax:] \verb|\tdplotsinandcos{sintheta}{costeta}{theta}| + \item[Parameters:]~ + \begin{description} + \item[\texttt{sintheta}] A macro (eg. \verb|\sintheta|) to store the sine of \texttt{theta}. + \item[\texttt{costheta}] A macro (eg. \verb|\costheta|) to store the cosine of \texttt{theta}. + \item[\texttt{theta}] An angle (in degrees) to calculate. Can be a macro or literal value. + \end{description} +\end{description} + +\subsubsection{\texttt{tdplotmult}} + +\begin{description} + \item[Description:] Determines the product of two specified values, and stores the result in the specified macro. + \item[Syntax:] \verb|\tdplotmult{result}{multiplicand}{multiplicator}| + \item[Parameters:]~ + \begin{description} + \item[\texttt{result}] A macro (eg. \verb|\result|) to store the product of \texttt{multiplicand * multiplicator}. + \item[\texttt{multiplicand}] The multiplicand of the product. Can be a macro or literal value. + \item[\texttt{multiplicator}] The multiplicator of the product. Can be a macro or literal value. + \end{description} +\end{description} + +\subsubsection{\texttt{tdplotdiv}} + +\begin{description} + \item[Description:] Determines the quotient of two specified values, and stores the result in the specified macro. + \item[Syntax:] \verb|\tdplotdiv{result}{dividend}{divisor}| + \item[Parameters:]~ + \begin{description} + \item[\texttt{result}] A macro (eg. \verb|\result|) to store the quotient of \texttt{dividend / divisor}. + \item[\texttt{dividend}] The dividend of the quotient. Can be a macro or literal value. + \item[\texttt{divisor}] The divisor of the quotient. Can be a macro or literal value. + \end{description} +\end{description} + +\chapter{Known Issues} + +There are various issues that have been found while developing the \tdplot\ package. Some of these are currently open problems which will hopefully be resolved. Feedback and suggestions are welcome. + +\section{Predefined Points Don't Work in Rotated Frame} + +When a coordinate is defined using the \tikzname\ command \verb|\coordinate|, it will be transformed by the transformation specified at the beginning of the \texttt{tikzpicture} environment. These coordinates will not work for transformations applied at the actual \verb|\draw| command. + +This problem seems to be inherant with \tikzname\ itself. By way of example, the following code is taken right from the PGF manual Version 2.00, section 21.2 on page 218: + +\begin{shaded} +\begin{verbatim} +Case A: +%this one works fine using literal coordinates +\begin{tikzpicture}[smooth] + \draw plot coordinates{(1,0)(2,0.5)(3,0)(3,1)}; + \draw[x={(0cm,1cm)},y={(1cm,0cm)},color=red] + plot coordinates{(1,0)(2,0.5)(3,0)(3,1)}; +\end{tikzpicture} + +Two distinct paths shown. All is good. + +Case B: +%this one does not work using predefined coordinates +\begin{tikzpicture}[smooth] + \coordinate (A) at (1,0); + \coordinate (B) at (2,0.5); + \coordinate (C) at (3,0); + \coordinate (D) at (3,1); + \draw plot coordinates{(A)(B)(C)(D)}; + \draw[x={(0cm,1cm)},y={(1cm,0cm)},color=red] plot coordinates{(A)(B)(C)(D)}; +\end{tikzpicture} + +Both paths draw overtop each other, and the coordinates are not transformed! +\end{verbatim} + +Case A: +%this one works fine using literal coordinates +\begin{tikzpicture}[smooth] + \draw plot coordinates{(1,0)(2,0.5)(3,0)(3,1)}; + \draw[x={(0cm,1cm)},y={(1cm,0cm)},color=red] plot coordinates{(1,0)(2,0.5)(3,0)(3,1)}; +\end{tikzpicture} + +Two distinct paths shown. All is good. + +Case B: +%this one does not work using predefined coordinates +\begin{tikzpicture}[smooth] + \coordinate (A) at (1,0); + \coordinate (B) at (2,0.5); + \coordinate (C) at (3,0); + \coordinate (D) at (3,1); + \draw plot coordinates{(A)(B)(C)(D)}; + \draw[x={(0cm,1cm)},y={(1cm,0cm)},color=red] plot coordinates{(A)(B)(C)(D)}; +\end{tikzpicture} + +Both paths draw overtop each other, and the coordinates are not transformed! +\end{shaded} + + +\section{\texttt{node} Command and \texttt{shift=(P)} Issues} + +When placing a node in a shifted coordinate frame, the \verb|\node| command will not position properly. As a workaround, the \verb|\draw| command must be used to position the node. By way of example. +\begin{shaded} +\begin{verbatim} +Case A: +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \coordinate (P) at (3,3,3); + \tdplotsetrotatedcoords{0}{0}{0} + \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (.5,0,0) node[anchor=north]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,.5,0) node[anchor=south west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,0,.5) node[anchor=south east]{$z'$}; + + \node[tdplot_rotated_coords] at (30:.5){$\theta_{bad}$}; + \draw[tdplot_rotated_coords] (0,0,0) + (30:.5) node{$\theta_{good}$}; +\end{tikzpicture} + +Here, the rotated coordinate frame is shifted by amount (P) within the main% +coordinate frame. The node labelled $\theta_{bad}$ does not accept any% +positioning coordinates. + +Case B: +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + +% \coordinate (P) at (3,3,3); + \tdplotsetrotatedcoords{0}{0}{0} +% \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (.5,0,0) node[anchor=north]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,.5,0) node[anchor=south west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) + -- (0,0,.5) node[anchor=south east]{$z'$}; + + \node[tdplot_rotated_coords] at (30:.5){$\theta_{bad}$}; + \draw[tdplot_rotated_coords] (0,0,0) + (30:.5) node{$\theta_{good}$}; +\end{tikzpicture} + +Here, the shift is removed from the rotated coordinate frame. The % +previously failing \verb|\node| command works properly. +\end{verbatim} +Case A: +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \coordinate (P) at (3,3,3); + \tdplotsetrotatedcoords{0}{0}{0} + \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=south west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south east]{$z'$}; + + \node[tdplot_rotated_coords] at (30:.5){$\theta_{bad}$}; + \draw[tdplot_rotated_coords] (0,0,0) + (30:.5) node{$\theta_{good}$}; +\end{tikzpicture} + +Here, the rotated coordinate frame is shifted by amount (P) within the main coordinate frame. The node labelled $\theta_{bad}$ does not accept any positioning coordinates. + +Case B: +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[scale=3,tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + +% \coordinate (P) at (3,3,3); + \tdplotsetrotatedcoords{0}{0}{0} +% \tdplotsetrotatedcoordsorigin{(P)} + + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=south west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south east]{$z'$}; + + \node[tdplot_rotated_coords] at (30:.5){$\theta_{bad}$}; + \draw[tdplot_rotated_coords] (0,0,0) + (30:.5) node{$\theta_{good}$}; +\end{tikzpicture} + +Here, the shift is removed from the rotated coordinate frame. The previously failing \verb|\node| command works properly. +\end{shaded} + +\section{PGF \texttt{xyz spherical} Coordinate System} + +I have recently heard about the \texttt{xyz spherical} coordinate system offered by PGF. Unfortunately, when I try to use it, I get compile errors. I haven't spent much time looking into it though, so I'm probably just doing something silly. +\begin{shaded} +\begin{verbatim} +\draw[-stealth,color=orange] (0,0,0) + -- (xyz spherical cs:radius=.5,longitude=60,latitude=120); +%this gives the following compile error using MikTeX 2.8: +% Undefined control sequence. <argument> \tikz@cs@radius. +\end{verbatim} +\end{shaded} + +\chapter{TODO list} + +This chapter contains notes and jots of ideas of things to do which can expand or improve the \tdplot package. + +\begin{itemize} + \item Figure out how to work in a variable scope that doesn't interfere with other packages + \item Find a way to check if TikZ is loaded, and give a compile error if necessary + \item Find a way to use predefined coordinates in rotated or translated coordinate frames, instead of just literal coordinates + \item Generalize matrix math if such a package exists + \item Look into using TikZ spherical polar coordinates explicitly to streamline coordinate definitions +\end{itemize} + + + + + + + +\end{document} diff --git a/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation_figures.tex b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation_figures.tex new file mode 100644 index 00000000000..00f95a5c8f5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation_figures.tex @@ -0,0 +1,296 @@ +\newcommand{\tdplotmainfig}{% +\ifpdf +%Angle Definitions +%----------------- +% +%set the plot display orientation +%synatax: \tdplotsetdisplay{\theta_d}{\phi_d} +\tdplotsetmaincoords{60}{110} +% +%define polar coordinates for some vector +%TODO: look into using 3d spherical coordinate system +\pgfmathsetmacro{\rvec}{.8} +\pgfmathsetmacro{\thetavec}{30} +\pgfmathsetmacro{\phivec}{60} +% +%start tikz picture, and use the tdplot_main_coords style to implement the display coordinate transformation provided by 3dplot +\begin{tikzpicture}[scale=3,tdplot_main_coords] + + %set up some coordinates + %----------------------- + \coordinate (O) at (0,0,0); + + %determine a coordinate (P) using (r,\theta,\phi) coordinates. This command also determines (Pxy), (Pxz), and (Pyz): the xy-, xz-, and yz-projections of the point (P). + %synatax: \tdplotsetcoord{Coordinate name without parentheses}{r}{\theta}{\phi} + \tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec} + + %draw figure contents + %-------------------- + + %draw the main coordinate system axes + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + %draw a vector from origin to point (P) + \draw[-stealth,color=red] (O) -- (P); + + %draw projection on xy plane, and a connecting line + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + %draw the angle \phi, and label it + %syntax: \tdplotdrawarc[coordinate frame, draw options]{center point}{r}{angle}{label options}{label} + \tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$} + + + %set the rotated coordinate system so the x'-y' plane lies within the "theta plane" of the main coordinate system + %syntax: \tdplotsetthetaplanecoords{\phi} + \tdplotsetthetaplanecoords{\phivec} + + %draw theta arc and label, using rotated coordinate system + \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{anchor=south west}{$\theta$} + + %draw some dashed arcs, demonstrating direct arc drawing + \draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec); + \draw[dashed] (\rvec,0,0) arc (0:90:\rvec); + + %set the rotated coordinate definition within display using a translation coordinate and Euler angles in the "z(\alpha)y(\beta)z(\gamma)" euler rotation convention + %syntax: \tdplotsetrotatedcoords{\alpha}{\beta}{\gamma} + \tdplotsetrotatedcoords{\phivec}{\thetavec}{0} + + %translate the rotated coordinate system + %syntax: \tdplotsetrotatedcoordsorigin{point} + \tdplotsetrotatedcoordsorigin{(P)} + + %use the tdplot_rotated_coords style to work in the rotated, translated coordinate frame + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north west]{$x'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=west]{$y'$}; + \draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z'$}; + + %WARNING: coordinates defined by the \coordinate command (eg. (O), (P), etc.) cannot be used in rotated coordinate frames. Use only literal coordinates. + + %draw some vector, and its projection, in the rotated coordinate frame + \draw[-stealth,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,.2); + \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,0); + \draw[dashed,color=blue,tdplot_rotated_coords] (.2,.2,0) -- (.2,.2,.2); + + %show its phi arc and label + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{45}{anchor=north west,color=black}{$\phi'$} + + %change the rotated coordinate frame so that it lies in its theta plane. Note that this overwrites the original rotated coordinate frame + %syntax: \tdplotsetrotatedthetaplanecoords{\phi'} + \tdplotsetrotatedthetaplanecoords{45} + + %draw theta arc and label + \tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{55}{anchor=south west,color=black}{$\theta'$} + +\end{tikzpicture} +\fi +} + +\newcommand{\threedcoord}[2]{% +\ifpdf +\tdplotsetmaincoords{#1}{#2} +\begin{tikzpicture}[tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; +\end{tikzpicture} +\fi +} + +\newcommand{\threedrotcoordsystem}{% +\ifpdf +\tdplotsetmaincoords{50}{140} +\begin{tikzpicture}[scale=5,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{34}{26}{12} + + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north east]{$x'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=north west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z'$}; + +\end{tikzpicture} +\fi +} + +\newcommand{\threedconventions}{% +\ifpdf +\tdplotsetmaincoords{50}{110} +\begin{tikzpicture}[scale=2,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \draw[color=blue] (0,0,0) -- (.5,.5,0); + + \draw[color=blue,->] (.5,0,0) arc (0:45:.5); +\end{tikzpicture} +\fi +} + + +\newcommand{\threedalphabetagamma}{% +\ifpdf +\tdplotsetmaincoords{50}{140} +% +\begin{tikzpicture}[scale=2,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{0}{0}{30} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=west]{$z'$}; + + \tdplotdrawarc[color=orange!50!black]{(0,0,0)}{.4}{0}{30}{anchor=north east}{$\gamma$} +\end{tikzpicture} +% +\begin{tikzpicture}[scale=2,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{0}{0}{30} + + \draw[dashed,color=red,tdplot_rotated_coords] (0,0,0) -- (.5,0,0); + \draw[dashed,color=green!50!black,tdplot_rotated_coords] (0,0,0) -- (0,.5,0); + \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (0,0,.5); + + \tdplotsetrotatedcoords{0}{40}{30} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; + + \tdplotsetthetaplanecoords{0} + \tdplotdrawarc[tdplot_rotated_coords,color=orange!50!black]{(0,0,0)}{.4}{0}{40}{anchor=south}{$\beta$} + +\end{tikzpicture} +% +\begin{tikzpicture}[scale=2,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetrotatedcoords{0}{40}{30} + + \draw[dashed,color=red,tdplot_rotated_coords] (0,0,0) -- (.5,0,0); + \draw[dashed,color=green!50!black,tdplot_rotated_coords] (0,0,0) -- (0,.5,0); + \draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (0,0,.5); + + \tdplotsetrotatedcoords{60}{0}{0} + \draw[dotted,color=blue,tdplot_rotated_coords] (0,0,0) -- (.4,0,0); + \tdplotsetrotatedcoords{60}{40}{30} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; + \draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; + \draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; + + + \tdplotdrawarc[color=orange!50!black]{(0,0,0)}{.2}{0}{60}{anchor=north east}{$\alpha$} +\end{tikzpicture} +\fi +} + +\newcommand{\threedthetaarc}{% +\ifpdf +% +\tdplotsetmaincoords{70}{110} +% +\begin{tikzpicture}[scale=5,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \tdplotsetcoord{P}{.8}{50}{70} + + %draw a vector from origin to point (P) + \draw[-stealth,color=red] (O) -- (P); + + %draw projection on xy plane, and a connecting line + \draw[dashed, color=red] (O) -- (Pxy); + \draw[dashed, color=red] (P) -- (Pxy); + + + \tdplotsetthetaplanecoords{70} + + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (.2,0,0) node[anchor=east]{$x'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,.2,0) node[anchor=north]{$y'$}; + \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,0,.2) node[anchor=west]{$z'$}; + + + \tdplotdrawarc[tdplot_rotated_coords,color=orange!50!black]{(0,0,0)}{.4}{0}{50}{anchor=north east}{$\theta$} +\end{tikzpicture} +\fi +} + +\newcommand{\threedparamplot}{% +\ifpdf +% +\beginpgfgraphicnamed{Figures/threedparamplot} +\tdplotsetmaincoords{70}{110} +% +\begin{tikzpicture}[scale=2,tdplot_main_coords] + \draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; + + \pgfplothandlerlineto + \pgfplotfunction{\thetaen}{0,6,...,360}{% + \pgfpointxyz{cos(\thetaen)}% + {sin(\thetaen)}% + {\thetaen/400} + } + \pgfusepath{stroke} + +\end{tikzpicture} +\endpgfgraphicnamed +\fi +} + +\newcommand{\threedsurfaceplot}{% +\ifpdf +\beginpgfgraphicnamed{Figures/threedsurfaceplot} +% +\tdplotsetmaincoords{70}{135} +% +\begin{tikzpicture}[scale=3,line join=bevel,tdplot_main_coords, fill opacity=.6] + +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +%{0.3}{black}{red}% +%{0.5*sin(\tdplottheta)*sin(\tdplottheta)}{black}{red}% +%{0.5*sin(\tdplottheta)*sin(\tdplottheta)*sin(\tdplotphi)*sin(\tdplotphi)}{black}{red}% +%{0.5*cos(\tdplottheta)*cos(\tdplottheta)}{black}{red}% +%{0.25*cos(\tdplottheta)}{black}{red}% +{(sin(\tdplottheta)*cos(\tdplottheta))}{black}{\tdplotphi}% +%{ .15*(3*cos(\tdplottheta)*cos(\tdplottheta) - 1 )^2}{black}{\tdplotphi} + {\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}% + {\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}% + +\end{tikzpicture} +\endpgfgraphicnamed +\fi +} + +\newcommand{\colortest}{% +\ifpdf +\begin{tikzpicture} + \foreach \thetawheel in {0,1,...,360} + { + %\tdplotcalcrgb{\thetawheel} + \pgfmathdivide{\thetawheel}{360} + \definecolor{tdplotcolor}{hsb}{\pgfmathresult, 1, 1} + \color{tdplotcolor} + \filldraw(\thetawheel:3) circle (1pt); + } +\end{tikzpicture} +\fi +} |