| 1 |
% % polyhedra.sty |
| 2 |
% % polyhedra LaTeX package |
| 3 |
% % Copyright 2015-2023 Zafeirakis Zafeirakopoulos |
| 4 |
% % [email protected] |
| 5 |
|
| 6 |
% This work may be distributed and/or modified under the |
| 7 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 8 |
% of this license or (at your option) any later version. |
| 9 |
% The latest version of this license is in |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 12 |
% version 2008 or later. |
| 13 |
|
| 14 |
% This work has the LPPL maintenance status `maintained'. |
| 15 |
|
| 16 |
% The Current Maintainer of this work is Zafeirakis Zafeirakopoulos. |
| 17 |
|
| 18 |
% This work consists of the files polyhedra.sty and polyhedra-doc.tex. |
| 19 |
|
| 20 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 21 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Identification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 22 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 23 |
|
| 24 |
\NeedsTeXFormat{LaTeX2e} |
| 25 |
\ProvidesPackage{polyhedra}[2023/10/31 v.0.3 Polyhedra LaTeX package] |
| 26 |
|
| 27 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 28 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Required Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 29 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 30 |
\RequirePackage{xcolor,xcolor-solarized} |
| 31 |
\RequirePackage{tikz,tikz-3dplot} |
| 32 |
\RequirePackage{xparse,xstring} |
| 33 |
|
| 34 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Tikz setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 |
|
| 38 |
\usetikzlibrary{shapes} |
| 39 |
\usetikzlibrary{patterns} |
| 40 |
\usetikzlibrary{arrows} |
| 41 |
|
| 42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Package Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 44 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 45 |
|
| 46 |
\DeclareOption*{\PackageWarning{Polyhedra}{Unknown ‘\CurrentOption’}} |
| 47 |
\ProcessOptions\relax |
| 48 |
|
| 49 |
% \PackageWarningNoLine{Polyhedra}{Solarized Color Scheme used} |
| 50 |
|
| 51 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 52 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Default Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 53 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 54 |
|
| 55 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Default Sizes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 56 |
\newcommand{\PolyhedraDefaultHeight}{0.5\textheight} |
| 57 |
\newcommand{\PolyhedraDefaultWidth}{0.5\textwidth} |
| 58 |
\newcommand{\PolyhedraDefaultScale}{0.6} |
| 59 |
|
| 60 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 61 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Default Colors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 62 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 63 |
|
| 64 |
\newcommand{\VertexColor}{solarized-blue} |
| 65 |
\newcommand{\VertexTextColor}{black} |
| 66 |
|
| 67 |
\newcommand{\EdgeColor}{solarized-blue} |
| 68 |
\newcommand{\RayColor}{solarized-cyan} |
| 69 |
\newcommand{\PolygonColor}{solarized-blue} |
| 70 |
\newcommand{\HalfspaceColor}{gray} |
| 71 |
|
| 72 |
\newcommand{\AlertColor}{solarized-red} |
| 73 |
\newcommand{\FocusColor}{solarized-green} |
| 74 |
\newcommand{\intersectionColor}{solarized-base2} |
| 75 |
\newcommand{\OpenColor}{solarized-base2} |
| 76 |
|
| 77 |
\newcommand{\ShadeColor}{gray} |
| 78 |
|
| 79 |
\newcommand{\OpenPolygonPattern}{north east lines} |
| 80 |
\newcommand{\OpenHyperplanePattern}{north west lines} |
| 81 |
|
| 82 |
|
| 83 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 84 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Default Thickness %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 85 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 86 |
|
| 87 |
\newcommand{\VertexThickness}{2} |
| 88 |
\newcommand{\RayThickness}{1} |
| 89 |
\newcommand{\EdgeThickness}{1} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 95 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Graphics Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 96 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 97 |
|
| 98 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Environments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 99 |
\makeatletter |
| 100 |
\define@key{polyhedron}{dim}{\def\mm@dim{#1}} |
| 101 |
\define@key{polyhedron}{phi}{\def\mm@phi{#1}} |
| 102 |
\define@key{polyhedron}{theta}{\def\mm@theta{#1}} |
| 103 |
\DeclareDocumentEnvironment{polyhedron}{m} |
| 104 |
{ |
| 105 |
\setkeys{polyhedron}{ |
| 106 |
dim={2}, |
| 107 |
phi={0}, |
| 108 |
theta={0}, |
| 109 |
,#1 } % |
| 110 |
\ifthenelse{\equal{\mm@dim}{3}} |
| 111 |
{ |
| 112 |
\tdplotsetmaincoords{\mm@phi}{\mm@theta} |
| 113 |
\begin{tikzpicture}[scale=\PolyhedraDefaultScale,tdplot_main_coords] |
| 114 |
}{ |
| 115 |
\begin{tikzpicture}[scale=\PolyhedraDefaultScale] |
| 116 |
} |
| 117 |
} |
| 118 |
{ |
| 119 |
\end{tikzpicture} |
| 120 |
} |
| 121 |
\makeatother |
| 122 |
|
| 123 |
|
| 124 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
\def\splicelist#1{ |
| 130 |
\StrCount{#1}{,}[\numofelem] |
| 131 |
\ifnum\numofelem>0\relax |
| 132 |
\StrBefore[1]{#1}{,}[\myhead]% |
| 133 |
\StrBehind[\numofelem]{#1}{,}[\mylast]% |
| 134 |
\else |
| 135 |
\let\myhead#1% |
| 136 |
\let\mylast#1% |
| 137 |
\fi |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
\newcommand{\point}[2]{ |
| 142 |
\coordinate (#2) at #1; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
\makeatletter |
| 148 |
|
| 149 |
|
| 150 |
\define@key{vertex}{color}{\def\mm@color{#1}} |
| 151 |
\define@key{vertex}{status}{\def\mm@status{#1}} |
| 152 |
\define@key{vertex}{opacity}{\def\mm@opacity{#1}} |
| 153 |
\define@key{vertex}{thickness}{\def\mm@thickness{#1}} |
| 154 |
\define@key{vertex}{pattern}{\def\mm@pattern{#1}} |
| 155 |
|
| 156 |
\define@key{vertex}{point}{\def\mm@point{#1}} |
| 157 |
|
| 158 |
\define@key{vertex}{text}{\def\mm@text{#1}} |
| 159 |
\define@key{vertex}{textcolor}{\def\mm@textcolor{#1}} |
| 160 |
\define@key{vertex}{anchora}{\def\mm@anchora{#1}} |
| 161 |
\define@key{vertex}{anchorb}{\def\mm@anchorb{#1}} |
| 162 |
\DeclareDocumentCommand{\vertex}{m}{% |
| 163 |
\begingroup% |
| 164 |
\setkeys{vertex}{ |
| 165 |
color=\VertexColor, |
| 166 |
opacity={1}, |
| 167 |
thickness=\VertexThickness, |
| 168 |
point={(0,0)}, |
| 169 |
status={normal}, |
| 170 |
pattern={}, |
| 171 |
text={}, |
| 172 |
anchora={north}, |
| 173 |
anchorb={above} |
| 174 |
,#1 } % |
| 175 |
\ifthenelse{\equal{\mm@status}{normal}}{\def\fillcolor{\mm@color}}{ |
| 176 |
\ifthenelse{\equal{\mm@status}{intesection}}{\def\fillcolor{\IntersectionColor}} |
| 177 |
{ |
| 178 |
\ifthenelse{\equal{\mm@status}{alert}}{\def\fillcolor{\AlertColor}}{ |
| 179 |
\ifthenelse{\equal{\mm@status}{focus}}{\def\fillcolor{\FocusColor}}{ |
| 180 |
\ifthenelse{\equal{\mm@status}{open}}{\def\fillcolor{\OpenColor}}{ |
| 181 |
\def\fillcolor{\mm@color} |
| 182 |
}}}}} |
| 183 |
|
| 184 |
\StrLeft{\mm@point}{1}[\firstletter] |
| 185 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\mm@point}}{\def\thepoint{( |
| 186 |
\mm@point)}} |
| 187 |
\ifthenelse{\equal{\mm@text}{}}{\def\thelabel{}} |
| 188 |
{\def\thelabel{label={[anchor=\mm@anchora]\mm@anchorb: \mm@text}}} |
| 189 |
\xdef\drawcom{ |
| 190 |
node[draw,circle, |
| 191 |
color=\mm@color, |
| 192 |
inner sep=\mm@thickness pt, |
| 193 |
fill=\fillcolor, |
| 194 |
pattern=\mm@pattern, |
| 195 |
pattern color=\mm@color, |
| 196 |
opacity=\mm@opacity, |
| 197 |
\thelabel |
| 198 |
] |
| 199 |
at \thepoint {} ; |
| 200 |
} |
| 201 |
\draw \drawcom |
| 202 |
\endgroup% |
| 203 |
} |
| 204 |
|
| 205 |
\define@key{ray}{color}{\def\mm@color{#1}} |
| 206 |
\define@key{ray}{opacity}{\def\mm@opacity{#1}} |
| 207 |
\define@key{ray}{thickness}{\def\mm@thickness{#1}} |
| 208 |
\define@key{ray}{status}{\def\mm@status{#1}} |
| 209 |
\define@key{ray}{pattern}{\def\mm@pattern{#1}} |
| 210 |
|
| 211 |
\define@key{ray}{points}{\def\mm@points{#1}} |
| 212 |
\DeclareDocumentCommand{\ray}{m}{% |
| 213 |
\begingroup% |
| 214 |
\setkeys{ray}{ |
| 215 |
color=\RayColor, |
| 216 |
opacity={1}, |
| 217 |
thickness=\RayThickness, |
| 218 |
points={(0,0)}, |
| 219 |
status={normal}, |
| 220 |
pattern={}, |
| 221 |
,#1 } % |
| 222 |
\xdef\raypattern{\mm@pattern} |
| 223 |
|
| 224 |
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{ |
| 225 |
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor} |
| 226 |
} |
| 227 |
{ |
| 228 |
\ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{ |
| 229 |
\ifthenelse{\equal{\mm@status}{open}}{\xdef\raypattern{dashed}\xdef\rcolor{ |
| 230 |
\mm@color}}{ |
| 231 |
|
| 232 |
\ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{ |
| 233 |
\xdef\rcolor{\mm@color} |
| 234 |
}}}}} |
| 235 |
|
| 236 |
\gdef\drawcom{ |
| 237 |
[->, color=\rcolor, |
| 238 |
line width=\mm@thickness, |
| 239 |
opacity=\mm@opacity, |
| 240 |
\raypattern] |
| 241 |
} |
| 242 |
\foreach \point [count=\xi] in \mm@points{ |
| 243 |
\StrLeft{\point}{1}[\firstletter] |
| 244 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 245 |
\point)}} |
| 246 |
\ifnum\xi=1 |
| 247 |
\xdef\drawcom{\drawcom \thepoint} |
| 248 |
\else |
| 249 |
\xdef\drawcom{\drawcom -- \thepoint} |
| 250 |
\fi |
| 251 |
} |
| 252 |
\xdef\drawcom{\drawcom ;} |
| 253 |
\draw \drawcom |
| 254 |
\endgroup% |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
\define@key{edge}{color}{\def\mm@color{#1}} |
| 259 |
\define@key{edge}{opacity}{\def\mm@opacity{#1}} |
| 260 |
\define@key{edge}{thickness}{\def\mm@thickness{#1}} |
| 261 |
\define@key{edge}{status}{\def\mm@status{#1}} |
| 262 |
\define@key{edge}{pattern}{\def\mm@pattern{#1}} |
| 263 |
\define@key{edge}{points}{\def\mm@points{#1}} |
| 264 |
\DeclareDocumentCommand{\edge}{m}{% |
| 265 |
\begingroup% |
| 266 |
\setkeys{edge}{ |
| 267 |
color=\EdgeColor, |
| 268 |
opacity={1}, |
| 269 |
thickness=\EdgeThickness, |
| 270 |
points={(0,0)}, |
| 271 |
status={normal}, |
| 272 |
pattern={}, |
| 273 |
,#1 } % |
| 274 |
\xdef\edgepattern{\mm@pattern} |
| 275 |
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{ |
| 276 |
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor} |
| 277 |
} |
| 278 |
{ |
| 279 |
\ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{ |
| 280 |
|
| 281 |
\ifthenelse{\equal{\mm@status}{open}}{\xdef\edgepattern{dashed}\xdef\rcolor{ |
| 282 |
\mm@color}}{ |
| 283 |
|
| 284 |
\ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{ |
| 285 |
\xdef\rcolor{\mm@color} |
| 286 |
}}}}} |
| 287 |
|
| 288 |
\gdef\drawcom{ |
| 289 |
[color=\rcolor, |
| 290 |
line width=\mm@thickness, |
| 291 |
opacity=\mm@opacity, |
| 292 |
\edgepattern] |
| 293 |
} |
| 294 |
\foreach \point [count=\xi] in \mm@points{ |
| 295 |
\StrLeft{\point}{1}[\firstletter] |
| 296 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 297 |
\point)}} |
| 298 |
\ifnum\xi=1 |
| 299 |
\xdef\drawcom{\drawcom \thepoint} |
| 300 |
\else |
| 301 |
\xdef\drawcom{\drawcom -- \thepoint} |
| 302 |
\fi |
| 303 |
} |
| 304 |
\xdef\drawcom{\drawcom ;} |
| 305 |
\draw \drawcom |
| 306 |
\endgroup% |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
\define@key{polygon}{color}{\def\mm@color{#1}} |
| 311 |
\define@key{polygon}{status}{\def\mm@status{#1}} |
| 312 |
\define@key{polygon}{pattern}{\def\mm@pattern{#1}} |
| 313 |
\define@key{polygon}{opacity}{\def\mm@opacity{#1}} |
| 314 |
\define@key{polygon}{thickness}{\def\mm@thickness{#1}} |
| 315 |
|
| 316 |
\define@key{polygon}{points}{\def\mm@points{#1}} |
| 317 |
\define@key{polygon}{boundary}{\def\mm@boundary{#1}} |
| 318 |
\DeclareDocumentCommand{\polygon}{m}{% |
| 319 |
\begingroup% |
| 320 |
\setkeys{polygon}{color=\PolygonColor,opacity={1},thickness={1}, |
| 321 |
points={(0,0)},status={normal},pattern={},boundary={true},#1 } % |
| 322 |
|
| 323 |
\xdef\polygonpattern{\mm@pattern} |
| 324 |
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{ |
| 325 |
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor} |
| 326 |
} |
| 327 |
{ |
| 328 |
\ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{ |
| 329 |
|
| 330 |
\ifthenelse{\equal{\mm@status}{open}}{\xdef\polygonpattern{\OpenPolygonPattern} |
| 331 |
\xdef\rcolor { |
| 332 |
\mm@color}}{ |
| 333 |
|
| 334 |
\ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{ |
| 335 |
\xdef\rcolor{\mm@color} |
| 336 |
}}}}} |
| 337 |
|
| 338 |
\ifthenelse{\equal{\mm@boundary}{true}} |
| 339 |
{\def\bounddraw{draw=\rcolor}} |
| 340 |
{\def\bounddraw{draw=none}} |
| 341 |
|
| 342 |
\gdef\drawcom{ |
| 343 |
[\bounddraw, |
| 344 |
line width=\mm@thickness, |
| 345 |
fill=\rcolor, |
| 346 |
opacity=\mm@opacity, |
| 347 |
pattern=\polygonpattern, |
| 348 |
pattern color=\rcolor |
| 349 |
] |
| 350 |
} |
| 351 |
\foreach \point [count=\xi] in \mm@points{ |
| 352 |
\StrLeft{\point}{1}[\firstletter] |
| 353 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 354 |
\point)}} |
| 355 |
\ifnum\xi=1 |
| 356 |
\xdef\drawcom{\drawcom \thepoint} |
| 357 |
\else |
| 358 |
\xdef\drawcom{\drawcom -- \thepoint} |
| 359 |
\fi |
| 360 |
} |
| 361 |
\xdef\drawcom{\drawcom -- cycle ;} |
| 362 |
\draw \drawcom |
| 363 |
\endgroup% |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
\define@key{halfspace}{color}{\def\mm@color{#1}} |
| 368 |
\define@key{halfspace}{opacity}{\def\mm@opacity{#1}} |
| 369 |
\define@key{halfspace}{thickness}{\def\mm@thickness{#1}} |
| 370 |
\define@key{halfspace}{points}{\def\mm@points{#1}} |
| 371 |
\define@key{halfspace}{status}{\def\mm@status{#1}} |
| 372 |
\define@key{halfspace}{pattern}{\def\mm@pattern{#1}} |
| 373 |
\define@key{halfspace}{patterncolor}{\def\mm@patterncolor{#1}} |
| 374 |
\DeclareDocumentCommand{\halfspace}{m}{% |
| 375 |
\begingroup% |
| 376 |
\setkeys{halfspace}{color=blue,opacity={0.7},thickness={1}, |
| 377 |
points={(0,0)},status={normal},pattern={north west |
| 378 |
lines},patterncolor={\HalfspaceColor} |
| 379 |
,#1 } % |
| 380 |
\gdef\drawcom{ |
| 381 |
[draw=none,color=\mm@color, |
| 382 |
line width=\mm@thickness, |
| 383 |
fill=\mm@color, |
| 384 |
opacity=\mm@opacity, |
| 385 |
pattern=\mm@pattern, |
| 386 |
pattern color=\mm@patterncolor |
| 387 |
] |
| 388 |
} |
| 389 |
\foreach \point [count=\xi] in \mm@points{ |
| 390 |
\StrLeft{\point}{1}[\firstletter] |
| 391 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 392 |
\point)}} |
| 393 |
\ifnum\xi=1 |
| 394 |
\xdef\drawcom{\drawcom \thepoint} |
| 395 |
\else |
| 396 |
\xdef\drawcom{\drawcom -- \thepoint} |
| 397 |
\fi |
| 398 |
} |
| 399 |
\xdef\drawcom{\drawcom -- cycle ;} |
| 400 |
\draw \drawcom |
| 401 |
\endgroup% |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
\define@key{cone}{color}{\def\mm@color{#1}} |
| 407 |
\define@key{cone}{opacity}{\def\mm@opacity{#1}} |
| 408 |
\define@key{cone}{thickness}{\def\mm@thickness{#1}} |
| 409 |
\define@key{cone}{status}{\def\mm@status{#1}} |
| 410 |
\define@key{cone}{pattern}{\def\mm@pattern{#1}} |
| 411 |
|
| 412 |
\define@key{cone}{generators}{\def\mm@generators{#1}} |
| 413 |
\define@key{cone}{vertex}{\def\mm@vertex{#1}} |
| 414 |
\DeclareDocumentCommand{\cone}{m}{% |
| 415 |
\begingroup% |
| 416 |
\setkeys{cone}{color=solarized-blue,opacity={1},thickness={1}, |
| 417 |
vertex={(0,0)},generators={(0,0)},status={normal},pattern={north west |
| 418 |
lines},#1 } % |
| 419 |
|
| 420 |
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{ |
| 421 |
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor} |
| 422 |
} |
| 423 |
{ |
| 424 |
\ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{ |
| 425 |
\ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{ |
| 426 |
\xdef\rcolor{\mm@color} |
| 427 |
}}}} |
| 428 |
|
| 429 |
\gdef\drawcom{ |
| 430 |
[->,color=\rcolor, |
| 431 |
line width=\mm@thickness, |
| 432 |
fill=\rcolor, |
| 433 |
opacity=\mm@opacity] |
| 434 |
} |
| 435 |
|
| 436 |
\StrLeft{\mm@vertex}{1}[\firstletter] |
| 437 |
\ifthenelse{\equal{\firstletter}{(}} |
| 438 |
{\def\thevertex{\mm@vertex}} |
| 439 |
{\def\thevertex{(\mm@vertex)}} |
| 440 |
|
| 441 |
\gdef\previouspoint{\thevertex} |
| 442 |
|
| 443 |
\foreach \point in \mm@generators{ |
| 444 |
\StrLeft{\point}{1}[\firstletter] |
| 445 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 446 |
\point)}} |
| 447 |
|
| 448 |
\node (xxxxO) at \thevertex {}; % Possible to add generator labels |
| 449 |
\node (xxxxA) at \thepoint {}; % Possible to add generator labels |
| 450 |
\coordinate (xxxxB) at ($(xxxxO)!1.5!(xxxxA)$); |
| 451 |
\draw [dashed,color=\rcolor] \thevertex -- (xxxxB) ; |
| 452 |
\draw \drawcom \thevertex -- (xxxxA) ; |
| 453 |
\ifthenelse{\equal{\previouspoint}{\thevertex}}{} |
| 454 |
{ |
| 455 |
\node (xxxxC) at \previouspoint {}; % Possible to add generator labels |
| 456 |
\draw [draw=none,pattern color=\rcolor,pattern=\mm@pattern,opacity=0.6] |
| 457 |
\thevertex -- ($(xxxxO)!1.3!(xxxxC)$) -- |
| 458 |
($(xxxxO)!1.3!(xxxxA)$) ; } |
| 459 |
\xdef\previouspoint{\thepoint} |
| 460 |
|
| 461 |
} |
| 462 |
\endgroup% |
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
\define@key{axes}{x}{\def\mm@x{#1}} |
| 469 |
\define@key{axes}{y}{\def\mm@y{#1}} |
| 470 |
\define@key{axes}{z}{\def\mm@z{#1}} |
| 471 |
\define@key{axes}{xlabel}{\def\mm@xlabel{#1}} |
| 472 |
\define@key{axes}{ylabel}{\def\mm@ylabel{#1}} |
| 473 |
\define@key{axes}{zlabel}{\def\mm@zlabel{#1}} |
| 474 |
\define@key{axes}{labels}{\def\mm@labels{#1}} |
| 475 |
\DeclareDocumentCommand{\axes}{m}{% |
| 476 |
\begingroup% |
| 477 |
|
| 478 |
\setkeys{axes}{x={0,1},y={0,1},z={},xlabel={x},ylabel={y},zlabel={z},labels={ |
| 479 |
true} , #1 } % |
| 480 |
|
| 481 |
\splicelist{\mm@x} |
| 482 |
\ifthenelse{\equal{\mm@z}{}}{ |
| 483 |
\coordinate (Origin) at (0,0); |
| 484 |
\splicelist{\mm@x} |
| 485 |
\coordinate (XAxisMin) at (-\myhead,0); |
| 486 |
\coordinate (XAxisMax) at (\mylast,0); |
| 487 |
\coordinate (XLabel) at (\mylast +0.3,0,0); |
| 488 |
|
| 489 |
\splicelist{\mm@y} |
| 490 |
\coordinate (YAxisMin) at (0,-\myhead); |
| 491 |
\coordinate (YAxisMax) at (0,\mylast); |
| 492 |
\coordinate (YLabel) at (0,\mylast +0.3,0); |
| 493 |
|
| 494 |
\draw [thin, gray,-latex] (XAxisMin) -- (XAxisMax) ;% Draw x axis |
| 495 |
\draw [thin, gray,-latex] (YAxisMin) -- (YAxisMax);% Draw y axis |
| 496 |
\ifthenelse{\equal{\mm@labels}{no}}{}{ |
| 497 |
\node at (XLabel) {\mm@xlabel}; |
| 498 |
\node at (YLabel) {\mm@ylabel}; |
| 499 |
} |
| 500 |
|
| 501 |
}{ |
| 502 |
\coordinate (Origin) at (0,0); |
| 503 |
\splicelist{\mm@x} |
| 504 |
\coordinate (XAxisMin) at (-\myhead,0); |
| 505 |
\coordinate (XAxisMax) at (\mylast,0); |
| 506 |
\coordinate (XLabel) at (\mylast +0.3,0,0); |
| 507 |
|
| 508 |
\splicelist{\mm@y} |
| 509 |
\coordinate (YAxisMin) at (0,-\myhead); |
| 510 |
\coordinate (YAxisMax) at (0,\mylast); |
| 511 |
\coordinate (YLabel) at (0,\mylast +0.3,0); |
| 512 |
|
| 513 |
\splicelist{\mm@z} |
| 514 |
\coordinate (ZAxisMin) at (0,0,-\myhead); |
| 515 |
\coordinate (ZAxisMax) at (0,0,\mylast); |
| 516 |
\coordinate (ZLabel) at (0,0,\mylast +0.3); |
| 517 |
|
| 518 |
\draw [thin, gray,-latex] (XAxisMin) -- (XAxisMax) ;% Draw x axis |
| 519 |
\draw [thin, gray,-latex] (YAxisMin) -- (YAxisMax);% Draw y axis |
| 520 |
\draw [thin, gray,-latex] (ZAxisMin) -- (ZAxisMax);% Draw z axis |
| 521 |
\ifthenelse{\equal{\mm@labels}{no}}{}{ |
| 522 |
\node at (XLabel) {\mm@xlabel}; |
| 523 |
\node at (YLabel) {\mm@ylabel}; |
| 524 |
\node at (ZLabel) {\mm@zlabel}; |
| 525 |
} |
| 526 |
|
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
\endgroup% |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
\define@key{hyperplane}{color}{\def\mm@color{#1}} |
| 539 |
\define@key{hyperplane}{fill}{\def\mm@fill{#1}} |
| 540 |
\define@key{hyperplane}{opacity}{\def\mm@opacity{#1}} |
| 541 |
\define@key{hyperplane}{thickness}{\def\mm@thickness{#1}} |
| 542 |
\define@key{hyperplane}{points}{\def\mm@points{#1}} |
| 543 |
\define@key{hyperplane}{status}{\def\mm@status{#1}} |
| 544 |
\define@key{hyperplane}{pattern}{\def\mm@pattern{#1}} |
| 545 |
\define@key{hyperplane}{patterncolor}{\def\mm@patterncolor{#1}} |
| 546 |
\DeclareDocumentCommand{\hyperplane}{m}{% |
| 547 |
\begingroup% |
| 548 |
\setkeys{hyperplane}{color=blue,fill=orange,opacity={0.7},thickness={1}, |
| 549 |
points={(0,0)},status={normal},pattern={north west |
| 550 |
lines},patterncolor={\HalfspaceColor} |
| 551 |
,#1 } % |
| 552 |
\gdef\drawcom{ |
| 553 |
[draw=none,color=\mm@color, |
| 554 |
line width=\mm@thickness, |
| 555 |
fill=\mm@fill, |
| 556 |
opacity=\mm@opacity, |
| 557 |
pattern=\mm@pattern, |
| 558 |
pattern color=\mm@patterncolor |
| 559 |
] |
| 560 |
} |
| 561 |
\foreach \point [count=\xi] in \mm@points{ |
| 562 |
\StrLeft{\point}{1}[\firstletter] |
| 563 |
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{( |
| 564 |
\point)}} |
| 565 |
\ifnum\xi=1 |
| 566 |
\xdef\drawcom{\drawcom \thepoint} |
| 567 |
\else |
| 568 |
\xdef\drawcom{\drawcom -- \thepoint} |
| 569 |
\fi |
| 570 |
} |
| 571 |
\xdef\drawcom{\drawcom -- cycle ;} |
| 572 |
\draw \drawcom |
| 573 |
\endgroup% |
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
\makeatother |