% % polyhedra.sty
% % polyhedra LaTeX package
% % Copyright 2015-2023 Zafeirakis Zafeirakopoulos
% % [email protected]

% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008 or later.

% This work has the LPPL maintenance status `maintained'.

% The Current Maintainer of this work is Zafeirakis Zafeirakopoulos.

% This work consists of the files polyhedra.sty and polyhedra-doc.tex.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Identification    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{polyhedra}[2023/10/31 v.0.3 Polyhedra LaTeX package]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Required Packages  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{xcolor,xcolor-solarized}
\RequirePackage{tikz,tikz-3dplot}
\RequirePackage{xparse,xstring}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Tikz setup   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usetikzlibrary{shapes}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Package Options  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareOption*{\PackageWarning{Polyhedra}{Unknown ‘\CurrentOption’}}
\ProcessOptions\relax

% \PackageWarningNoLine{Polyhedra}{Solarized Color Scheme used}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Default Options  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Default Sizes  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\PolyhedraDefaultHeight}{0.5\textheight}
\newcommand{\PolyhedraDefaultWidth}{0.5\textwidth}
\newcommand{\PolyhedraDefaultScale}{0.6}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Default Colors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\VertexColor}{solarized-blue}
\newcommand{\VertexTextColor}{black}

\newcommand{\EdgeColor}{solarized-blue}
\newcommand{\RayColor}{solarized-cyan}
\newcommand{\PolygonColor}{solarized-blue}
\newcommand{\HalfspaceColor}{gray}

\newcommand{\AlertColor}{solarized-red}
\newcommand{\FocusColor}{solarized-green}
\newcommand{\intersectionColor}{solarized-base2}
\newcommand{\OpenColor}{solarized-base2}

\newcommand{\ShadeColor}{gray}

\newcommand{\OpenPolygonPattern}{north east lines}
\newcommand{\OpenHyperplanePattern}{north west lines}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Default Thickness %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\VertexThickness}{2}
\newcommand{\RayThickness}{1}
\newcommand{\EdgeThickness}{1}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Graphics Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%% Environments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\define@key{polyhedron}{dim}{\def\mm@dim{#1}}
\define@key{polyhedron}{phi}{\def\mm@phi{#1}}
\define@key{polyhedron}{theta}{\def\mm@theta{#1}}
\DeclareDocumentEnvironment{polyhedron}{m}
{
\setkeys{polyhedron}{
dim={2},
phi={0},
theta={0},
,#1 } %
 \ifthenelse{\equal{\mm@dim}{3}}
 {
   \tdplotsetmaincoords{\mm@phi}{\mm@theta}
   \begin{tikzpicture}[scale=\PolyhedraDefaultScale,tdplot_main_coords]
 }{
   \begin{tikzpicture}[scale=\PolyhedraDefaultScale]
  }
}
{
  \end{tikzpicture}
}
\makeatother


%%%%%%%%%%%%%%%%%%%%%%%%%%%% Macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




\def\splicelist#1{
\StrCount{#1}{,}[\numofelem]
\ifnum\numofelem>0\relax
   \StrBefore[1]{#1}{,}[\myhead]%
   \StrBehind[\numofelem]{#1}{,}[\mylast]%
\else
   \let\myhead#1%
   \let\mylast#1%
\fi
}


\newcommand{\point}[2]{
 \coordinate (#2) at #1;
}



\makeatletter


\define@key{vertex}{color}{\def\mm@color{#1}}
\define@key{vertex}{status}{\def\mm@status{#1}}
\define@key{vertex}{opacity}{\def\mm@opacity{#1}}
\define@key{vertex}{thickness}{\def\mm@thickness{#1}}
\define@key{vertex}{pattern}{\def\mm@pattern{#1}}

\define@key{vertex}{point}{\def\mm@point{#1}}

\define@key{vertex}{text}{\def\mm@text{#1}}
\define@key{vertex}{textcolor}{\def\mm@textcolor{#1}}
\define@key{vertex}{anchora}{\def\mm@anchora{#1}}
\define@key{vertex}{anchorb}{\def\mm@anchorb{#1}}
\DeclareDocumentCommand{\vertex}{m}{%
\begingroup%
\setkeys{vertex}{
color=\VertexColor,
opacity={1},
thickness=\VertexThickness,
point={(0,0)},
status={normal},
pattern={},
text={},
anchora={north},
anchorb={above}
,#1 } %
\ifthenelse{\equal{\mm@status}{normal}}{\def\fillcolor{\mm@color}}{
\ifthenelse{\equal{\mm@status}{intesection}}{\def\fillcolor{\IntersectionColor}}
{
\ifthenelse{\equal{\mm@status}{alert}}{\def\fillcolor{\AlertColor}}{
\ifthenelse{\equal{\mm@status}{focus}}{\def\fillcolor{\FocusColor}}{
\ifthenelse{\equal{\mm@status}{open}}{\def\fillcolor{\OpenColor}}{
     \def\fillcolor{\mm@color}
}}}}}

\StrLeft{\mm@point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\mm@point}}{\def\thepoint{(
\mm@point)}}
\ifthenelse{\equal{\mm@text}{}}{\def\thelabel{}}
{\def\thelabel{label={[anchor=\mm@anchora]\mm@anchorb: \mm@text}}}
  \xdef\drawcom{
     node[draw,circle,
     color=\mm@color,
     inner sep=\mm@thickness pt,
     fill=\fillcolor,
     pattern=\mm@pattern,
     pattern color=\mm@color,
     opacity=\mm@opacity,
     \thelabel
     ]
     at \thepoint {} ;
    }
  \draw \drawcom
\endgroup%
}

\define@key{ray}{color}{\def\mm@color{#1}}
\define@key{ray}{opacity}{\def\mm@opacity{#1}}
\define@key{ray}{thickness}{\def\mm@thickness{#1}}
\define@key{ray}{status}{\def\mm@status{#1}}
\define@key{ray}{pattern}{\def\mm@pattern{#1}}

\define@key{ray}{points}{\def\mm@points{#1}}
\DeclareDocumentCommand{\ray}{m}{%
\begingroup%
\setkeys{ray}{
color=\RayColor,
opacity={1},
thickness=\RayThickness,
points={(0,0)},
status={normal},
pattern={},
,#1 } %
\xdef\raypattern{\mm@pattern}

\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor}
}
{
 \ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{
 \ifthenelse{\equal{\mm@status}{open}}{\xdef\raypattern{dashed}\xdef\rcolor{
\mm@color}}{

   \ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{
     \xdef\rcolor{\mm@color}
}}}}}

  \gdef\drawcom{
     [->, color=\rcolor,
     line width=\mm@thickness,
     opacity=\mm@opacity,
     \raypattern]
 }
 \foreach \point [count=\xi] in \mm@points{
     \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}
   \ifnum\xi=1
     \xdef\drawcom{\drawcom  \thepoint}
   \else
     \xdef\drawcom{\drawcom -- \thepoint}
   \fi
 }
 \xdef\drawcom{\drawcom  ;}
 \draw \drawcom
\endgroup%
}


\define@key{edge}{color}{\def\mm@color{#1}}
\define@key{edge}{opacity}{\def\mm@opacity{#1}}
\define@key{edge}{thickness}{\def\mm@thickness{#1}}
\define@key{edge}{status}{\def\mm@status{#1}}
\define@key{edge}{pattern}{\def\mm@pattern{#1}}
\define@key{edge}{points}{\def\mm@points{#1}}
\DeclareDocumentCommand{\edge}{m}{%
\begingroup%
\setkeys{edge}{
color=\EdgeColor,
opacity={1},
thickness=\EdgeThickness,
points={(0,0)},
status={normal},
pattern={},
,#1 } %
\xdef\edgepattern{\mm@pattern}
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor}
}
{
 \ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{

\ifthenelse{\equal{\mm@status}{open}}{\xdef\edgepattern{dashed}\xdef\rcolor{
\mm@color}}{

   \ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{
     \xdef\rcolor{\mm@color}
}}}}}

  \gdef\drawcom{
     [color=\rcolor,
     line width=\mm@thickness,
     opacity=\mm@opacity,
     \edgepattern]
 }
 \foreach \point [count=\xi] in \mm@points{
     \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}
   \ifnum\xi=1
     \xdef\drawcom{\drawcom  \thepoint}
   \else
     \xdef\drawcom{\drawcom -- \thepoint}
   \fi
 }
 \xdef\drawcom{\drawcom  ;}
 \draw \drawcom
\endgroup%
}


\define@key{polygon}{color}{\def\mm@color{#1}}
\define@key{polygon}{status}{\def\mm@status{#1}}
\define@key{polygon}{pattern}{\def\mm@pattern{#1}}
\define@key{polygon}{opacity}{\def\mm@opacity{#1}}
\define@key{polygon}{thickness}{\def\mm@thickness{#1}}

\define@key{polygon}{points}{\def\mm@points{#1}}
\define@key{polygon}{boundary}{\def\mm@boundary{#1}}
\DeclareDocumentCommand{\polygon}{m}{%
\begingroup%
 \setkeys{polygon}{color=\PolygonColor,opacity={1},thickness={1},
points={(0,0)},status={normal},pattern={},boundary={true},#1 } %

\xdef\polygonpattern{\mm@pattern}
\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor}
}
{
 \ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{

\ifthenelse{\equal{\mm@status}{open}}{\xdef\polygonpattern{\OpenPolygonPattern}
\xdef\rcolor {
\mm@color}}{

   \ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{
     \xdef\rcolor{\mm@color}
}}}}}

\ifthenelse{\equal{\mm@boundary}{true}}
{\def\bounddraw{draw=\rcolor}}
{\def\bounddraw{draw=none}}

  \gdef\drawcom{
     [\bounddraw,
     line width=\mm@thickness,
     fill=\rcolor,
     opacity=\mm@opacity,
     pattern=\polygonpattern,
     pattern color=\rcolor
     ]
 }
 \foreach \point [count=\xi] in \mm@points{
    \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}
   \ifnum\xi=1
     \xdef\drawcom{\drawcom  \thepoint}
   \else
     \xdef\drawcom{\drawcom -- \thepoint}
   \fi
 }
 \xdef\drawcom{\drawcom -- cycle ;}
 \draw \drawcom
\endgroup%
}


\define@key{halfspace}{color}{\def\mm@color{#1}}
\define@key{halfspace}{opacity}{\def\mm@opacity{#1}}
\define@key{halfspace}{thickness}{\def\mm@thickness{#1}}
\define@key{halfspace}{points}{\def\mm@points{#1}}
\define@key{halfspace}{status}{\def\mm@status{#1}}
\define@key{halfspace}{pattern}{\def\mm@pattern{#1}}
\define@key{halfspace}{patterncolor}{\def\mm@patterncolor{#1}}
\DeclareDocumentCommand{\halfspace}{m}{%
\begingroup%
 \setkeys{halfspace}{color=blue,opacity={0.7},thickness={1},
points={(0,0)},status={normal},pattern={north west
lines},patterncolor={\HalfspaceColor}
,#1 } %
  \gdef\drawcom{
     [draw=none,color=\mm@color,
     line width=\mm@thickness,
     fill=\mm@color,
     opacity=\mm@opacity,
     pattern=\mm@pattern,
     pattern color=\mm@patterncolor
     ]
 }
 \foreach \point [count=\xi] in \mm@points{
    \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}
   \ifnum\xi=1
     \xdef\drawcom{\drawcom  \thepoint}
   \else
     \xdef\drawcom{\drawcom -- \thepoint}
   \fi
 }
 \xdef\drawcom{\drawcom -- cycle ;}
 \draw \drawcom
\endgroup%
}



\define@key{cone}{color}{\def\mm@color{#1}}
\define@key{cone}{opacity}{\def\mm@opacity{#1}}
\define@key{cone}{thickness}{\def\mm@thickness{#1}}
\define@key{cone}{status}{\def\mm@status{#1}}
\define@key{cone}{pattern}{\def\mm@pattern{#1}}

\define@key{cone}{generators}{\def\mm@generators{#1}}
\define@key{cone}{vertex}{\def\mm@vertex{#1}}
\DeclareDocumentCommand{\cone}{m}{%
\begingroup%
 \setkeys{cone}{color=solarized-blue,opacity={1},thickness={1},
 vertex={(0,0)},generators={(0,0)},status={normal},pattern={north west
lines},#1 } %

\ifthenelse{\equal{\mm@status}{normal}}{\xdef\rcolor{\mm@color}}{
\ifthenelse{\equal{\mm@status}{intesection}}{\xdef\rcolor{\IntersectionColor}
}
{
 \ifthenelse{\equal{\mm@status}{alert}}{\xdef\rcolor{\AlertColor}}{
   \ifthenelse{\equal{\mm@status}{focus}}{\xdef\rcolor{\FocusColor}}{
     \xdef\rcolor{\mm@color}
}}}}

  \gdef\drawcom{
     [->,color=\rcolor,
     line width=\mm@thickness,
     fill=\rcolor,
     opacity=\mm@opacity]
 }

      \StrLeft{\mm@vertex}{1}[\firstletter]
   \ifthenelse{\equal{\firstletter}{(}}
   {\def\thevertex{\mm@vertex}}
   {\def\thevertex{(\mm@vertex)}}

   \gdef\previouspoint{\thevertex}

   \foreach \point in \mm@generators{
      \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}

   \node (xxxxO) at \thevertex {}; % Possible to add generator labels
   \node (xxxxA) at \thepoint {}; % Possible to add generator labels
   \coordinate (xxxxB) at ($(xxxxO)!1.5!(xxxxA)$);
    \draw [dashed,color=\rcolor]  \thevertex -- (xxxxB) ;
    \draw \drawcom  \thevertex  -- (xxxxA) ;
   \ifthenelse{\equal{\previouspoint}{\thevertex}}{}
   {
   \node (xxxxC) at \previouspoint {}; % Possible to add generator labels
   \draw [draw=none,pattern color=\rcolor,pattern=\mm@pattern,opacity=0.6]
 \thevertex -- ($(xxxxO)!1.3!(xxxxC)$)  --
($(xxxxO)!1.3!(xxxxA)$)  ;          }
   \xdef\previouspoint{\thepoint}

}
\endgroup%
}




\define@key{axes}{x}{\def\mm@x{#1}}
\define@key{axes}{y}{\def\mm@y{#1}}
\define@key{axes}{z}{\def\mm@z{#1}}
\define@key{axes}{xlabel}{\def\mm@xlabel{#1}}
\define@key{axes}{ylabel}{\def\mm@ylabel{#1}}
\define@key{axes}{zlabel}{\def\mm@zlabel{#1}}
\define@key{axes}{labels}{\def\mm@labels{#1}}
\DeclareDocumentCommand{\axes}{m}{%
\begingroup%

\setkeys{axes}{x={0,1},y={0,1},z={},xlabel={x},ylabel={y},zlabel={z},labels={
true} , #1 } %

  \splicelist{\mm@x}
   \ifthenelse{\equal{\mm@z}{}}{
   \coordinate (Origin)   at (0,0);
   \splicelist{\mm@x}
   \coordinate (XAxisMin) at (-\myhead,0);
   \coordinate (XAxisMax) at (\mylast,0);
   \coordinate (XLabel) at (\mylast +0.3,0,0);

   \splicelist{\mm@y}
   \coordinate (YAxisMin) at (0,-\myhead);
   \coordinate (YAxisMax) at (0,\mylast);
   \coordinate (YLabel) at (0,\mylast +0.3,0);

   \draw [thin, gray,-latex] (XAxisMin) -- (XAxisMax) ;% Draw x axis
   \draw [thin, gray,-latex] (YAxisMin) -- (YAxisMax);% Draw y axis
  \ifthenelse{\equal{\mm@labels}{no}}{}{
     \node at (XLabel) {\mm@xlabel};
     \node at (YLabel) {\mm@ylabel};
 }

     }{
   \coordinate (Origin)   at (0,0);
   \splicelist{\mm@x}
   \coordinate (XAxisMin) at (-\myhead,0);
   \coordinate (XAxisMax) at (\mylast,0);
   \coordinate (XLabel) at (\mylast +0.3,0,0);

   \splicelist{\mm@y}
   \coordinate (YAxisMin) at (0,-\myhead);
   \coordinate (YAxisMax) at (0,\mylast);
    \coordinate (YLabel) at (0,\mylast +0.3,0);

   \splicelist{\mm@z}
   \coordinate (ZAxisMin) at (0,0,-\myhead);
   \coordinate (ZAxisMax) at (0,0,\mylast);
   \coordinate (ZLabel) at (0,0,\mylast +0.3);

   \draw [thin, gray,-latex] (XAxisMin) -- (XAxisMax) ;% Draw x axis
   \draw [thin, gray,-latex] (YAxisMin) -- (YAxisMax);% Draw y axis
   \draw [thin, gray,-latex] (ZAxisMin) -- (ZAxisMax);% Draw z axis
   \ifthenelse{\equal{\mm@labels}{no}}{}{
       \node at (XLabel) {\mm@xlabel};
       \node at (YLabel) {\mm@ylabel};
       \node at (ZLabel) {\mm@zlabel};
   }

  }



\endgroup%
}





\define@key{hyperplane}{color}{\def\mm@color{#1}}
\define@key{hyperplane}{fill}{\def\mm@fill{#1}}
\define@key{hyperplane}{opacity}{\def\mm@opacity{#1}}
\define@key{hyperplane}{thickness}{\def\mm@thickness{#1}}
\define@key{hyperplane}{points}{\def\mm@points{#1}}
\define@key{hyperplane}{status}{\def\mm@status{#1}}
\define@key{hyperplane}{pattern}{\def\mm@pattern{#1}}
\define@key{hyperplane}{patterncolor}{\def\mm@patterncolor{#1}}
\DeclareDocumentCommand{\hyperplane}{m}{%
\begingroup%
 \setkeys{hyperplane}{color=blue,fill=orange,opacity={0.7},thickness={1},
points={(0,0)},status={normal},pattern={north west
lines},patterncolor={\HalfspaceColor}
,#1 } %
  \gdef\drawcom{
     [draw=none,color=\mm@color,
     line width=\mm@thickness,
     fill=\mm@fill,
     opacity=\mm@opacity,
     pattern=\mm@pattern,
     pattern color=\mm@patterncolor
     ]
 }
 \foreach \point [count=\xi] in \mm@points{
    \StrLeft{\point}{1}[\firstletter]
\ifthenelse{\equal{\firstletter}{(}}{\def\thepoint{\point}}{\def\thepoint{(
\point)}}
   \ifnum\xi=1
     \xdef\drawcom{\drawcom  \thepoint}
   \else
     \xdef\drawcom{\drawcom -- \thepoint}
   \fi
 }
 \xdef\drawcom{\drawcom -- cycle ;}
 \draw \drawcom
\endgroup%
}


\makeatother