Skip to content

Instantly share code, notes, and snippets.

@andreasgrv
Last active July 14, 2024 11:56
Show Gist options
  • Select an option

  • Save andreasgrv/22efd2c49bb8991ab025ce8f83635bda to your computer and use it in GitHub Desktop.

Select an option

Save andreasgrv/22efd2c49bb8991ab025ce8f83635bda to your computer and use it in GitHub Desktop.
Boolean Hyperplane Arrangement in TikZ
% Built based on https://tikz.net/3d-plane-and-normal-vector/
\documentclass[crop,tikz]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{matrix,math,tikzmark,intersections,through,backgrounds,shadows,scopes,fit,calc,patterns,quotes,arrows.meta,positioning, shapes.geometric}
\definecolor{clr1}{RGB}{228,26,28}
\definecolor{clr2}{RGB}{55,126,184}
\definecolor{clr3}{RGB}{77,175,74}
\definecolor{clr4}{RGB}{152,78,163}
\begin{document}
\begin{tikzpicture}[x={(1cm,.2cm)}, y={(.5cm, -.5cm)}, z={(0cm,1.1cm)}, scale=1]
\begin{scope}
%Axis
\node[yshift=-.2em] (O) at (0,0,0) {};
\def\s{1.7}
\def\p{1.1}
\draw[-latex] (-\s,0,0) -- (\s,0,0) node[pos = 1.05] {$x$};
\draw[-latex] (0,-\s,0) -- (0,\s,0) node[pos = 1.08] {$y$};
\draw[-latex] (0,0,0) -- (0,0,\s) node[pos = 1.08] {$z$};
\coordinate (e1) at (1, 0, 0);
\coordinate (e2) at (0, 1, 0);
\coordinate (e3) at (0, 0, 1);
\coordinate (x1) at (0, \p, \p);
\coordinate (x2) at (0, \p, -\p);
\coordinate (x3) at (0, -\p, -\p);
\coordinate (x4) at (0, -\p, \p);
\path[draw=black, fill=clr3, thick, opacity=.25] (x1) -- (x2) -- (x3) -- (x4) -- (x1);
\coordinate (y1) at ( \p, 0, \p);
\coordinate (y2) at ( \p, 0, -\p);
\coordinate (y3) at (-\p, 0, -\p);
\coordinate (y4) at (-\p, 0, \p);
\path[draw=black, fill=clr2, thick, opacity=.25] (y1) -- (y2) -- (y3) -- (y4) -- (y1);
\coordinate (z1) at ( \p, \p, 0);
\coordinate (z2) at ( \p, -\p, 0);
\coordinate (z3) at (-\p, -\p, 0);
\coordinate (z4) at (-\p, \p, 0);
\path[draw=black, fill=clr1, thick, opacity=.25] (z1) -- (z2) -- (z3) -- (z4) -- (z1);
\draw[-{Latex[length=2mm]}, thick, font=\scriptsize, clr3] (0, 0, 0) to node[at end, left, yshift=.4em]{$\mathbf{e}_1$} (e1);
\draw[-{Latex[length=2mm]}, thick, font=\scriptsize, clr2] (0, 0, 0) to node[at end, left, xshift=-.1em]{$\mathbf{e}_2$} (e2);
\draw[-{Latex[length=2mm]}, thick, font=\scriptsize, clr1] (0, 0, 0) to node[at end, left, xshift=.1em]{$\mathbf{e}_3$} (e3);
\end{scope}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment