我想复制下图:
我尝试使用rotate
特定坐标和正则多边形的预定义锚点来规避使用,但显然它不起作用。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=3, draw, minimum size=4cm]
(m) at (0,0) {};
\fill [black] (m.corner 1) circle (3pt);
\draw [black] (m.corner 1) circle (6pt);
\fill [black] (m.corner 2) circle (3pt);
\draw [black] (m.corner 2) circle (6pt);
\fill [black] (m.corner 3) circle (3pt);
\draw [black] (m.corner 3) circle (6pt);
\draw [black, ->, rotate=-90] (m.side 1) -- (m.corner 1);
\end{tikzpicture}
\end{document}
draw
在我看来,如果我命名使用锚点的起点和终点,那么它就rotate
不会起作用了?
答案1
您可以使用calc
带有部分语法的库,该语法接受可选的旋转参数。
表达方式
($(A)!0.5!90:(B)$)
(A)
指定位于和之间距离的一半、(B)
沿着从和(A)
之间的方向旋转 90 度的方向的点。(A)
(B)
在你的情况下,你可以使用以下方法绘制第 1 侧的法线
\draw [-latex, thick] (m.side 1) -- ($(m.side 1)!0.5!90:(m.corner 1)$);
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\begin{document}
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=3, draw, minimum size=4cm]
(m) at (0,0) {};
\fill [black] (m.corner 1) circle (3pt);
\draw [black] (m.corner 1) circle (6pt);
\fill [black] (m.corner 2) circle (3pt);
\draw [black] (m.corner 2) circle (6pt);
\fill [black] (m.corner 3) circle (3pt);
\draw [black] (m.corner 3) circle (6pt);
\draw [-latex, thick] (m.side 1) -- ($(m.side 1)!0.5!90:(m.corner 1)$);
\draw [-latex, thick] (m.side 2) -- ($(m.side 2)!0.5!90:(m.corner 2)$);
\draw [-latex, thick] (m.side 3) -- ($(m.side 3)!0.5!90:(m.corner 3)$);
\end{tikzpicture}
\end{document}
答案2
我认为这些箭头提示在 TikZ 中没有预定义。但如果重要的话,可以从头开始定义。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[regular polygon, regular polygon sides=3, draw, minimum size=4cm,thick] (m) at (0,0) {};
\foreach \x[count=\xi from 0] in {1,2,3}{
\fill [black,thick] (m.corner \x) circle (3pt);
\draw [black,thick] (m.corner \x) circle (6pt);
\draw [black,thick,->] (m.side \x) -- (\xi*120+150:2cm);
};
\end{tikzpicture}
\end{document}
通过添加calc
库,人们还可以使用 Jake 的答案中给出的具有类似语法的几何中心来实现旋转感知(也适用于更多侧面)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\begin{document}
\begin{tikzpicture}[rotate=45,transform shape]
\node[regular polygon, regular polygon sides=3, draw, minimum size=4cm,thick] (m) at (0,0) {};
\foreach \x in {1,2,3}{
\fill [black,thick] (m.corner \x) circle (3pt);
\draw [black,thick] (m.corner \x) circle (6pt);
\draw [black,thick,->] (m.side \x) -- ($(m.side \x)!-1!(m.center)$);
};
\end{tikzpicture}
\end{document}
答案3
使用 tikz-euclide 的解决方案,当然可以改进 =)
\documentclass{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[rotate=10]
\def\radius{10} % Defines the size (sidelength of the triangle)
\def\T{0.20} % Defines the thickness of the figure
\pgfmathsetmacro{\E}{\radius/16} % Macro for drawing the filled circles
\pgfmathsetmacro{\r}{\radius/8} % Macro for drawing the circles.
\tkzDefPoint(0,0){A}
\tkzDefPoint(\radius,0){B}
\tkzDefPointBy[rotation= center A angle 60](B)
\tkzGetPoint{C}
\tkzCentroid(A,B,C) \tkzGetPoint{O}
\tkzDefMidPoint(A,B) \tkzGetPoint{M1}
\tkzDefMidPoint(A,C) \tkzGetPoint{M2}
\tkzDefMidPoint(B,C) \tkzGetPoint{M3}
\tkzInterLC(A,O)(O,B) \tkzGetSecondPoint{T1}
\tkzInterLC(B,O)(O,B) \tkzGetSecondPoint{T2}
\tkzInterLC(C,O)(O,C) \tkzGetSecondPoint{T3}
\tkzDrawPolygon[line width=\T cm](A,B,C)
\tkzDrawCircle[R,line width=\T cm](A,\r cm) \tkzDrawCircle[R, fill=black](A,\E cm)
\tkzDrawCircle[R,line width=\T cm](B,\r cm) \tkzDrawCircle[R, fill=black](B,\E cm)
\tkzDrawCircle[R,line width=\T cm](C,\r cm) \tkzDrawCircle[R, fill=black](C,\E cm)
\tkzDrawSegments[-stealth,line width = \T cm](M3,T1 M2,T2 M1,T3)
\end{tikzpicture}
\end{document}
答案4
我不明白请求:without-specifying-the-coord
您需要使用坐标,并在第一个答案中使用坐标。一种简单的可能性是使用一些坐标,($(A)!0.5!90:(B)$)
而($(m.side \x)!-1!(m.center)$)
无需库:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture} [-latex,ultra thick]
\draw[fill] (-30:4) circle (3pt) -- (90:4) circle (3pt) -- (210:4) circle (3pt) -- (-30:4);
\draw (-30:4) circle (6pt) (90:4) circle (6pt) (210:4) circle (6pt) ;
\draw[->] (30:2) -- (30:4);
\draw[->] (150:2) -- (150:4);
\draw[->] (270:2) -- (270:4);
\end{tikzpicture}
\end{document}