Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· openaiHugging Face Suzhen/CodeChat

Please give a latex code using TiKZ for drawing a boundry of a 3-dimensional simplex

  1. User

    Please give a latex code using TiKZ for drawing a boundry of a 3-dimensional simplex

  2. Assistant

    You can use the following LaTeX code to draw the boundary of the 3D simplex using TikZ:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{calc, positioning}
    
    \begin{document}
    \begin{tikzpicture}[
        label distance=1.5mm,
        vertex/.style={circle, minimum size=0.1cm, fill=black, inner sep=0}
    ]
      \node[vertex, label=left:{$A(x_1, y_1, z_1)$}] (A) at (0, 0) {};
      \node[vertex, label=below:{$B(x_2, y_2, z_2)$}] (B) at (3, 0) {};
      \node[vertex, label=left:{$D(x_4, y_4, z_4)$}] (D) at (1, 2) {};
      \node[vertex, label=right:{$C(x_3, y_3, z_3)$}] (C) at ($(B) + (D) - (A)$) {};
    
      \foreach \u/\strategy [remember=\u as \lastu (initially C), remember=\strategy as \laststrategy (initially 0)] in {A/1,D/1,B/1,C/1,A/2,D/2,B/2,C/2} {
        \global\let\lastu=\u
        \xdef\laststrategy{\strategy}
        \node at ($(\u)!\strategy*(\lastu)$) {};
      }
    
      \draw[fill=gray!30, opacity=0.5] (A.center) -- (B.center) -- (C.center) -- cycle;
      \draw[fill=gray!30, opacity=0.5] (A.center) -- (D.center) -- (C.center) -- cycle;
      \draw[fill=gray!30, opacity=0.5] (A.center) -- (B.center) -- (D.center) -- cycle;
      \draw[fill=gray!30, opacity=0.5] (B.center) -- (D.center) -- (C.center) -- cycle;
    \end{tikzpicture}
    \end{document}
    

    You can adjust the coordinates of the vertices A, B, C, and D as needed. The code draws the faces of the 3D simplex with 50% opacity, so the overlapping areas will be visible.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.