我试过
\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,calc,backgrounds,patterns}
\usepackage{fouriernc}
\begin{document}
\def\a{2.5}
\def\h{2*\a}
\def\r{\a*sqrt(3)/6}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[canvas is xy plane at z=0]
\coordinate (A) at (0,0);
\coordinate (B) at (\a,0);
\coordinate (C) at (\a/2,{\a*sqrt(3)/2});
\coordinate (O) at (\a/2,{\a*sqrt(3)/6});
\coordinate (M) at ($ (A) !0.5!(B) $);
\coordinate (N) at ($ (C) !0.5!(A) $);
\draw[dashed] (O) circle (\r);
\end{scope}
\begin{scope}[canvas is xy plane at z=\h]
\coordinate (A') at (0,0);
\coordinate (B') at (\a,0);
\coordinate (C') at (\a/2,{\a*sqrt(3)/2});
\coordinate (O') at (\a/2,{\a*sqrt(3)/6});
\draw[thick] (O') circle (\r);
\coordinate (M') at ($ (A') !0.5!(B') $);
\coordinate (N') at ($ (C') !0.5!(A') $);
\end{scope}
\foreach \v/\position in {A/left,B/below,C/right,O/below,A'/above,B'/left,C'/right} {\draw[draw =black, fill=black] (\v) circle (1pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (A') -- (B') -- (C') -- cycle
(B) -- (C) (B) --(B') (C)-- (C')
;
\draw[dashed] (A) -- (A') (B) -- (A) -- (C) (O) -- (O') (N) -- (N') (M) -- (M');
\end{tikzpicture}
\end{document}
我有
气缸不正确。我该如何纠正?
答案1
从几何学上来说,垂直线的端点是水平线的交点屏幕上和相应的圆圈。在代码中,这些点被称为b1
、b2
和。用于确保辅助路径不会改变边界框。t1
t2
overlay
\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections}
\usepackage{fouriernc}
\begin{document}
\def\a{2.5}
\def\h{2*\a}
\pgfmathsetmacro\r{\a*sqrt(3)/6}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[tdplot_main_coords]
\path[tdplot_screen_coords,overlay]
(-3*\r,0) coordinate (Xm) (3*\r,0) coordinate (Xp);
\begin{scope}[canvas is xy plane at z=0]
\coordinate (A) at (0,0);
\coordinate (B) at (\a,0);
\coordinate (C) at (\a/2,{\a*sqrt(3)/2});
\coordinate (O) at (\a/2,{\a*sqrt(3)/6});
\coordinate (M) at ($ (A) !0.5!(B) $);
\coordinate (N) at ($ (C) !0.5!(A) $);
\draw[dashed,name path=circle] (O) circle (\r);
\path[overlay,name path=hori] ($(O)-0.5*($(Xp)-(Xm)$)$) -- ++ ($(Xp)-(Xm)$);
\path[name intersections={of=circle and hori,by={b1,b2}}];
\end{scope}
\begin{scope}[canvas is xy plane at z=\h]
\coordinate (A') at (0,0);
\coordinate (B') at (\a,0);
\coordinate (C') at (\a/2,{\a*sqrt(3)/2});
\coordinate (O') at (\a/2,{\a*sqrt(3)/6});
\path[name path=circle] (O') circle (\r);
\path[overlay,name path=hori] ($(O')-0.5*($(Xp)-(Xm)$)$) -- ++ ($(Xp)-(Xm)$);
\path[name intersections={of=circle and hori,by={t1,t2}}];
\draw[dashed,thick] (b1) -- (t1) (b2) -- (t2);
\draw[thick] (O') circle (\r);
\coordinate (M') at ($ (A') !0.5!(B') $);
\coordinate (N') at ($ (C') !0.5!(A') $);
\end{scope}
\foreach \v/\position in {A/left,B/below,C/right,O/below,A'/above,B'/left,C'/right} {\draw[draw =black, fill=black] (\v) circle (1pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (A') -- (B') -- (C') -- cycle
(B) -- (C) (B) --(B') (C)-- (C')
;
\draw[dashed] (A) -- (A') (B) -- (A) -- (C) (O) -- (O');
\end{tikzpicture}
\end{document}
答案2
非常感谢 marmot这个答案有了这个答案,我尝试
\documentclass[border=1mm,12pt,tikz]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\foreach \Angle in {5,15,...,355}
{
\begin{tikzpicture}[3d/install view={phi=\Angle,psi=0,theta=70},line join = round, line cap = round,same bounding box=A,declare function={a=3;b=4;h=4;}]
\path (0,0,0) coordinate (A)
(a,0,0) coordinate (B) (0,b,0) coordinate (C)
(0,0,h) coordinate (A')
(a,0,h) coordinate (B') (0,b,h) coordinate (C')
(1,1,h/2) coordinate (O'');
\path pic[red,3d/hidden]{3d incircle={%
A={(A)},B={(B)},C={(C)},center name=I}}
pic[blue,3d/visible]{3d incircle={%
A={(A')},B={(B')},C={(C')},center name=I'}};
\tikzset{3d/polyhedron/.cd,O={(O'')},
fore/.append style={fill=none,/tikz/3d/visible},
back/.append style={fill=none,/tikz/3d/hidden},
draw face with corners={{(A)},{(B)},{(B')},{(A')}},
draw face with corners={{(B)},{(C)},{(C')},{(B')}},
draw face with corners={{(C)},{(A)},{(A')},{(C')}},
draw face with corners={{(A')},{(B')},{(C')}}}
\pgfmathsetmacro{\myr}{tddistance("(I')","(tmppa)")}
\draw[3d/hidden]
([xshift=-\myr*1cm]I) -- ([xshift=-\myr*1cm]I')
([xshift=\myr*1cm]I) -- ([xshift=\myr*1cm]I');
\end{tikzpicture}}
\end{document}