如何用虚线在立方体上方绘制圆柱体?

如何用虚线在立方体上方绘制圆柱体?

我正在尝试用虚线绘制这些图形

在此处输入图片描述

数学,很容易画出来。

在此处输入图片描述

如何用TeX绘制第二张图?

我只画了立方体。我的代码

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
    \tdplotsetmaincoords{70}{100}
\begin{tikzpicture} [tdplot_main_coords,c/.style={circle,fill,inner sep=1pt},line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
        declare function={a=3;}]
        \path
        (a,-a,-a) coordinate (A)
        (a,a,-a) coordinate (B)
        (-a,a,-a) coordinate (C)
        (-a,-a,-a) coordinate (D)
        (a,-a,a) coordinate (E)
        (a,a,a) coordinate (F)
        (-a,a,a) coordinate (G)
        (-a,-a,a) coordinate (H)
        (0,0,0)  coordinate (O) ;
    \draw[] (C) -- (F) -- (H) (A) -- (F) (A) -- (B) -- (C) (E) -- (F) -- (G)-- (H)--cycle (A) -- (E) (B) --  (F) (C) -- (G);
        \draw[dashed] (A) -- (D) -- (C) (C) -- (A) -- (H)--cycle (D) -- (H);
        \path foreach \p/\g in {A/-90,B/-90,C/0,D/0,E/90,F/90,G/90,H/90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};  
    \end{tikzpicture}
    \end{document}

答案1

通过第二张图片,你可以3d工具

 \documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {5, 10, ..., 355}
{   \begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
        declare function={a=2.5;},same bounding box=A]
        \path
        (a,-a,-a) coordinate (A)
        (a,a,-a) coordinate (B)
        (-a,a,-a) coordinate (C)
        (-a,-a,-a) coordinate (D)
        (a,-a,a) coordinate (E)
        (a,a,a) coordinate (F)
        (-a,a,a) coordinate (G)
        (-a,-a,a) coordinate (H)
        (0,0,0)  coordinate (O)
        (0,0,a) coordinate (O')
        ;   
        \tikzset{3d/polyhedron/.cd,O={(O)},
            back/.style={3d/polyhedron/complete dashes,fill=none,3d/hidden},
            fore/.style={3d/visible,fill=none},draw face with corners={{(B)},{(C)},{(G)},{(F)}},
            draw  face with corners={{(D)},{(C)},{(G)},{(H)}},
            draw  face with corners={{(A)},{(B)},{(C)},{(D)}},
            draw  face with corners={{(A)},{(B)},{(F)},{(E)}},
            draw  face with corners={{(A)},{(E)},{(H)},{(D)}}}  
        \path (O')  pic[3d/visible/.append style={save named path=cyl}]{3d/frustum={r=a,R=a,h=a}};
        \path[save named path=EFGH] (E) -- (F) -- (G) -- (H) -- cycle;
        \tikzset{3d/ordered paths/.cd,cyl/.style={draw=none}}
        % draw ordered objects  
        \tikzset{3d/draw ordered paths={EFGH,cyl}}
        \path foreach \p/\g in {A/-90,B/180,C/-90,D/-90,E/0,F/90,G/-30,H/0,O'/90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}}; 
    \end{tikzpicture}}
\end{document}    

在此处输入图片描述

我尝试使用 GeoGebra 并将文件放在这里. 您可以用鼠标旋转图形。

相关内容