我想画一个四面体,每个角上都有标记点。我尝试编辑我在这里找到的圆锥体示例:带有 tikzpicture 的锥体 我让它看起来部分像四面体,但无法正确完成(更不用说标记点了)。这是我目前得到的:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
\def\RI{2}
\def\RII{1.25}
\draw[] (\RI,0)
\foreach \x in {0,240} { -- (\x:\RI) node at (\x:\RI) (R1-\x) {} };
\draw[dashed,thick] (R1-0.center)
\foreach \x in {120} { -- (\x:\RI) node at (\x:\RI) (R1-\x) {} };
\begin{scope}[yshift=2cm]
\draw[thick,fill=gray!30,opacity=0.2] (\RII,0)
\foreach \x in {0,120,240,360}
{ -- (\x:\RII) node at (\x:\RII) (R2-\x) {}};
\end{scope}
\foreach \x in {0,240} { \draw (R1-\x.center)--(R2-\x.center); };
\foreach \x in {120} { \draw[dashed] (R1-\x.center)--(R2-\x.center); };
\end{tikzpicture}
\end{document}
编译后的结果如下:
答案1
在以下机构的帮助下维基百科和TikZ
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[line join = round, line cap = round]
\pgfmathsetmacro{\factor}{1/sqrt(2)};
\coordinate [label=right:A] (A) at (2,0,-2*\factor);
\coordinate [label=left:B] (B) at (-2,0,-2*\factor);
\coordinate [label=above:C] (C) at (0,2,2*\factor);
\coordinate [label=below:D] (D) at (0,-2,2*\factor);
\draw[->] (0,0) -- (3,0,0) node[right] {$x$};
\draw[->] (0,0) -- (0,3,0) node[above] {$y$};
\draw[->] (0,0) -- (0,0,3) node[below left] {$z$};
\foreach \i in {A,B,C,D}
\draw[dashed] (0,0)--(\i);
\draw[-, fill=red!30, opacity=.5] (A)--(D)--(B)--cycle;
\draw[-, fill=green!30, opacity=.5] (A) --(D)--(C)--cycle;
\draw[-, fill=purple!30, opacity=.5] (B)--(D)--(C)--cycle;
\end{tikzpicture}
\end{document}
答案2
这是一个六面体,但也许这可以给你一个起点。
\begin{tikzpicture}[x=0.65cm, y=0.65cm]
% Specify the coordinates
\coordinate (P0) at (0.0, 0.0); % 0
\coordinate (P1) at (10.0, 0.0); % 1
\coordinate (P2) at (13.0, 2.50); % 2
\coordinate (P3) at (3.0, 2.50); % 3
\coordinate (P4) at (0.0, 6.0); % 4
\coordinate (P5) at (10.0, 6.0); % 5
\coordinate (P6) at (14.0, 8.50); % 6
\coordinate (P7) at (3.0, 8.50); % 7
% draw and number the edges
\draw[line width=0.5pt] (P0) -- (P1);
\node[fill=white] (c) at ($(P0)!0.5!(P1)$) {$0 \,\rightarrow$};
\draw[line width=0.5pt] (P1) -- (P2);
\node[fill=white] (c) at ($(P1)!0.55!(P2)$) {$\overset{\nearrow}{5}$};
\draw[line width=0.5pt] (P0) -- (P4);
\node[fill=white] (c) at ($(P0)!0.5!(P4)$) {$\overset{\uparrow}{8}$};
\draw[line width=0.5pt] (P4) -- (P5);
\node[fill=white] (c) at ($(P4)!0.5!(P5)$) {$3 \,\rightarrow$};
\draw[line width=0.5pt] (P4) -- (P7);
\node[fill=white] (c) at ($(P4)!0.5!(P7)$) {$\overset{\nearrow}{7}$};
\draw[line width=0.5pt] (P5) -- (P6);
\node[fill=white] (c) at ($(P5)!0.5!(P6)$) {$\overset{\text{\rotatebox[origin=c]{-8}{$\nearrow$}}}{6}$};
\draw[line width=0.5pt] (P7) -- (P6);
\node[fill=white] (c) at ($(P7)!0.5!(P6)$) {$2 \,\rightarrow$};
\draw[line width=0.5pt] (P1) -- (P5);
\node[fill=white] (c) at ($(P1)!0.6!(P5)$) {$\overset{\uparrow}{9}$};
\draw[line width=0.5pt] (P2) to[out=90,in=-120] (P6);
\node[fill=white,anchor=east] (c) at ($(P2)!0.5!(P6)$) {$\overset{\text{\rotatebox[origin=c]{-10}{$\uparrow$}}}{10}$};
\draw[dashed, line width=0.5pt] (P3) -- (P0);
\node[fill=white] (c) at ($(P0)!0.65!(P3)$) {$\overset{\nearrow}{4}$};
\draw[dashed, line width=0.5pt] (P3) -- (P2);
\node[fill=white] (c) at ($(P3)!0.5!(P2)$) {$1 \,\rightarrow$};
\draw[dashed, line width=0.5pt] (P3) -- (P7);
\node[fill=white] (c) at ($(P3)!0.35!(P7)$) {$\overset{\uparrow}{11}$};
% numbering the nodes
\foreach \i in {2,3,6,7}
{
\draw[fill=black] (P\i) circle (0.15em)
node[above right,blue,font=\bfseries] {\Large \i};
}
\foreach \i in {0,1,4,5}
{
\draw[fill=black] (P\i) circle (0.15em)
node[below left,blue,font=\bfseries] {\Large \i};
}
% coordinate system
\node (x) at ($(P0)!0.15!(P1)$) {};
\node (y) at ($(P0)!0.45!(P3)$) {};
\node (z) at ($(P0)!0.35!(P4)$) {};
\draw[-latex,thick] (P0) to (x) node [below] {$x$};
\draw[-latex,thick] (P0) to (y) node [below] {$y$};
\draw[-latex,thick] (P0) to (z) node [right] {$z$};
\end{tikzpicture}
这些点都已标记,因此修改起来相当容易。玩得开心。我根据一些示例创建了此图像TeXample.net。
以下代码将块创建为独立图像。适用于pdflatex
。
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{amsmath}
\begin{document}
\input{block.tikz}
\end{document}
答案3
运行xelatex
\documentclass{article}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=40 10 10 rtp2xyz,lightsrc=viewpoint,Decran=30}
\begin{pspicture}[solidmemory](-2,-2)(3,3)
\psSolid[object=tetrahedron,r=3,action=draw*,name=T,num=1 2 3]% without 0
\psSolid[object=point,definition=solidgetsommet,args=T 0,text=Top,pos=uc]% Point T0 (top)
\end{pspicture}
\end{document}
答案4
这个怎么样。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[thick, fill=gray] (0,1.5) -- (1.2,0.4) -- (0,-1) -- (0,1.5) -- (-1.6,-0.1) -- (0,-1);
\draw[thick, dashed] (1.1,0.4) -- (-1.5,-0.1) ;
\draw[thick, red] (-0.5132,0.247) -- (-2.1795,0.0633) ;
\draw[thick, red, dashed] (1.839,0.4928) -- (-0.396,0.247) ;
\fill (-1.8,-0.4) circle (0pt) node[above] {4};
\fill (0,-1.5) circle (0pt) node[above] {3};
\fill (1.3,0.4) circle (0pt) node[above] {2};
\fill (0,1.6) circle (0pt) node[above] {1};
\end{tikzpicture}
\end{document}