| 1 |
\newcommand{\tdplotmainfig}{% |
| 2 |
%Angle Definitions |
| 3 |
%----------------- |
| 4 |
% |
| 5 |
%set the plot display orientation |
| 6 |
%synatax: \tdplotsetdisplay{\theta_d}{\phi_d} |
| 7 |
\tdplotsetmaincoords{60}{110} |
| 8 |
% |
| 9 |
%define polar coordinates for some vector |
| 10 |
%TODO: look into using 3d spherical coordinate system |
| 11 |
\pgfmathsetmacro{\rvec}{.8} |
| 12 |
\pgfmathsetmacro{\thetavec}{30} |
| 13 |
\pgfmathsetmacro{\phivec}{60} |
| 14 |
% |
| 15 |
%start tikz picture, and use the tdplot_main_coords style to implement the display coordinate transformation provided by 3dplot |
| 16 |
\begin{tikzpicture}[scale=3,tdplot_main_coords] |
| 17 |
|
| 18 |
%set up some coordinates |
| 19 |
%----------------------- |
| 20 |
\coordinate (O) at (0,0,0); |
| 21 |
|
| 22 |
%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). |
| 23 |
%synatax: \tdplotsetcoord{Coordinate name without parentheses}{r}{\theta}{\phi} |
| 24 |
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec} |
| 25 |
|
| 26 |
%draw figure contents |
| 27 |
%-------------------- |
| 28 |
|
| 29 |
%draw the main coordinate system axes |
| 30 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 31 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 32 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 33 |
|
| 34 |
%draw a vector from origin to point (P) |
| 35 |
\draw[-stealth,color=red] (O) -- (P); |
| 36 |
|
| 37 |
%draw projection on xy plane, and a connecting line |
| 38 |
\draw[dashed, color=red] (O) -- (Pxy); |
| 39 |
\draw[dashed, color=red] (P) -- (Pxy); |
| 40 |
|
| 41 |
%draw the angle \phi, and label it |
| 42 |
%syntax: \tdplotdrawarc[coordinate frame, draw options]{center point}{r}{angle}{label options}{label} |
| 43 |
\tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\phi$} |
| 44 |
|
| 45 |
|
| 46 |
%set the rotated coordinate system so the x'-y' plane lies within the "theta plane" of the main coordinate system |
| 47 |
%syntax: \tdplotsetthetaplanecoords{\phi} |
| 48 |
\tdplotsetthetaplanecoords{\phivec} |
| 49 |
|
| 50 |
%draw theta arc and label, using rotated coordinate system |
| 51 |
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{\thetavec}{anchor=south west}{$\theta$} |
| 52 |
|
| 53 |
%draw some dashed arcs, demonstrating direct arc drawing |
| 54 |
\draw[dashed,tdplot_rotated_coords] (\rvec,0,0) arc (0:90:\rvec); |
| 55 |
\draw[dashed] (\rvec,0,0) arc (0:90:\rvec); |
| 56 |
|
| 57 |
%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 |
| 58 |
%syntax: \tdplotsetrotatedcoords{\alpha}{\beta}{\gamma} |
| 59 |
\tdplotsetrotatedcoords{\phivec}{\thetavec}{0} |
| 60 |
|
| 61 |
%translate the rotated coordinate system |
| 62 |
%syntax: \tdplotsetrotatedcoordsorigin{point} |
| 63 |
\tdplotsetrotatedcoordsorigin{(P)} |
| 64 |
|
| 65 |
%use the tdplot_rotated_coords style to work in the rotated, translated coordinate frame |
| 66 |
\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north west]{$x'$}; |
| 67 |
\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=west]{$y'$}; |
| 68 |
\draw[thick,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z'$}; |
| 69 |
|
| 70 |
%WARNING: coordinates defined by the \coordinate command (eg. (O), (P), etc.) cannot be used in rotated coordinate frames. Use only literal coordinates. |
| 71 |
|
| 72 |
%draw some vector, and its projection, in the rotated coordinate frame |
| 73 |
\draw[-stealth,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,.2); |
| 74 |
\draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (.2,.2,0); |
| 75 |
\draw[dashed,color=blue,tdplot_rotated_coords] (.2,.2,0) -- (.2,.2,.2); |
| 76 |
|
| 77 |
%show its phi arc and label |
| 78 |
\tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{45}{anchor=north west,color=black}{$\phi'$} |
| 79 |
|
| 80 |
%change the rotated coordinate frame so that it lies in its theta plane. Note that this overwrites the original rotated coordinate frame |
| 81 |
%syntax: \tdplotsetrotatedthetaplanecoords{\phi'} |
| 82 |
\tdplotsetrotatedthetaplanecoords{45} |
| 83 |
|
| 84 |
%draw theta arc and label |
| 85 |
\tdplotdrawarc[tdplot_rotated_coords,color=blue]{(0,0,0)}{0.2}{0}{55}{anchor=south west,color=black}{$\theta'$} |
| 86 |
|
| 87 |
\end{tikzpicture} |
| 88 |
} |
| 89 |
|
| 90 |
\newcommand{\threedcoord}[2]{% |
| 91 |
\tdplotsetmaincoords{#1}{#2} |
| 92 |
\begin{tikzpicture}[tdplot_main_coords] |
| 93 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 94 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 95 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 96 |
\end{tikzpicture} |
| 97 |
} |
| 98 |
|
| 99 |
\newcommand{\threedrotcoordsystem}{% |
| 100 |
\tdplotsetmaincoords{50}{140} |
| 101 |
\begin{tikzpicture}[scale=5,tdplot_main_coords] |
| 102 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 103 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 104 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 105 |
|
| 106 |
\tdplotsetrotatedcoords{34}{26}{12} |
| 107 |
|
| 108 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (.5,0,0) node[anchor=north east]{$x'$}; |
| 109 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,.5,0) node[anchor=north west]{$y'$}; |
| 110 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.5) node[anchor=south]{$z'$}; |
| 111 |
|
| 112 |
\end{tikzpicture} |
| 113 |
} |
| 114 |
|
| 115 |
\newcommand{\threedconventions}{% |
| 116 |
\tdplotsetmaincoords{50}{110} |
| 117 |
\begin{tikzpicture}[scale=2,tdplot_main_coords] |
| 118 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 119 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 120 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 121 |
|
| 122 |
\draw[color=blue] (0,0,0) -- (.5,.5,0); |
| 123 |
|
| 124 |
\draw[color=blue,->] (.5,0,0) arc (0:45:.5); |
| 125 |
\end{tikzpicture} |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
\newcommand{\threedalphabetagamma}{% |
| 130 |
\beginpgfgraphicnamed{Figures/alphabetagamma} |
| 131 |
\tdplotsetmaincoords{50}{140} |
| 132 |
% |
| 133 |
\begin{tikzpicture}[scale=2,tdplot_main_coords] |
| 134 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 135 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 136 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 137 |
|
| 138 |
\tdplotsetrotatedcoords{0}{0}{30} |
| 139 |
|
| 140 |
\draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; |
| 141 |
\draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; |
| 142 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=west]{$z'$}; |
| 143 |
|
| 144 |
\tdplotdrawarc[color=orange!50!black]{(0,0,0)}{.4}{0}{30}{anchor=north east}{$\gamma$} |
| 145 |
\end{tikzpicture} |
| 146 |
% |
| 147 |
\begin{tikzpicture}[scale=2,tdplot_main_coords] |
| 148 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 149 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 150 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 151 |
|
| 152 |
\tdplotsetrotatedcoords{0}{0}{30} |
| 153 |
|
| 154 |
\draw[dashed,color=red,tdplot_rotated_coords] (0,0,0) -- (.5,0,0); |
| 155 |
\draw[dashed,color=green!50!black,tdplot_rotated_coords] (0,0,0) -- (0,.5,0); |
| 156 |
\draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (0,0,.5); |
| 157 |
|
| 158 |
\tdplotsetrotatedcoords{0}{40}{30} |
| 159 |
|
| 160 |
\draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; |
| 161 |
\draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; |
| 162 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; |
| 163 |
|
| 164 |
\tdplotsetthetaplanecoords{0} |
| 165 |
\tdplotdrawarc[tdplot_rotated_coords,color=orange!50!black]{(0,0,0)}{.4}{0}{40}{anchor=south}{$\beta$} |
| 166 |
|
| 167 |
\end{tikzpicture} |
| 168 |
% |
| 169 |
\begin{tikzpicture}[scale=2,tdplot_main_coords] |
| 170 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 171 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 172 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 173 |
|
| 174 |
\tdplotsetrotatedcoords{0}{40}{30} |
| 175 |
|
| 176 |
\draw[dashed,color=red,tdplot_rotated_coords] (0,0,0) -- (.5,0,0); |
| 177 |
\draw[dashed,color=green!50!black,tdplot_rotated_coords] (0,0,0) -- (0,.5,0); |
| 178 |
\draw[dashed,color=blue,tdplot_rotated_coords] (0,0,0) -- (0,0,.5); |
| 179 |
|
| 180 |
\tdplotsetrotatedcoords{60}{0}{0} |
| 181 |
\draw[dotted,color=blue,tdplot_rotated_coords] (0,0,0) -- (.4,0,0); |
| 182 |
\tdplotsetrotatedcoords{60}{40}{30} |
| 183 |
|
| 184 |
\draw[thick,color=red,tdplot_rotated_coords,->] (0,0,0) -- (.7,0,0) node[anchor=north]{$x'$}; |
| 185 |
\draw[thick,color=green!50!black,tdplot_rotated_coords,->] (0,0,0) -- (0,.7,0) node[anchor=west]{$y'$}; |
| 186 |
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) -- (0,0,.7) node[anchor=south]{$z'$}; |
| 187 |
|
| 188 |
|
| 189 |
\tdplotdrawarc[color=orange!50!black]{(0,0,0)}{.2}{0}{60}{anchor=north east}{$\alpha$} |
| 190 |
\end{tikzpicture} |
| 191 |
\endpgfgraphicnamed |
| 192 |
} |
| 193 |
|
| 194 |
\newcommand{\threedthetaarc}{% |
| 195 |
% |
| 196 |
\tdplotsetmaincoords{70}{110} |
| 197 |
% |
| 198 |
\begin{tikzpicture}[scale=5,tdplot_main_coords] |
| 199 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 200 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 201 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 202 |
|
| 203 |
\tdplotsetcoord{P}{.8}{50}{70} |
| 204 |
|
| 205 |
%draw a vector from origin to point (P) |
| 206 |
\draw[-stealth,color=red] (O) -- (P); |
| 207 |
|
| 208 |
%draw projection on xy plane, and a connecting line |
| 209 |
\draw[dashed, color=red] (O) -- (Pxy); |
| 210 |
\draw[dashed, color=red] (P) -- (Pxy); |
| 211 |
|
| 212 |
|
| 213 |
\tdplotsetthetaplanecoords{70} |
| 214 |
|
| 215 |
\draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (.2,0,0) node[anchor=east]{$x'$}; |
| 216 |
\draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,.2,0) node[anchor=north]{$y'$}; |
| 217 |
\draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,0,.2) node[anchor=west]{$z'$}; |
| 218 |
|
| 219 |
|
| 220 |
\tdplotdrawarc[tdplot_rotated_coords,color=orange!50!black]{(0,0,0)}{.4}{0}{50}{anchor=north east}{$\theta$} |
| 221 |
\end{tikzpicture} |
| 222 |
} |
| 223 |
|
| 224 |
\newcommand{\threedparamplot}{% |
| 225 |
% |
| 226 |
\beginpgfgraphicnamed{Figures/threedparamplot} |
| 227 |
\tdplotsetmaincoords{70}{110} |
| 228 |
% |
| 229 |
\begin{tikzpicture}[scale=2,tdplot_main_coords] |
| 230 |
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$}; |
| 231 |
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$}; |
| 232 |
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; |
| 233 |
|
| 234 |
\pgfplothandlerlineto |
| 235 |
\pgfplotfunction{\thetaen}{0,6,...,360}{% |
| 236 |
\pgfpointxyz{cos(\thetaen)}% |
| 237 |
{sin(\thetaen)}% |
| 238 |
{\thetaen/400} |
| 239 |
} |
| 240 |
\pgfusepath{stroke} |
| 241 |
|
| 242 |
\end{tikzpicture} |
| 243 |
\endpgfgraphicnamed |
| 244 |
} |
| 245 |
|
| 246 |
\newcommand{\threedsurfaceplot}{% |
| 247 |
\beginpgfgraphicnamed{Figures/threedsurfaceplot} |
| 248 |
% |
| 249 |
\tdplotsetmaincoords{70}{135} |
| 250 |
% |
| 251 |
\begin{tikzpicture}[scale=3,line join=bevel,tdplot_main_coords, fill opacity=.6] |
| 252 |
|
| 253 |
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}% |
| 254 |
%{0.3}{black}{red}% |
| 255 |
%{0.5*sin(\tdplottheta)*sin(\tdplottheta)}{black}{red}% |
| 256 |
%{0.5*sin(\tdplottheta)*sin(\tdplottheta)*sin(\tdplotphi)*sin(\tdplotphi)}{black}{red}% |
| 257 |
%{0.5*cos(\tdplottheta)*cos(\tdplottheta)}{black}{red}% |
| 258 |
%{0.25*cos(\tdplottheta)}{black}{red}% |
| 259 |
{(sin(\tdplottheta)*cos(\tdplottheta))}{black}{\tdplotphi}% |
| 260 |
%{ .15*(3*cos(\tdplottheta)*cos(\tdplottheta) - 1 )^2}{black}{\tdplotphi} |
| 261 |
{\draw[color=black,thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};}% |
| 262 |
{\draw[color=black,thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};}% |
| 263 |
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}% |
| 264 |
|
| 265 |
\end{tikzpicture} |
| 266 |
\endpgfgraphicnamed |
| 267 |
|
| 268 |
} |
| 269 |
|
| 270 |
\newcommand{\colortest}{% |
| 271 |
\begin{tikzpicture} |
| 272 |
\foreach \thetawheel in {0,1,...,360} |
| 273 |
{ |
| 274 |
%\tdplotcalcrgb{\thetawheel} |
| 275 |
\pgfmathdivide{\thetawheel}{360} |
| 276 |
\definecolor{tdplotcolor}{hsb}{\pgfmathresult, 1, 1} |
| 277 |
\color{tdplotcolor} |
| 278 |
\filldraw(\thetawheel:3) circle (1pt); |
| 279 |
} |
| 280 |
\end{tikzpicture} |
| 281 |
} |