我刚刚开始使用 TIKZ,我需要帮助尝试绘制一个内接于等边三角形的六边形。
答案1
一种解决方案(但还有许多其他解决方案)tkz-euclide
。它只用于绘制您想要的内容,但如果您想使用一些顶点,那么最好使用\tkzDefPointBy[
或使用获取坐标\tkzDefTriangle[equilateral]
\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\c}{6}
\tkzDefPoints{0/0/A,\c/0/B}
\tkzDefTriangle[equilateral](A,B)\tkzGetPoint{C}
\tkzDefPointBy[homothety=center A ratio 1./3](B) \tkzGetPoint{a}
\tkzDefPointsBy[homothety=center A ratio 2./3](B,C){b,c}
\foreach \x / \y in {A/B,A/a,C/c,b/B}
{\tkzDrawTriangle[equilateral](\x,\y)}
\end{tikzpicture}
\end{document}
现在有一个有趣的解决方案
\documentclass{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\c}{6}
\tkzDefPoints{0/0/A,\c/0/B}
\tkzDefTriangle[equilateral](A,B)\tkzGetPoint{C}
\tkzDefSpcTriangle[medial](A,B,C){a,b,c}
\tkzDefMidPoint(A,a)\tkzGetPoint{ma}
\tkzDefMidPoint(B,b)\tkzGetPoint{mb}
\tkzDefMidPoint(C,c)\tkzGetPoint{mc}
\tkzInterLL(C,ma)(A,B) \tkzGetPoint{c1}
\tkzInterLL(C,mb)(A,B) \tkzGetPoint{c2}
\tkzInterLL(A,mb)(B,C) \tkzGetPoint{a1}
\tkzInterLL(A,mc)(B,C) \tkzGetPoint{a2}
\tkzInterLL(B,ma)(A,C) \tkzGetPoint{b1}
\tkzInterLL(B,mc)(A,C) \tkzGetPoint{b2}
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments[dashed](A,a B,b C,c C,c1 C,c2 A,a1 A,a2 B,b1 B,b2)
\tkzDrawPolygon[red,thick](a1,a2,b2,b1,c1,c2)
\end{tikzpicture}
\end{document}
第三种解决方案
\documentclass{standalone}
\usepackage{tkz-euclide} % soon with "elements"
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\c}{6}
\tkzDefPoints{0/0/A,\c/0/B}
\tkzDefTriangle[equilateral](A,B)\tkzGetPoint{C}
\tkzDefTriangleCenter[centroid](A,B,C) \tkzGetPoint{I}
\tkzDefPointBy[homothety=center A ratio 1./3](B) \tkzGetPoint{c1}
\tkzInterLC(B,C)(I,c1) \tkzGetPoints{a1}{a2}
\tkzInterLC(A,C)(I,c1) \tkzGetPoints{b1}{b2}
\tkzInterLC(A,B)(I,c1) \tkzGetPoints{c1}{c2}
\tkzDrawPolygon(A,B,C)
\tkzDrawCircle[thin,orange](I,c1)
\tkzDrawPolygon[red,thick](a2,a1,b2,b1,c2,c1)
\end{tikzpicture}
\end{document}
答案2
你只需要shapes.geometric
图书馆。圆周率日快乐!
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[reg/.style={draw,transform shape,
regular polygon,regular polygon sides=#1}]
\path[scale=pi] (0,0) node[reg=3]{} node[reg=6]{}
(3/4,0) node[reg=3]{} node[reg=6,rotate=30,scale={cos(30)}]{};
\end{tikzpicture}
\end{document}
答案3
答案4
纯粹为了娱乐价值——元帖子,使用luamplib
,因此用进行编译lualatex
。
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
path t; t := up; t := for i=0, 1, 2: t rotated 120i -- endfor cycle;
t := t shifted 2 up; t := for i=0, 1, 2: t rotated 120i -- endfor cycle;
draw t scaled 42;
endfig;
\end{mplibcode}
\end{document}