如何在乳胶中绘制六角金字塔?

如何在乳胶中绘制六角金字塔?

我想在乳胶中画一个像下面这样的六角金字塔? 在此处输入图片描述

答案1

如果需要,可让您切换透视视图的解决方案。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={55}{20},declare function={a=2;b=3;l=5;},
    %perspective,
    >=stealth,line cap=round,line join=round]
 \draw[->]  (tpp cs:x=0,y=0,z=0) coordinate (O) -- (tpp cs:x=l,y=0,z=0);
 \draw[->]  (O) -- (tpp cs:x=0,y=l,z=0);
 \draw[->]  (tpp cs:x=0,y=0,z=b) -- (tpp cs:x=0,y=0,z=l);
 \path foreach \X in {1,...,6}
  {(tpp cs:x={a*cos(\X*60-30)},y={a*sin(\X*60-30)},z=0) coordinate (p\X)}
  (tpp cs:x=0,y=0,z=b) coordinate (tip);
 \draw[fill=white] plot[samples at={1,...,6}] (p\x) -- cycle;
 \draw foreach \X in {1,...,6} {(p\X) edge (tip)};
 \draw[dashed] foreach \X in {1,2,3} {(p\X) edge (p\the\numexpr\X+3)}
  (O) edge (tip);
\end{tikzpicture}
\end{document}

在此处输入图片描述

如果你取消注释perspective,你会得到

在此处输入图片描述

关于此视图的详细信息,请参见64 三点透视绘图库pgfmanual v3.1.5。

当然,您可以改变视角。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\foreach \X in {5,15,...,355}
{\begin{tikzpicture}
 \path[use as bounding box](-6,-3) rectangle (6,6);
 \begin{scope}[3d view={\X}{20+10*sin(\X)},declare function={a=2;b=3;l=5;},
    >=stealth,line cap=round,line join=round]
  \draw[->]  (tpp cs:x=0,y=0,z=0) coordinate (O) -- (tpp cs:x=l,y=0,z=0);
  \draw[->]  (O) -- (tpp cs:x=0,y=l,z=0);
  \draw[->]  (tpp cs:x=0,y=0,z=b) -- (tpp cs:x=0,y=0,z=l);
  \path foreach \X in {1,...,6}
   {(tpp cs:x={a*cos(\X*60-30)},y={a*sin(\X*60-30)},z=0) coordinate (p\X)}
   (tpp cs:x=0,y=0,z=b) coordinate (tip);
  \draw[fill=white] plot[samples at={1,...,6}] (p\x) -- cycle;
  \draw foreach \X in {1,...,6} {(p\X) edge (tip)};
  \draw[dashed] foreach \X in {1,2,3} {(p\X) edge (p\the\numexpr\X+3)}
   (O) edge (tip);
 \end{scope}
\end{tikzpicture}}
\end{document}

在此处输入图片描述

答案2

PSTricks 解决方案仅供娱乐。编译过程分为 3 步:

  • latex mop.tex
  • dvips mop.dvi
  • ps2pdf mop.ps

% this file name is mop.tex
\documentclass[pstricks,border=0pt,12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[showgrid=false](-5,0)(5,11)
    \pstGeonode[PosAngle={180,-90,-90,0,45,135,90}]
        (-4,3){A}
        (-2,1){B}
        (1,1){C}
        (4,3){D}
        (2,5){E}
        (-1,5){F}
        (1,10){T}
    \foreach \i in {A,B,C,D}{\psline(T)(\i)}
    \foreach \i in {A,E,T}{\psline[linestyle=dashed](F)(\i)}
    \foreach \i in {D,T}{\psline[linestyle=dashed](E)(\i)}
    \psline(A)(B)(C)(D)
\end{pspicture}
\end{document}

在此处输入图片描述

其余部分特意留给您进行打字练习!

您也可以使用 一步完成编译xelatex mop.tex。不幸的是,这种方法需要花费大量时间来进行编译。

答案3

我对 MetaPost 的一次小小尝试。虽然我使用了 LuaTeX 的嵌入式库(通过 ConTeXt),但您可以使用以下软件包将其包含在 LaTeX 中:gmp或者直接将代码保存在.mp文件中并通过编译,以便使用或任何类似方式mpost包含输出。\includegraphics...

\startTEXpage
\startMPcode
%Save in figure.mp and use "mpost figure.mp"
%Uncomment the following lines in the standalone file
%prologues := 3;
%beginfig(1)
u := 1cm;
pair p[]; 
for i = 1 upto 6:
    p[i] := dir(60*i-30) xscaled 2 rotated 10 scaled u;
endfor
pair q, r;
q := origin;
r := (0,4)*u;
draw p1
for i = 2 upto 6:
    --p[i]
endfor
--cycle;
for i = 1 upto 6:
    draw q -- p[i] dashed evenly;
    draw r -- p[i];
endfor
draw q -- r dashed evenly;
drawarrow q -- 0.5[p5,p6] scaled 2;
drawarrow r -- (1.25*r);
drawarrow p1 -- (sqrt(3)*p1);
%endfig;
%end
\stopMPcode  
\stopTEXpage

在此处输入图片描述

相关内容