diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf | bin | 332169 -> 448058 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex | 688 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-3dplot/tikz-3dplot.sty | 320 |
4 files changed, 893 insertions, 117 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-3dplot/README b/Master/texmf-dist/doc/latex/tikz-3dplot/README index 4350ec4e649..7a33bf2fef7 100644 --- a/Master/texmf-dist/doc/latex/tikz-3dplot/README +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/README @@ -4,4 +4,4 @@ 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. +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 tikz-3dplot package can also handle 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 differindex e1ffb016f47..67ed20860be 100644 --- a/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.pdf +++ 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 index 55cdf2ad083..99b10cfd89e 100644 --- a/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex +++ b/Master/texmf-dist/doc/latex/tikz-3dplot/tikz-3dplot_documentation.tex @@ -20,7 +20,7 @@ %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 +%Created 2009-11-07 by Jeff Hein. Last updated: 2010-01-24 %---------------------------------------------------------- %Requirements @@ -39,7 +39,7 @@ \usepackage{tikz-3dplot} %for tikz-3dplot functionality \usepackage{amsmath} %for align equation environment \usepackage{url} -%\usepackage{hyperref} +\usepackage{hyperref} \pgfrealjobname{tikz-3dplot_documentation} @@ -67,6 +67,7 @@ \maxtocdepth{subsection} +\newif\ifscratch %for doing scratchpad work, this cuts out the rest of the document @@ -91,6 +92,15 @@ \begin{document} +\input{Scratchpad.tex} + + + +\ifscratch + \end{document} +\fi + + \frontmatter \pagestyle{empty} @@ -118,11 +128,13 @@ \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. + \item[2010-01-20] Added the following commands: \verb|\tdplotgetpolarcoords|, \verb|\tdplotcrossprod|, \verb|\tdplotcalctransformrotmain|, \verb|\tdplotcalctransformmainrot|, \verb|\tdplottransformrotmain|, \verb|\tdplottransformmainrot|, and \verb|\tdplotdrawpolytopearc|. + \item[2010-01-24] Added the ability to hue 3d polar plots based on radius using the \verb|\tdplotr| macro. \end{description} \vfill \parindent=0pt - Copyright 2009 by Jeff Hein + Copyright 2010 Jeff Hein \medskip Permission is granted to distribute and/or modify \emph{both @@ -182,6 +194,8 @@ \mainmatter +\pagestyle{plain} + \chapter{Introduction}\label{cha:intro} \section{Overview of the \tdplot\ Package} @@ -193,9 +207,11 @@ This document describes the basics of the \tdplot\ package and provides informat \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}. +Various plotting commands are used to itentify coordinate locations using spherical polar or cartesian coordinates. Coordinate transformation commands allow for the calculation of a coordinate in one frame based on its values in another frame. Some drawing commands have been developed to assist in the rendering of arcs. These commands do the number crunching required to position and render the arcs. These commands are discussed in Section \ref{sec:tdplotcommands}. -\begin{figure}[h] +In addition, the \verb|\tdplotsphericalsurfaceplot| was developed to render three-dimensional surfaces in spherical polar coordinates, where the radius is expressed in terms of a user-defined function of $\theta$ and $\phi$. With this function, the surface hue can be given explicitly, or expressed as a user-defined function of $r$, $\theta$, and $\phi$. This command is discussed in Section \ref{sec:spherical_surface_plot}. + +\begin{figure}[ht] \begin{center} \threedconventions \end{center} @@ -418,7 +434,7 @@ This rotation matrix $D(\alpha,\beta,\gamma)$ is given by 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\\ + \cos\alpha\cos\beta\cos\gamma - \sin\alpha\sin\gamma & -\cos\alpha\cos\beta\sin\gamma - \sin\alpha\cos\gamma & \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} @@ -491,13 +507,65 @@ The \verb|tdplot_rotated_coords| style stores the coordinate transformation (tra 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\ Macros} \label{sec:tdplotmacros} +% +%\tdplot\ uses various macros to perform all its number crunching. Some of these are only used ``under the hood'', where the user would never need to know about them, while others are required to pass numbers to, or receive results from, the \tdplot\ commands. +% +%Since my knowledge of LaTeX is limited, there is probably a more streamlined and efficient way I can handle all this. As such, feedback and suggestions are welcome. +% +%\subsection{``Input'' Macros} +% +%These macros must be defined by the user before calling the corresponding command. In some cases, they are defined explicitly by another command, as described in the following section. +% +%\begin{center} +% \begin{tabular}{c p{4in}} +% \hline +% \textbf{Macro} & \textbf{Notes}\\ +% \hline +% +% \hline +% \end{tabular} +%\end{center} +% +%\subsection{''Output'' Macros} +% +%These macros are defined as a result of calling a command. These can either be used directly by the user, or by subsequent \tdplot\ commands. +% +%\begin{center} +% \begin{tabular}{c p{4in}} +% \hline +% \textbf{Macro} & \textbf{Notes}\\ +% \hline +% \verb|\tdplotresx| & Result x value +% +% \hline +% \end{tabular} +%\end{center} +% +%\subsection{``Under the Hood'' Macros} +% +%These are macros which are not necessary to know about. They are used so \tdplot\ can perform its task, and are not used outside the commands. +% +%\begin{center} +% \begin{tabular}{c p{4in}} +% \hline +% \textbf{Macro} & \textbf{Notes}\\ +% \hline +% \verb|\lowerphi| & Lower $\phi$ limit for \verb|\tdplotsphericalsurfaceplot| polar plot.\\ +% \verb|\upperphi| & Upper $\phi$ limit for \verb|\tdplotsphericalsurfaceplot| polar plot.\\ +% \verb|\lowertheta| & Lower $\theta$ limit for \verb|\tdplotsphericalsurfaceplot| polar plot.\\ +% \verb|\uppertheta| & Upper $\theta$ limit for \verb|\tdplotsphericalsurfaceplot| polar plot.\\ +% \hline +% \end{tabular} +%\end{center} + \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} +\section{Coordinate Configuration Commands} -\subsubsection{\texttt{tdplotsetmaincoords}} +\subsection{\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''. @@ -529,7 +597,7 @@ This section lists the various commands provided by the \tdplot\ package. Examp \end{description} -\subsubsection{\texttt{tdplotsetrotatedcoords}} +\subsection{\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. @@ -575,7 +643,7 @@ This section lists the various commands provided by the \tdplot\ package. Examp \end{description} -\subsubsection{\texttt{tdplotsetrotatedcoordsorigin}} +\subsection{\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. @@ -624,7 +692,7 @@ This section lists the various commands provided by the \tdplot\ package. Examp \end{shaded} \end{description} -\subsubsection{\texttt{tdplotresetrotatedcoordsorigin}} +\subsection{\texttt{tdplotresetrotatedcoordsorigin}} \begin{description} \item[Description:] Resets the origin of the rotated coordinate system back to the origin of the main coordinate system. @@ -632,7 +700,7 @@ This section lists the various commands provided by the \tdplot\ package. Examp \item[Parameters:] None \end{description} -\subsubsection{\texttt{tdplotsetthetaplanecoords}} +\subsection{\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. @@ -704,7 +772,7 @@ This section lists the various commands provided by the \tdplot\ package. Examp \end{description} -\subsubsection{\texttt{tdplotsetrotatedthetaplanecoords}} +\subsection{\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. @@ -745,7 +813,6 @@ This section lists the various commands provided by the \tdplot\ package. Examp \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$}; @@ -767,24 +834,37 @@ This section lists the various commands provided by the \tdplot\ package. Examp \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{\texttt{tdplotcalctransformmainrot}} + +\begin{description} + \item[Description:] Calculates the rotation matrix used to transform a coordinate from the main coordinate frame to the rotated coordinate frame. The matrix elements are stored in the macros \verb|\raaeul| through \verb|\rcceul|. This transformation is accessed using \verb|\tdplottransformmainrot|. +\end{description} + +\subsection{\texttt{tdplotcalctransformrotmain}} + +\begin{description} + \item[Description:] Calculates the rotation matrix used to define the rotated coordinate frame, as well as transform a coordinate from the rotated coordinate frame to the main coordinate frame. The matrix elements are stored in the macros \verb|\raaeul| through \verb|\rcceul|. This transformation is used in the \verb|\tdplotsetrotatedcoords| command, and is accessed using \verb|\tdplottransformrotmain|. +\end{description} -\subsection{Point Calculation Commands} +\section{Point Calculation Commands} -\subsubsection{\texttt{tdplotsetcoord}} +\subsection{\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[Description:] Generates a TikZ 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. + \item[\texttt{point}] The name of the TikZ coordinate to be assigned. Note that the $()$ parentheses must be excluded. + \item[$r$] Point radius. + \item[$\theta$] Point polar angle. + \item[$\phi$] Point azimuthal angle. \end{description} \item[Example:] ~ \begin{shaded} @@ -845,11 +925,379 @@ This section lists the various commands provided by the \tdplot\ package. Examp \end{shaded} \end{description} -\subsection{Drawing Commands} + +\subsection{\texttt{tdplottransformmainrot}} + +\begin{description} + \item[Description:] Transforms a coordinate from the main coordinate frame to the rotated coordinate frame. This command cannot use a \tikzname\ coordinate, and does not account for a shifted rotated coordinate frame. The results are stored in the \verb|\tdplotresx|, \verb|\tdplotresy|, and \verb|\tdplotresz| macros. + \item[Syntax:] \verb|\tdplottransformmainrot{x}{y}{z}| + \item[Parameters:]~ + \begin{description} + \item[x] The x-component of the coordinate in the main coordinate frame. + \item[y] The y-component of the coordinate in the main coordinate frame. + \item[z] The z-component of the coordinate in the main coordinate frame. + \end{description} + \item[Output:] The following macros are assigned: + \begin{description} + \item[\texttt{tdplotresx}] The transformed coordinate x component in the rotated coordinate frame. + \item[\texttt{tdplotresy}] The transformed coordinate y component in the rotated coordinate frame. + \item[\texttt{tdplotresz}] The transformed coordinate z component in the rotated coordinate frame. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\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$}; + + \pgfmathsetmacro{\ax}{2} + \pgfmathsetmacro{\ay}{2} + \pgfmathsetmacro{\az}{1} + + \tdplotsetrotatedcoords{20}{40}{00} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) + -- (.7,0,0) node[anchor=east]{$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'$}; + + + \tdplottransformmainrot{\ax}{\ay}{\az} + + \draw[tdplot_rotated_coords,->,blue!50] (0,0,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); + + \node[tdplot_main_coords,anchor=south] + at (\ax,\ay,\az){Main coords: (\ax, \ay, \az)}; + \node[tdplot_rotated_coords,anchor=north] + at (\tdplotresx,\tdplotresy,\tdplotresz) + {Rotated coords: (\tdplotresx, \tdplotresy, \tdplotresz)}; + +\end{tikzpicture} +\end{verbatim} +\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$}; + + \pgfmathsetmacro{\ax}{2} + \pgfmathsetmacro{\ay}{2} + \pgfmathsetmacro{\az}{1} + + \tdplotsetrotatedcoords{20}{40}{00} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) + -- (.7,0,0) node[anchor=east]{$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'$}; + + + \tdplottransformmainrot{\ax}{\ay}{\az} + + \draw[tdplot_rotated_coords,->,blue!50] (0,0,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); + + \node[tdplot_main_coords,anchor=south] + at (\ax,\ay,\az){Main coords: (\ax, \ay, \az)}; + \node[tdplot_rotated_coords,anchor=north] + at (\tdplotresx,\tdplotresy,\tdplotresz) + {Rotated coords: (\tdplotresx, \tdplotresy, \tdplotresz)}; + +\end{tikzpicture} +\end{shaded} +\end{description} + + +\subsection{\texttt{tdplottransformrotmain}} + +\begin{description} + \item[Description:] Transforms a coordinate from the rotated coordinate frame to the main coordinate frame. This command cannot use a \tikzname\ coordinate, and does not account for a shifted rotated coordinate frame. The results are stored in the \verb|\tdplotresx|, \verb|\tdplotresy|, and \verb|\tdplotresz| macros. + \item[Syntax:] \verb|\tdplottransformrotmain{x}{y}{z}| + \item[Parameters:]~ + \begin{description} + \item[x] The x-component of the coordinate in the rotated coordinate frame. + \item[y] The y-component of the coordinate in the rotated coordinate frame. + \item[z] The z-component of the coordinate in the rotated coordinate frame. + \end{description} + \item[Output:] The following macros are assigned: + \begin{description} + \item[\texttt{tdplotresx}] The transformed coordinate x component in the main coordinate frame. + \item[\texttt{tdplotresy}] The transformed coordinate y component in the main coordinate frame. + \item[\texttt{tdplotresz}] The transformed coordinate z component in the main coordinate frame. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\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$}; + + \pgfmathsetmacro{\ax}{-.75} + \pgfmathsetmacro{\ay}{2.5} + \pgfmathsetmacro{\az}{0} + + \tdplotsetrotatedcoords{20}{40}{00} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) + -- (.7,0,0) node[anchor=east]{$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'$}; + + + \tdplottransformrotmain{\ax}{\ay}{\az} + + \draw[tdplot_main_coords,->,blue!50] (0,0,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); + + \node[tdplot_rotated_coords,anchor=north] + at (\ax,\ay,\az){Rotated coords: (\ax, \ay, \az)}; + \node[tdplot_main_coords,anchor=south] + at (\tdplotresx,\tdplotresy,\tdplotresz) + {Main coords: (\tdplotresx, \tdplotresy, \tdplotresz)}; + + +\end{tikzpicture} +\end{verbatim} +\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$}; + + \pgfmathsetmacro{\ax}{-.75} + \pgfmathsetmacro{\ay}{2.5} + \pgfmathsetmacro{\az}{0} + + \tdplotsetrotatedcoords{20}{40}{00} + + \draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) + -- (.7,0,0) node[anchor=east]{$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'$}; + + + \tdplottransformrotmain{\ax}{\ay}{\az} + + \draw[tdplot_main_coords,->,blue!50] (0,0,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); + + \node[tdplot_rotated_coords,anchor=north] + at (\ax,\ay,\az){Rotated coords: (\ax, \ay, \az)}; + \node[tdplot_main_coords,anchor=south] + at (\tdplotresx,\tdplotresy,\tdplotresz) + {Main coords: (\tdplotresx, \tdplotresy, \tdplotresz)}; + + +\end{tikzpicture} +\end{shaded} +\end{description} + + +\subsection{\texttt{tdplotgetpolarcoords}} + +\begin{description} + \item[Description:] Calculates the $\theta$ polar coordinate for the specified point. The result is specified in the \verb|\tdplotrestheta| macro. + \item[Syntax:] \verb|\tdplotgetpolarcoords{x}{y}{z}| + \item[Parameters:]~ + \begin{description} + \item[x] The x-component of the coordinate. + \item[y] The y-component of the coordinate. + \item[z] The z-component of the coordinate. + \end{description} + \item[Output:] + \begin{description} + \item[\texttt{tdplotrestheta}] The $\theta$ polar coordinate. + \item[\texttt{tdplotresphi}] The $\phi$ polar coordinate. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$}; + + \pgfmathsetmacro{\ax}{1} + \pgfmathsetmacro{\ay}{1} + \pgfmathsetmacro{\az}{1} + + \draw[->,red] (0,0,0) -- (\ax,\ay,\az); + + \draw[dashed,red] (0,0,0) -- (\ax,\ay,0) -- (\ax,\ay,\az); + + \tdplotgetpolarcoords{\ax}{\ay}{\az} + + \tdplotsetthetaplanecoords{\tdplotresphi} + + \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{1}{0}% + {\tdplotrestheta}{anchor=west}{$\theta = \tdplotrestheta$} +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{70}{110} +\begin{tikzpicture}[tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$}; + + \pgfmathsetmacro{\ax}{1} + \pgfmathsetmacro{\ay}{1} + \pgfmathsetmacro{\az}{1} + + \draw[->,red] (0,0,0) -- (\ax,\ay,\az); + + \draw[dashed,red] (0,0,0) -- (\ax,\ay,0) -- (\ax,\ay,\az); + + \tdplotgetpolarcoords{\ax}{\ay}{\az} + + \tdplotdrawarc{(0,0,0)}{1}{0}% + {\tdplotresphi}{anchor=north}{$\phi = \tdplotresphi$} + + \tdplotsetthetaplanecoords{\tdplotresphi} + + \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{1}{0}% + {\tdplotrestheta}{anchor=west}{$\theta = \tdplotrestheta$} +\end{tikzpicture} +\end{shaded} +\end{description} + + +\subsection{\texttt{tdplotcrossprod}} + +\begin{description} + \item[Description:] Calculates the cross product of two vectors specified by two coordinates with respect to the origin. The result vector is specified by the coordinates \verb|\tdplotresx|, \verb|\tdplotresy|, and \verb|\tdplotresz| with respect to the origin. + \item[Syntax:] \verb|\tdplotcrossprod(|$a_x$\verb|,|$a_y$\verb|,|$a_z$\verb|)(|$b_x$\verb|,|$b_y$\verb|,|$b_z$\verb|)| + \item[Parameters:]~ + \begin{description} + \item[$a_x$] The x-component of the first vector with respect to the origin. + \item[$a_y$] The y-component of the first vector with respect to the origin. + \item[$a_z$] The z-component of the first vector with respect to the origin. + \item[$b_x$] The x-component of the second vector with respect to the origin. + \item[$b_y$] The y-component of the second vector with respect to the origin. + \item[$b_z$] The z-component of the second vector with respect to the origin. + \end{description} + \item[Output:] The following macros are assigned. + \begin{description} + \item[\texttt{tdplotresx}] The x-component of the cross product with respect to the origin. + \item[\texttt{tdplotresy}] The y-component of the cross product with respect to the origin. + \item[\texttt{tdplotresz}] The z-component of the cross product with respect to the origin. + \end{description} + \item[Example:] ~ +\begin{shaded} +\begin{verbatim} +\tdplotsetmaincoords{50}{110} +\begin{tikzpicture}[tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$}; + + \pgfmathsetmacro{\ax}{1} + \pgfmathsetmacro{\ay}{1} + \pgfmathsetmacro{\az}{.4} + \pgfmathsetmacro{\bx}{-1} + \pgfmathsetmacro{\by}{1} + \pgfmathsetmacro{\bz}{.6} + + \tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz) + + \draw[->,red] (0,0,0) -- (\ax,\ay,\az) node[anchor=west]{$\vec{A}$}; + \draw[dashed,red] (0,0,0) -- (\ax,\ay,0) -- (\ax,\ay,\az); + \draw[->,green!50!black] (0,0,0) -- + (\bx,\by,\bz) node[anchor=south west]{$\vec{B}$}; + \draw[dashed,green!50!black] (0,0,0) -- (\bx,\by,0) -- (\bx,\by,\bz); + + \draw[->,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,\tdplotresz) + node[anchor=south east]{$\vec{A}\times\vec{B}$}; + \draw[dashed,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{50}{110} +\begin{tikzpicture}[tdplot_main_coords] + + \draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$}; + \draw[thick,->] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$}; + \draw[thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$}; + + \pgfmathsetmacro{\ax}{1} + \pgfmathsetmacro{\ay}{1} + \pgfmathsetmacro{\az}{.4} + \pgfmathsetmacro{\bx}{-1} + \pgfmathsetmacro{\by}{1} + \pgfmathsetmacro{\bz}{.6} + + \tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz) + + \draw[->,red] (0,0,0) -- (\ax,\ay,\az) node[anchor=west]{$\vec{A}$}; + \draw[dashed,red] (0,0,0) -- (\ax,\ay,0) -- (\ax,\ay,\az); + \draw[->,green!50!black] (0,0,0) -- + (\bx,\by,\bz) node[anchor=south west]{$\vec{B}$}; + \draw[dashed,green!50!black] (0,0,0) -- (\bx,\by,0) -- (\bx,\by,\bz); + + \draw[->,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,\tdplotresz) + node[anchor=south east]{$\vec{A}\times\vec{B}$}; + \draw[dashed,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,0) + -- (\tdplotresx,\tdplotresy,\tdplotresz); +\end{tikzpicture} +\end{shaded} +\end{description} + +\subsection{\texttt{tdplotdefinepoints}} + +\begin{description} + \item[Description:] Assigns the values of three coordinates, to be used in the \verb|\tdplotdrawpolytopearc| + \item[Syntax:] \verb|\tdplotdefinepoints(|$v_x$\verb|,|$v_y$\verb|,|$v_z$\verb|)(|$a_x$\verb|,|$a_y$\verb|,|$a_z$\verb|)(|$b_x$\verb|,|$b_y$\verb|,|$b_z$\verb|)| + \item[Parameters:]~ + \begin{description} + \item[$v_x$] The x-component of the vertex. + \item[$v_y$] The y-component of the vertex. + \item[$v_z$] The z-component of the vertex. + \item[$a_x$] The x-component of the first point. + \item[$a_y$] The y-component of the first point. + \item[$a_z$] The z-component of the first point. + \item[$b_x$] The x-component of the second point. + \item[$b_y$] The y-component of the second point. + \item[$b_z$] The z-component of the second point. + \end{description} + \item[Output:] The following macros are assigned: + \begin{description} + \item[\texttt{tdplotvertexx}] The x-component of the vertex. + \item[\texttt{tdplotvertexy}] The y-component of the vertex. + \item[\texttt{tdplotvertexz}] The z-component of the vertex. + \item[\texttt{tdplotax}] The x-component of the first point. + \item[\texttt{tdplotay}] The y-component of the first point. + \item[\texttt{tdplotaz}] The z-component of the first point. + \item[\texttt{tdplotbx}] The x-component of the second point. + \item[\texttt{tdplotby}] The y-component of the second point. + \item[\texttt{tdplotbz}] The z-component of the second point. + \end{description}\end{description} + + +\section{Drawing Commands} Along with all the conventional \tikzname\ drawing commands, the following \tdplot\ commands can be used. -\subsubsection{\texttt{tdplotdrawarc}} +\subsection{\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. @@ -858,6 +1306,7 @@ Along with all the conventional \tikzname\ drawing commands, the following \tdpl \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[r] The arc radius of curvature. \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. @@ -966,8 +1415,88 @@ Along with all the conventional \tikzname\ drawing commands, the following \tdpl \end{shaded} \end{description} + +\subsection{\texttt{tdplotdrawpolytopearc}} + +\begin{description} + \item[Description:] Draws an arc using three user-specified points and a radius. A vertex determines the center of curvature, while two points define the angular extent and the plane of the arc. The three points must be specified in the corresponding macros before this command is issued. + \item[Prerequisites:] The three points must be specified by using the \verb|\tdplotdefinepoints| command. + \item[Syntax:] \verb|\tdplotdrawpolytopearc[draw style]{r}{label options}{label}| + \item[Parameters:]~ + \begin{description} + \item[(\textit{Optional}) draw styles] Optional argument containing draw styles for rendering the arc. + \item[r] The arc radius of curvature. + \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} +\begin{tikzpicture}[tdplot_main_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=south]{$z$}; + + \tdplotdefinepoints(2,2,2)(3,5,1)(-1,5,3) + + \draw[dashed] (0,0,0) -- (\tdplotvertexx,\tdplotvertexy,0) -- + (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz); + \draw[dashed] (0,0,0) -- (\tdplotax,\tdplotay,0) + -- (\tdplotax,\tdplotay,\tdplotaz); + \draw[dashed] (0,0,0) -- (\tdplotbx,\tdplotby,0) + -- (\tdplotbx,\tdplotby,\tdplotbz); + + \draw[->,red] (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz) + -- (\tdplotax,\tdplotay,\tdplotaz); + \draw[->,green!50!black] (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz) + -- (\tdplotbx,\tdplotby,\tdplotbz); + + \node[anchor=east] at (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz){Vertex}; + \node[anchor=north west] at (\tdplotax,\tdplotay,\tdplotaz){A}; + \node[anchor=south west] at (\tdplotbx,\tdplotby,\tdplotbz){B}; + + \tdplotdrawpolytopearc[thick]{1}{anchor=west}{$\theta$} +\end{tikzpicture} +\end{verbatim} +\tdplotsetmaincoords{60}{110} +\begin{tikzpicture}[tdplot_main_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=south]{$z$}; + + \tdplotdefinepoints(2,2,2)(3,5,1)(-1,5,3) + + \draw[dashed] (0,0,0) -- (\tdplotvertexx,\tdplotvertexy,0) -- + (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz); + \draw[dashed] (0,0,0) -- (\tdplotax,\tdplotay,0) + -- (\tdplotax,\tdplotay,\tdplotaz); + \draw[dashed] (0,0,0) -- (\tdplotbx,\tdplotby,0) + -- (\tdplotbx,\tdplotby,\tdplotbz); + + \draw[->,red] (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz) + -- (\tdplotax,\tdplotay,\tdplotaz); + \draw[->,green!50!black] (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz) + -- (\tdplotbx,\tdplotby,\tdplotbz); + + \node[anchor=east] at (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz){Vertex}; + \node[anchor=north west] at (\tdplotax,\tdplotay,\tdplotaz){A}; + \node[anchor=south west] at (\tdplotbx,\tdplotby,\tdplotbz){B}; + + \tdplotdrawpolytopearc[thick]{1}{anchor=west}{$\theta$} +\end{tikzpicture} +\end{shaded} +\end{description} + + + + + + %make more! -%\subsubsection{} +%\subsection{} %\begin{description} % \item[Description:] @@ -978,101 +1507,131 @@ Along with all the conventional \tikzname\ drawing commands, the following \tdpl % \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. +\section{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 initially 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, as +% \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} +The command has been generalized so that the hue can be specified in terms of the three polar coordinates, as +% +\begin{align}\begin{split} + r &= f(\theta,\phi)\\ + hue &= g(r,\theta,\phi) +\end{split}\end{align} + +\subsection{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. +To achieve the illusion of a 3d surface with proper persistence of vision, the \tdplot\ package divides the drawing task into smaller sections. This division ensures the surface on the far side of the viewing perspective is properly occluded from view. 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'' + \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}$. +The entire back half is drawn before the front half. For each half, the entire left or right side is drawn. For each side, all $\theta$ angles are drawn in wedges for each $\phi$ angle. When the back half is rendered, the $\theta$ angle is swept from $\theta_{view}$ toward the poles. When the front half is rendered, 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. +During this process, the $x$, $y$, and $z$ axes are drawn at the appropriate time, ensuring the axes are occluded properly by the shape. The draw instructions for these axes are specified as user-defined parameters for this command. - -\subsubsection{Using \texttt{tdplotsphericalsurfaceplot}} +\subsection{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[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. The line thickness can be specified by issuing the \verb|\pgfsetlinewidth| PGF macro. \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[(\emph{Optional}) fill color style] Specifies whether \texttt{fill color} is a function of (\verb|\tdplotr|, \verb|\tdplottheta|, \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. + \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. To avoid this, make sure \texttt{function} is always positive. + \item[x axis] Any draw commands used to render the $x$ axis. + \item[y axis] Any draw commands used to render the $y$ axis. + \item[z axis] Any draw commands used to render the $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] - +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.5] +\pgfsetlinewidth{.2pt} \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$};}% + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Parametric Fill in $\phi$}; +\end{tikzpicture} +\begin{tikzpicture}[scale=2,tdplot_main_coords,line join=bevel,fill opacity=.8] +\pgfsetlinewidth{.1pt} +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{0.5*abs(cos(\tdplottheta))}{black}{2*abs(\tdplotr)}% {\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$};}% + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Parametric Fill in $r$}; \end{tikzpicture} -\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords,% - fill opacity=.7] +\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7] +\pgfsetlinewidth{.4pt} \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$};}% + {\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$};}% + + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Solid Fill}; \end{tikzpicture} \end{verbatim} \ifpdf \beginpgfgraphicnamed{Figures/examplesurfaceplot} \tdplotsetmaincoords{70}{135} \begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.5] - +\pgfsetlinewidth{.2pt} \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$};}% + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Parametric Fill in $\phi$}; +\end{tikzpicture} +\begin{tikzpicture}[scale=2,tdplot_main_coords,line join=bevel,fill opacity=.8] +\pgfsetlinewidth{.1pt} +\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% +{0.5*abs(cos(\tdplottheta))}{black}{2*abs(\tdplotr)}% + {\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$};}% + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Parametric Fill in $r$}; \end{tikzpicture} \begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7] +\pgfsetlinewidth{.4pt} \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$};}% + + \node[tdplot_screen_coords,fill opacity=1] at (0,-1) {Solid Fill}; \end{tikzpicture} \endpgfgraphicnamed \fi \end{shaded} \end{description} -\subsubsection{The \texttt{tdplotsetpolarplotrange} Command} +\subsection{The \texttt{tdplotsetpolarplotrange} Command} \begin{description} \item[Description:] Defines the range of angles to be displayed when using \verb|\tdplotsphericalsurfaceplot| @@ -1119,17 +1678,17 @@ To improve the illusion of proper depth perception, a set of commands can be spe \end{shaded} \end{description} -\subsubsection{The \texttt{tdplotresetpolarplotrange} Command} +\subsection{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} +\subsection{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[Description:] Draws a ``color guide'' table which associates the hue of a parametric polar plot with an angle. Guide is drawn at user-specified screen coordinates with user-specified size. This guide is intended to illustrate the complex phase representation of the surface for a given $\theta$ and $\phi$ coordinate. \item[Syntax:] \verb|\tdplotshowargcolorguide{x position}{y position}{x size}{y size}| \item[Parameters:]~ \begin{description} @@ -1163,11 +1722,11 @@ To improve the illusion of proper depth perception, a set of commands can be spe \end{shaded} \end{description} -\subsection{Miscellaneous Math Commands} +\section{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}} +\subsection{\texttt{tdplotsinandcos}} \begin{description} \item[Description:] Determines the sine and cosine of the specified angle, and stores in specified macros. @@ -1180,7 +1739,7 @@ The following commands are used to streamline the \tdplot\ calculations in the b \end{description} \end{description} -\subsubsection{\texttt{tdplotmult}} +\subsection{\texttt{tdplotmult}} \begin{description} \item[Description:] Determines the product of two specified values, and stores the result in the specified macro. @@ -1193,7 +1752,7 @@ The following commands are used to streamline the \tdplot\ calculations in the b \end{description} \end{description} -\subsubsection{\texttt{tdplotdiv}} +\subsection{\texttt{tdplotdiv}} \begin{description} \item[Description:] Determines the quotient of two specified values, and stores the result in the specified macro. @@ -1386,11 +1945,12 @@ I have recently heard about the \texttt{xyz spherical} coordinate system offered 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 + \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. + \item Find a way to extract coordinate components defined by the \verb|\coordinate| command and use them in macros defined by the \verb|\pgfmathsetmacro| and \verb|\pgfmathparse| commands. \end{itemize} diff --git a/Master/texmf-dist/tex/latex/tikz-3dplot/tikz-3dplot.sty b/Master/texmf-dist/tex/latex/tikz-3dplot/tikz-3dplot.sty index 819e8394fd4..4873efb424d 100644 --- a/Master/texmf-dist/tex/latex/tikz-3dplot/tikz-3dplot.sty +++ b/Master/texmf-dist/tex/latex/tikz-3dplot/tikz-3dplot.sty @@ -20,7 +20,7 @@ %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 +%Created 2009-11-07 by Jeff Hein. Last updated: 2010-01-20 %---------------------------------------------------------- %Requirements @@ -30,20 +30,8 @@ %Update Notes %------------ -%2009-11-07: Created package from previous scratch work -%2009-11-18: Added a few macros for storing user-specified coordinate frame angles. Useful for commands which would like to know what the current display perspective is. -%2009-11-21: Added spherical polar parametric surface plotting functionality with the \tdplotsphericalsurfaceplot command. -%2009-12-03: Fixed the range checking for polar parametric plotting. It should now behave better around the range \phi = 0 -%2010-01-17: renamed the package to tikz-3dplot. +%see the documentation for update notes -%TODO list -%--------- - -%TODO: figure out how to work in a variable scope that doesn't interfere with other packages -%TODO: find a way to check if TikZ is loaded, and give a compile error if necessary -%TODO: find a way to use predefined coordinates in rotated or translated coordinate frames, instead of just literal coordinates -%TODO: generalize matrix math if such a package exists -%TODO: look into using TikZ spherical polar coordinates explicitly to streamline coordinate definitions. \RequirePackage{pgf} \RequirePackage{ifthen} @@ -54,11 +42,11 @@ \tikzset{tdplot_screen_coords/.style={x={(1 cm,0 cm)},y={(0 cm, 1 cm)},z={(-1 cm, -1 cm)}}}% -\pgfmathsetmacro{\lowerphi}{0} -\pgfmathsetmacro{\upperphi}{360} -\pgfmathsetmacro{\lowertheta}{0} -\pgfmathsetmacro{\uppertheta}{180} - +\pgfmathsetmacro{\tdplotlowerphi}{0} +\pgfmathsetmacro{\tdplotupperphi}{360} +\pgfmathsetmacro{\tdplotlowertheta}{0} +\pgfmathsetmacro{\tdplotuppertheta}{180} +%\pgfmathsetmacro{\tdplotlinewidth}{.25pt} %Commands %-------- @@ -145,22 +133,12 @@ \tikzset{tdplot_main_coords/.style={x={(\raarot cm,\rbarot cm)},y={(\rabrot cm, \rbbrot cm)},z={(\racrot cm, \rbcrot cm)}}}% } - -%\tdplotsetrotatedcoords{\alpha}{\beta}{\gamma} -%generates the coordinate transformation for the rotated coordinate system within the display coordinate system. This should be called only after the display coordinate system has been defined. If the display coordinate system changes, this will have to be updated. -%#1: user-specified euler angle \alpha. -%#2: user-specified euler angle \beta. -%#3: user-specified euler angle \gamma. -\newcommand{\tdplotsetrotatedcoords}[3]{% -% -\pgfmathsetmacro{\alphaeul}{#1} -\pgfmathsetmacro{\betaeul}{#2} -\pgfmathsetmacro{\gammaeul}{#3} -% +%determines the rotation matrix for transformation from the rotation coordinate frame to the main coordinate frame. This also defines the rotation to produce the rotated coordinate frame. +\newcommand{\tdplotcalctransformrotmain}{% %perform some trig for the Euler transformation -\tdplotsinandcos{\sinalpha}{\cosalpha}{\alphaeul} -\tdplotsinandcos{\sinbeta}{\cosbeta}{\betaeul} -\tdplotsinandcos{\singamma}{\cosgamma}{\gammaeul} +\tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} +\tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta} +\tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma} % \tdplotmult{\sasb}{\sinalpha}{\sinbeta} \tdplotmult{\sbsg}{\sinbeta}{\singamma} @@ -198,6 +176,87 @@ %\rbaeul\ \rbbeul\ \rbceul % %\rcaeul\ \rcbeul\ \rcceul +} + + +%determines the rotation matrix for transformation from the main coordinate frame to the rotated coordinate frame. +\newcommand{\tdplotcalctransformmainrot}{% +%perform some trig for the Euler transformation +\tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} +\tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta} +\tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma} +% +\tdplotmult{\sasb}{\sinalpha}{\sinbeta} +\tdplotmult{\sbsg}{\sinbeta}{\singamma} +\tdplotmult{\sasg}{\sinalpha}{\singamma} +\tdplotmult{\sasbsg}{\sasb}{\singamma} +% +\tdplotmult{\sacb}{\sinalpha}{\cosbeta} +\tdplotmult{\sacg}{\sinalpha}{\cosgamma} +\tdplotmult{\sbcg}{\sinbeta}{\cosgamma} +\tdplotmult{\sacbsg}{\sacb}{\singamma} +\tdplotmult{\sacbcg}{\sacb}{\cosgamma} +% +\tdplotmult{\casb}{\cosalpha}{\sinbeta} +\tdplotmult{\cacb}{\cosalpha}{\cosbeta} +\tdplotmult{\cacg}{\cosalpha}{\cosgamma} +\tdplotmult{\casg}{\cosalpha}{\singamma} +% +\tdplotmult{\cacbsg}{\cacb}{\singamma} +\tdplotmult{\cacbcg}{\cacb}{\cosgamma} +% +%determine rotation matrix elements for Euler transformation +\pgfmathsetmacro{\raaeul}{\cacbcg - \sasg} +\pgfmathsetmacro{\rabeul}{\sacbcg + \casg} +\pgfmathsetmacro{\raceul}{-\sbcg} +\pgfmathsetmacro{\rbaeul}{-\cacbsg - \sacg} +\pgfmathsetmacro{\rbbeul}{-\sacbsg + \cacg} +\pgfmathsetmacro{\rbceul}{\sbsg} +\pgfmathsetmacro{\rcaeul}{\casb} +\pgfmathsetmacro{\rcbeul}{\sasb} +\pgfmathsetmacro{\rcceul}{\cosbeta} +% +%DEBUG: display euler matrix elements +%\raaeul\ \rabeul\ \raceul +% +%\rbaeul\ \rbbeul\ \rbceul +% +%\rcaeul\ \rcbeul\ \rcceul +} + +%transforms a coordinate from the main coordinate frame to the rotated coordinate frame +\newcommand{\tdplottransformmainrot}[3]{% + \tdplotcalctransformmainrot + + \pgfmathsetmacro{\tdplotresx}{\raaeul * #1 + \rabeul * #2 + \raceul * #3} + \pgfmathsetmacro{\tdplotresy}{\rbaeul * #1 + \rbbeul * #2 + \rbceul * #3} + \pgfmathsetmacro{\tdplotresz}{\rcaeul * #1 + \rcbeul * #2 + \rcceul * #3} +} + +%transforms a coordinate from the rotated coordinate frame to the main coordinate frame +\newcommand{\tdplottransformrotmain}[3]{% + \tdplotcalctransformrotmain + + \pgfmathsetmacro{\tdplotresx}{\raaeul * #1 + \rabeul * #2 + \raceul * #3} + \pgfmathsetmacro{\tdplotresy}{\rbaeul * #1 + \rbbeul * #2 + \rbceul * #3} + \pgfmathsetmacro{\tdplotresz}{\rcaeul * #1 + \rcbeul * #2 + \rcceul * #3} +} + + + +%\tdplotsetrotatedcoords{\alpha}{\beta}{\gamma} +%generates the coordinate transformation for the rotated coordinate system within the display coordinate system. This should be called only after the display coordinate system has been defined. If the display coordinate system changes, this will have to be updated. +%#1: user-specified euler angle \alpha. +%#2: user-specified euler angle \beta. +%#3: user-specified euler angle \gamma. +\newcommand{\tdplotsetrotatedcoords}[3]{% +% +\pgfmathsetmacro{\tdplotalpha}{#1} +\pgfmathsetmacro{\tdplotbeta}{#2} +\pgfmathsetmacro{\tdplotgamma}{#3} +% +\tdplotcalctransformrotmain + % %now, determine master rotation matrix to define euler-rotated coordinates within the display coordinate frame \tdplotmult{\raaeaa}{\raarot}{\raaeul} @@ -292,7 +351,7 @@ %this places the rotated coordinate system into the "theta plane" for the current rotated coordinate system, at user-specified angle \phi'. Note that it replaces the current rotated coordinate system %#1: user-specified \phi' angle from x'-axis \newcommand{\tdplotsetrotatedthetaplanecoords}[1]{% - \tdplotsetrotatedcoords{\alphaeul}{\betaeul}{\gammaeul + #1}% + \tdplotsetrotatedcoords{\tdplotalpha}{\tdplotbeta}{\tdplotgamma + #1}% % %permute the coordinates \tikzset{tdplot_rotated_coords/.append style={y={(\raarc cm,\rbarc cm)},z={(\rabrc cm, \rbbrc cm)},x={(\racrc cm, \rbcrc cm)}}}% @@ -354,6 +413,77 @@ \draw[#1] #2 + (#4:#3) arc (#4:#5:#3); } +\def\tdplotdefinepoints(#1,#2,#3)(#4,#5,#6)(#7,#8,#9){% + \pgfmathsetmacro{\tdplotvertexx}{#1} + \pgfmathsetmacro{\tdplotvertexy}{#2} + \pgfmathsetmacro{\tdplotvertexz}{#3} + \pgfmathsetmacro{\tdplotax}{#4} + \pgfmathsetmacro{\tdplotay}{#5} + \pgfmathsetmacro{\tdplotaz}{#6} + \pgfmathsetmacro{\tdplotbx}{#7} + \pgfmathsetmacro{\tdplotby}{#8} + \pgfmathsetmacro{\tdplotbz}{#9} +}% + + +%draws an arc using three specified points +%\tdplotdrawpolytopearc[thick]{1}{anchor=west}{$\theta$} +\newcommand{\tdplotdrawpolytopearc}[4][]{% + + %determine vector lengths + \pgfmathsetmacro{\ax}{\tdplotax - \tdplotvertexx} + \pgfmathsetmacro{\ay}{\tdplotay - \tdplotvertexy} + \pgfmathsetmacro{\az}{\tdplotaz - \tdplotvertexz} + + \pgfmathsetmacro{\bx}{\tdplotbx - \tdplotvertexx} + \pgfmathsetmacro{\by}{\tdplotby - \tdplotvertexy} + \pgfmathsetmacro{\bz}{\tdplotbz - \tdplotvertexz} + + %determine normal to vectors + \tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz) + + %DEBUG: show the cross product + %\draw[->,blue] (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz) + % -- ++(\tdplotresx,\tdplotresy,\tdplotresz); + + %get angles for this vector + \tdplotgetpolarcoords{\tdplotresx}{\tdplotresy}{\tdplotresz} + + %place the rotated coordinate system so that the z' axis points along this vector + \tdplotsetrotatedcoords{\tdplotresphi}{\tdplotrestheta}{0} + \coordinate (Vertex) at (\tdplotvertexx,\tdplotvertexy,\tdplotvertexz); + \tdplotsetrotatedcoordsorigin{(Vertex)} + + %DEBUG: show the rotated coordinate system + %\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x'$}; + %\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y'$}; + %\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z'$}; + + %calculate the start angle of the arc + \tdplottransformmainrot{\ax}{\ay}{\az} + \tdplotgetpolarcoords{\tdplotresx}{\tdplotresy}{\tdplotresz} + \pgfmathsetmacro{\tdplotstartphi}{\tdplotresphi} + + %calculate the end angle of the arc + \tdplottransformmainrot{\bx}{\by}{\bz} + \tdplotgetpolarcoords{\tdplotresx}{\tdplotresy}{\tdplotresz} + + %draw the arc + \pgfmathparse{\tdplotstartphi < \tdplotresphi} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {}% + { + \pgfmathsetmacro{\tdplotstartphi}{\tdplotstartphi - 360} + } + + \draw[tdplot_rotated_coords,#1] (0,0,0) + (\tdplotstartphi:#2) arc (\tdplotstartphi:\tdplotresphi:#2); + + \pgfmathsetmacro{\tdplotresphi}{(\tdplotresphi + \tdplotstartphi)/2} + + \draw[tdplot_rotated_coords] (0,0,0) + (\tdplotresphi:#2) node[#3]{#4}; +} + + % \tdplotsphericalsurfaceplot[fill mode]{theta step size}{phi step size}{r} %draws a surface in spherical polar coordinates given by r(\theta,\phi), where angular ranges and steps are defined. %#1: draw styles @@ -450,17 +580,17 @@ %sets the angular range of the polar plot to user-specified values \newcommand{\tdplotsetpolarplotrange}[4]{% - \pgfmathsetmacro{\lowerphi}{#3} - \pgfmathsetmacro{\upperphi}{#4} - \pgfmathsetmacro{\lowertheta}{#1} - \pgfmathsetmacro{\uppertheta}{#2} + \pgfmathsetmacro{\tdplotlowerphi}{#3} + \pgfmathsetmacro{\tdplotupperphi}{#4} + \pgfmathsetmacro{\tdplotlowertheta}{#1} + \pgfmathsetmacro{\tdplotuppertheta}{#2} } \newcommand{\tdplotresetpolarplotrange}{% - \pgfmathsetmacro{\lowerphi}{0} - \pgfmathsetmacro{\upperphi}{360} - \pgfmathsetmacro{\lowertheta}{0} - \pgfmathsetmacro{\uppertheta}{180} + \pgfmathsetmacro{\tdplotlowerphi}{0} + \pgfmathsetmacro{\tdplotupperphi}{360} + \pgfmathsetmacro{\tdplotlowertheta}{0} + \pgfmathsetmacro{\tdplotuppertheta}{180} } @@ -505,23 +635,23 @@ }{}% %test to see if this value is within the specified angular range - \pgfmathparse{\tdplottheta > \uppertheta} + \pgfmathparse{\tdplottheta > \tdplotuppertheta} \pgfmathsetmacro{\logictest}{1 - \pgfmathresult} - \pgfmathparse{\tdplottheta < \lowertheta} + \pgfmathparse{\tdplottheta < \tdplotlowertheta} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} \pgfmathsetmacro{\tdplottheta}{\tdplottheta + \viewthetastep} - \pgfmathparse{\tdplottheta > \uppertheta} + \pgfmathparse{\tdplottheta > \tdplotuppertheta} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} - \pgfmathparse{\tdplottheta < \lowertheta} + \pgfmathparse{\tdplottheta < \tdplotlowertheta} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} - \pgfmathparse{\tdplotphi > \upperphi} + \pgfmathparse{\tdplotphi > \tdplotupperphi} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} - \pgfmathparse{\tdplotphi < \lowerphi} + \pgfmathparse{\tdplotphi < \tdplotlowerphi} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} \pgfmathsetmacro{\tdplotphi}{\tdplotphi + \viewphistep} @@ -531,19 +661,21 @@ \pgfmathsetmacro{\tdplotphi}{\tdplotphi + 360} }{}% - \pgfmathparse{\tdplotphi > \upperphi} + \pgfmathparse{\tdplotphi > \tdplotupperphi} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} - \pgfmathparse{\tdplotphi < \lowerphi} + \pgfmathparse{\tdplotphi < \tdplotlowerphi} \pgfmathsetmacro{\logictest}{\logictest * (1 - \pgfmathresult)} \pgfmathsetmacro{\tdplottheta}{\curtheta} \pgfmathsetmacro{\tdplotphi}{\curphi} - + %if using fill color parametric to angles \ifthenelse{\equal{#6}{parametricfill}}{% \pgfmathsetmacro{\radius}{#1} + \pgfmathsetmacro{\tdplotr}{\radius*360} %factor of 360 lets the radius change hue through one full cycle for each unit radius + \pgfmathlessthan{\radius}{0} \pgfmathsetmacro{\phaseshift}{180 * \pgfmathresult} @@ -632,6 +764,90 @@ } +%\tdplotgetpolarcoords{\vx}{\vy}{\vz} +%determines the theta and phi angle associated with the specified x, y, and z components of a vector +\newcommand{\tdplotgetpolarcoords}[3]{% +% + \pgfmathsetmacro{\vxcalc}{#1} + \pgfmathsetmacro{\vycalc}{#2} + \pgfmathsetmacro{\vzcalc}{#3} +% + \pgfmathsetmacro{\vcalc}{ sqrt(\vxcalc^2 + \vycalc^2 + \vzcalc^2) } +% \pgfmathsetmacro{\vcalc}{ (\vxcalc^2 + \vycalc^2 + \vzcalc^2)^.5 } + + \pgfmathsetmacro{\vxycalc}{ sqrt(\vxcalc^2 + \vycalc^2) } +% \pgfmathsetmacro{\vxycalc}{ (\vxcalc^2 + \vycalc^2)^.5 } + + \pgfmathsetmacro{\tdplotrestheta}{asin(\vxycalc/\vcalc)} +% + %check for angles larger than 90 + \pgfmathparse{\vzcalc < 0} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {% + \pgfmathsetmacro{\tdplotrestheta}{180 - \tdplotrestheta} + } + {} +% + %check for special case: vx = 0 + \ifthenelse{\equal{\vxcalc}{0.0}}% + {% + %check the sign of vy, and set angle appropriately + \pgfmathparse{\vycalc < 0} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {% + \pgfmathsetmacro{\tdplotresphi}{270} + } + {% + \pgfmathparse{\vycalc == 0} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {% + \pgfmathsetmacro{\tdplotresphi}{0} + } + {% + \pgfmathsetmacro{\tdplotresphi}{90} + } + } + } + {% + %perform the arctan calculation + \pgfmathsetmacro{\tdplotresphi}{atan(\vycalc/\vxcalc)} +% + %check if vx is less than zero, to properly identify the quadrant + \pgfmathparse{\vxcalc < 0} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {% + %increase by half a rotation if necessary + \pgfmathsetmacro{\tdplotresphi}{\tdplotresphi+180} + } + {} + + %ensure the angle lies between 0 and 360 degrees + \pgfmathparse{\tdplotresphi < 0} + \ifthenelse{\equal{\pgfmathresult}{1.0}}% + {% + \pgfmathsetmacro{\tdplotresphi}{\tdplotresphi+360} + } + {} + } +} + + +% \tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz) +\def\tdplotcrossprod(#1,#2,#3)(#4,#5,#6){% + \pgfmathsetmacro{\tdplotresx}{#2 * #6 - #3 * #5} + \pgfmathsetmacro{\tdplotresy}{#3 * #4 - #1 * #6} + \pgfmathsetmacro{\tdplotresz}{#1 * #5 - #2 * #4} + +} + +%\newcommand{\tdplottransform +% +% +%\newcommand{\tdplotgetplane}{ +% +%} + + %Notes %----- |