|
| 1 | +\documentclass[class=minimal,border=0pt,convert={density=300,outext=.png}]{standalone} |
| 2 | +% \documentclass[class=minimal,border=0pt]{standalone} |
| 3 | +\usepackage[scaled]{helvet} |
| 4 | +\renewcommand*\familydefault{\sfdefault} |
| 5 | + |
| 6 | +% =========================================================================== |
| 7 | +% The code below (used to define the \tikzcuboid command) is copied, |
| 8 | +% unmodified, from a tex.stackexchange.com answer by the user "Tom Bombadil": |
| 9 | +% http://tex.stackexchange.com/a/29882/8335 |
| 10 | +% |
| 11 | +% It is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 12 | +% Unported license: http://creativecommons.org/licenses/by-sa/3.0/ |
| 13 | +% =========================================================================== |
| 14 | + |
| 15 | +\usepackage[usenames,dvipsnames]{color} |
| 16 | +\usepackage{tikz} |
| 17 | +\usepackage{keyval} |
| 18 | +\usepackage{ifthen} |
| 19 | + |
| 20 | +%==================================== |
| 21 | +%emphasize vertices --> switch and emph style (e.g. thick,black) |
| 22 | +%==================================== |
| 23 | +\makeatletter |
| 24 | +% Standard Values for Parameters |
| 25 | +\newcommand{\tikzcuboid@shiftx}{0} |
| 26 | +\newcommand{\tikzcuboid@shifty}{0} |
| 27 | +\newcommand{\tikzcuboid@dimx}{3} |
| 28 | +\newcommand{\tikzcuboid@dimy}{3} |
| 29 | +\newcommand{\tikzcuboid@dimz}{3} |
| 30 | +\newcommand{\tikzcuboid@scale}{1} |
| 31 | +\newcommand{\tikzcuboid@densityx}{1} |
| 32 | +\newcommand{\tikzcuboid@densityy}{1} |
| 33 | +\newcommand{\tikzcuboid@densityz}{1} |
| 34 | +\newcommand{\tikzcuboid@rotation}{0} |
| 35 | +\newcommand{\tikzcuboid@anglex}{0} |
| 36 | +\newcommand{\tikzcuboid@angley}{90} |
| 37 | +\newcommand{\tikzcuboid@anglez}{225} |
| 38 | +\newcommand{\tikzcuboid@scalex}{1} |
| 39 | +\newcommand{\tikzcuboid@scaley}{1} |
| 40 | +\newcommand{\tikzcuboid@scalez}{sqrt(0.5)} |
| 41 | +\newcommand{\tikzcuboid@linefront}{black} |
| 42 | +\newcommand{\tikzcuboid@linetop}{black} |
| 43 | +\newcommand{\tikzcuboid@lineright}{black} |
| 44 | +\newcommand{\tikzcuboid@fillfront}{white} |
| 45 | +\newcommand{\tikzcuboid@filltop}{white} |
| 46 | +\newcommand{\tikzcuboid@fillright}{white} |
| 47 | +\newcommand{\tikzcuboid@shaded}{N} |
| 48 | +\newcommand{\tikzcuboid@shadecolor}{black} |
| 49 | +\newcommand{\tikzcuboid@shadeperc}{25} |
| 50 | +\newcommand{\tikzcuboid@emphedge}{N} |
| 51 | +\newcommand{\tikzcuboid@emphstyle}{thick} |
| 52 | + |
| 53 | +% Definition of Keys |
| 54 | +\define@key{tikzcuboid}{shiftx}[\tikzcuboid@shiftx]{\renewcommand{\tikzcuboid@shiftx}{#1}} |
| 55 | +\define@key{tikzcuboid}{shifty}[\tikzcuboid@shifty]{\renewcommand{\tikzcuboid@shifty}{#1}} |
| 56 | +\define@key{tikzcuboid}{dimx}[\tikzcuboid@dimx]{\renewcommand{\tikzcuboid@dimx}{#1}} |
| 57 | +\define@key{tikzcuboid}{dimy}[\tikzcuboid@dimy]{\renewcommand{\tikzcuboid@dimy}{#1}} |
| 58 | +\define@key{tikzcuboid}{dimz}[\tikzcuboid@dimz]{\renewcommand{\tikzcuboid@dimz}{#1}} |
| 59 | +\define@key{tikzcuboid}{scale}[\tikzcuboid@scale]{\renewcommand{\tikzcuboid@scale}{#1}} |
| 60 | +\define@key{tikzcuboid}{densityx}[\tikzcuboid@densityx]{\renewcommand{\tikzcuboid@densityx}{#1}} |
| 61 | +\define@key{tikzcuboid}{densityy}[\tikzcuboid@densityy]{\renewcommand{\tikzcuboid@densityy}{#1}} |
| 62 | +\define@key{tikzcuboid}{densityz}[\tikzcuboid@densityz]{\renewcommand{\tikzcuboid@densityz}{#1}} |
| 63 | +\define@key{tikzcuboid}{rotation}[\tikzcuboid@rotation]{\renewcommand{\tikzcuboid@rotation}{#1}} |
| 64 | +\define@key{tikzcuboid}{anglex}[\tikzcuboid@anglex]{\renewcommand{\tikzcuboid@anglex}{#1}} |
| 65 | +\define@key{tikzcuboid}{angley}[\tikzcuboid@angley]{\renewcommand{\tikzcuboid@angley}{#1}} |
| 66 | +\define@key{tikzcuboid}{anglez}[\tikzcuboid@anglez]{\renewcommand{\tikzcuboid@anglez}{#1}} |
| 67 | +\define@key{tikzcuboid}{scalex}[\tikzcuboid@scalex]{\renewcommand{\tikzcuboid@scalex}{#1}} |
| 68 | +\define@key{tikzcuboid}{scaley}[\tikzcuboid@scaley]{\renewcommand{\tikzcuboid@scaley}{#1}} |
| 69 | +\define@key{tikzcuboid}{scalez}[\tikzcuboid@scalez]{\renewcommand{\tikzcuboid@scalez}{#1}} |
| 70 | +\define@key{tikzcuboid}{linefront}[\tikzcuboid@linefront]{\renewcommand{\tikzcuboid@linefront}{#1}} |
| 71 | +\define@key{tikzcuboid}{linetop}[\tikzcuboid@linetop]{\renewcommand{\tikzcuboid@linetop}{#1}} |
| 72 | +\define@key{tikzcuboid}{lineright}[\tikzcuboid@lineright]{\renewcommand{\tikzcuboid@lineright}{#1}} |
| 73 | +\define@key{tikzcuboid}{fillfront}[\tikzcuboid@fillfront]{\renewcommand{\tikzcuboid@fillfront}{#1}} |
| 74 | +\define@key{tikzcuboid}{filltop}[\tikzcuboid@filltop]{\renewcommand{\tikzcuboid@filltop}{#1}} |
| 75 | +\define@key{tikzcuboid}{fillright}[\tikzcuboid@fillright]{\renewcommand{\tikzcuboid@fillright}{#1}} |
| 76 | +\define@key{tikzcuboid}{shaded}[\tikzcuboid@shaded]{\renewcommand{\tikzcuboid@shaded}{#1}} |
| 77 | +\define@key{tikzcuboid}{shadecolor}[\tikzcuboid@shadecolor]{\renewcommand{\tikzcuboid@shadecolor}{#1}} |
| 78 | +\define@key{tikzcuboid}{shadeperc}[\tikzcuboid@shadeperc]{\renewcommand{\tikzcuboid@shadeperc}{#1}} |
| 79 | +\define@key{tikzcuboid}{emphedge}[\tikzcuboid@emphedge]{\renewcommand{\tikzcuboid@emphedge}{#1}} |
| 80 | +\define@key{tikzcuboid}{emphstyle}[\tikzcuboid@emphstyle]{\renewcommand{\tikzcuboid@emphstyle}{#1}} |
| 81 | +% Commands |
| 82 | +\newcommand{\tikzcuboid}[1]{ |
| 83 | + \setkeys{tikzcuboid}{#1} % Process Keys passed to command |
| 84 | + \pgfmathsetmacro{\vectorxx}{\tikzcuboid@scalex*cos(\tikzcuboid@anglex)} |
| 85 | + \pgfmathsetmacro{\vectorxy}{\tikzcuboid@scalex*sin(\tikzcuboid@anglex)} |
| 86 | + \pgfmathsetmacro{\vectoryx}{\tikzcuboid@scaley*cos(\tikzcuboid@angley)} |
| 87 | + \pgfmathsetmacro{\vectoryy}{\tikzcuboid@scaley*sin(\tikzcuboid@angley)} |
| 88 | + \pgfmathsetmacro{\vectorzx}{\tikzcuboid@scalez*cos(\tikzcuboid@anglez)} |
| 89 | + \pgfmathsetmacro{\vectorzy}{\tikzcuboid@scalez*sin(\tikzcuboid@anglez)} |
| 90 | + \begin{scope}[xshift=\tikzcuboid@shiftx, yshift=\tikzcuboid@shifty, scale=\tikzcuboid@scale, rotate=\tikzcuboid@rotation, x={(\vectorxx,\vectorxy)}, y={(\vectoryx,\vectoryy)}, z={(\vectorzx,\vectorzy)}] |
| 91 | + \pgfmathsetmacro{\steppingx}{1/\tikzcuboid@densityx} |
| 92 | + \pgfmathsetmacro{\steppingy}{1/\tikzcuboid@densityy} |
| 93 | + \pgfmathsetmacro{\steppingz}{1/\tikzcuboid@densityz} |
| 94 | + \newcommand{\dimx}{\tikzcuboid@dimx} |
| 95 | + \newcommand{\dimy}{\tikzcuboid@dimy} |
| 96 | + \newcommand{\dimz}{\tikzcuboid@dimz} |
| 97 | + \pgfmathsetmacro{\secondx}{2*\steppingx} |
| 98 | + \pgfmathsetmacro{\secondy}{2*\steppingy} |
| 99 | + \pgfmathsetmacro{\secondz}{2*\steppingz} |
| 100 | + \foreach \x in {\steppingx,\secondx,...,\dimx} |
| 101 | + { \foreach \y in {\steppingy,\secondy,...,\dimy} |
| 102 | + { \pgfmathsetmacro{\lowx}{(\x-\steppingx)} |
| 103 | + \pgfmathsetmacro{\lowy}{(\y-\steppingy)} |
| 104 | + \filldraw[fill=\tikzcuboid@fillfront,draw=\tikzcuboid@linefront] (\lowx,\lowy,\dimz) -- (\lowx,\y,\dimz) -- (\x,\y,\dimz) -- (\x,\lowy,\dimz) -- cycle; |
| 105 | + |
| 106 | + } |
| 107 | + } |
| 108 | + \foreach \x in {\steppingx,\secondx,...,\dimx} |
| 109 | + { \foreach \z in {\steppingz,\secondz,...,\dimz} |
| 110 | + { \pgfmathsetmacro{\lowx}{(\x-\steppingx)} |
| 111 | + \pgfmathsetmacro{\lowz}{(\z-\steppingz)} |
| 112 | + \filldraw[fill=\tikzcuboid@filltop,draw=\tikzcuboid@linetop] (\lowx,\dimy,\lowz) -- (\lowx,\dimy,\z) -- (\x,\dimy,\z) -- (\x,\dimy,\lowz) -- cycle; |
| 113 | + } |
| 114 | + } |
| 115 | + \foreach \y in {\steppingy,\secondy,...,\dimy} |
| 116 | + { \foreach \z in {\steppingz,\secondz,...,\dimz} |
| 117 | + { \pgfmathsetmacro{\lowy}{(\y-\steppingy)} |
| 118 | + \pgfmathsetmacro{\lowz}{(\z-\steppingz)} |
| 119 | + \filldraw[fill=\tikzcuboid@fillright,draw=\tikzcuboid@lineright] (\dimx,\lowy,\lowz) -- (\dimx,\lowy,\z) -- (\dimx,\y,\z) -- (\dimx,\y,\lowz) -- cycle; |
| 120 | + } |
| 121 | + } |
| 122 | + \ifthenelse{\equal{\tikzcuboid@emphedge}{Y}}% |
| 123 | + {\draw[\tikzcuboid@emphstyle](0,\dimy,0) -- (\dimx,\dimy,0) -- (\dimx,\dimy,\dimz) -- (0,\dimy,\dimz) -- cycle;% |
| 124 | + \draw[\tikzcuboid@emphstyle] (0,0,\dimz) -- (0,\dimy,\dimz) -- (\dimx,\dimy,\dimz) -- (\dimx,0,\dimz) -- cycle;% |
| 125 | + \draw[\tikzcuboid@emphstyle](\dimx,0,0) -- (\dimx,\dimy,0) -- (\dimx,\dimy,\dimz) -- (\dimx,0,\dimz) -- cycle;% |
| 126 | + }% |
| 127 | + {} |
| 128 | + \end{scope} |
| 129 | +} |
| 130 | + |
| 131 | +\makeatother |
| 132 | + |
| 133 | +\begin{document} |
| 134 | + |
| 135 | +\begin{tikzpicture} |
| 136 | + \tikzcuboid{% |
| 137 | + shiftx=21cm,% |
| 138 | + shifty=8cm,% |
| 139 | + scale=1.00,% |
| 140 | + rotation=0,% |
| 141 | + densityx=2,% |
| 142 | + densityy=2,% |
| 143 | + densityz=2,% |
| 144 | + dimx=4,% |
| 145 | + dimy=3,% |
| 146 | + dimz=3,% |
| 147 | + linefront=purple!75!black,% |
| 148 | + linetop=purple!50!black,% |
| 149 | + lineright=purple!25!black,% |
| 150 | + fillfront=purple!25!white,% |
| 151 | + filltop=purple!50!white,% |
| 152 | + fillright=purple!75!white,% |
| 153 | + emphedge=Y,% |
| 154 | + emphstyle=very thick, |
| 155 | + } |
| 156 | + \tikzcuboid{% |
| 157 | + shiftx=21cm,% |
| 158 | + shifty=11.6cm,% |
| 159 | + scale=1.00,% |
| 160 | + rotation=0,% |
| 161 | + densityx=2,% |
| 162 | + densityy=2,% |
| 163 | + densityz=2,% |
| 164 | + dimx=4,% |
| 165 | + dimy=3,% |
| 166 | + dimz=3,% |
| 167 | + linefront=teal!75!black,% |
| 168 | + linetop=teal!50!black,% |
| 169 | + lineright=teal!25!black,% |
| 170 | + fillfront=teal!25!white,% |
| 171 | + filltop=teal!50!white,% |
| 172 | + fillright=teal!75!white,% |
| 173 | + emphedge=Y,% |
| 174 | + emphstyle=very thick, |
| 175 | + } |
| 176 | + \tikzcuboid{% |
| 177 | + shiftx=26.2cm,% |
| 178 | + shifty=8cm,% |
| 179 | + scale=1.00,% |
| 180 | + rotation=0,% |
| 181 | + densityx=10000,% |
| 182 | + densityy=2,% |
| 183 | + densityz=2,% |
| 184 | + dimx=0,% |
| 185 | + dimy=3,% |
| 186 | + dimz=3,% |
| 187 | + linefront=orange!75!black,% |
| 188 | + linetop=orange!50!black,% |
| 189 | + lineright=orange!25!black,% |
| 190 | + fillfront=orange!25!white,% |
| 191 | + filltop=orange!50!white,% |
| 192 | + fillright=orange!100!white,% |
| 193 | + emphedge=Y,% |
| 194 | + emphstyle=very thick, |
| 195 | + } |
| 196 | + \tikzcuboid{% |
| 197 | + shiftx=27.6cm,% |
| 198 | + shifty=8cm,% |
| 199 | + scale=1.00,% |
| 200 | + rotation=0,% |
| 201 | + densityx=10000,% |
| 202 | + densityy=2,% |
| 203 | + densityz=2,% |
| 204 | + dimx=0,% |
| 205 | + dimy=3,% |
| 206 | + dimz=3,% |
| 207 | + linefront=purple!75!black,% |
| 208 | + linetop=purple!50!black,% |
| 209 | + lineright=purple!25!black,% |
| 210 | + fillfront=purple!25!white,% |
| 211 | + filltop=purple!50!white,% |
| 212 | + fillright=red!75!white,% |
| 213 | + emphedge=Y,% |
| 214 | + emphstyle=very thick, |
| 215 | + } |
| 216 | + % \tikzcuboid{% |
| 217 | + % shiftx=25.8cm,% |
| 218 | + % shifty=12cm,% |
| 219 | + % scale=1.00,% |
| 220 | + % rotation=0,% |
| 221 | + % densityx=2,% |
| 222 | + % densityx=2,% |
| 223 | + % densityy=100,% |
| 224 | + % densityz=100,% |
| 225 | + % dimx=4,% |
| 226 | + % dimy=0,% |
| 227 | + % dimz=0,% |
| 228 | + % emphedge=Y,% |
| 229 | + % emphstyle=very thick, |
| 230 | + % } |
| 231 | + \tikzcuboid{% |
| 232 | + shiftx=25.8cm,% |
| 233 | + shifty=11.6cm,% |
| 234 | + scale=1.00,% |
| 235 | + rotation=0,% |
| 236 | + densityx=100,% |
| 237 | + densityy=2,% |
| 238 | + densityz=100,% |
| 239 | + dimx=0,% |
| 240 | + dimy=3,% |
| 241 | + dimz=0,% |
| 242 | + emphedge=Y,% |
| 243 | + emphstyle=very thick, |
| 244 | + } |
| 245 | + \tikzcuboid{% |
| 246 | + shiftx=25.8cm,% |
| 247 | + shifty=11.6cm,% |
| 248 | + scale=1.00,% |
| 249 | + rotation=180,% |
| 250 | + densityx=100,% |
| 251 | + densityy=100,% |
| 252 | + densityz=2,% |
| 253 | + dimx=0,% |
| 254 | + dimy=0,% |
| 255 | + dimz=3,% |
| 256 | + emphedge=Y,% |
| 257 | + emphstyle=very thick, |
| 258 | + } |
| 259 | + \fill (27,11.6) circle[radius=2pt]; |
| 260 | +\end{tikzpicture} |
| 261 | + |
| 262 | +\end{document} |
0 commit comments