我想画一个属 3 的曲面。我制作了这个
\documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations, decorations.markings}
\usetikzlibrary{arrows, arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw (-2.6,-1.5) to [out=320, in=70] (-2,-4) %unterer Torus
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=220] (2.6,-1.5);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.2,-6.4) to[bend right] (1.2,-6.4);
\end{tikzpicture}
\end{document}
这让我
现在,我想复制两份,旋转它们并将它们粘合在一起以形成一个表面。有没有简单的方法可以做到这一点?
答案1
这就是pic
s 的用途。您可以旋转(和拉伸等)它们,还可以命名其中带有前缀的坐标。这样您就可以顺利地连接手柄。
\documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
\usepackage{tikz}
\tikzset{pics/.cd,
handle/.style={code={
\draw (-2.6,-1.5) coordinate (-left) to [out=320, in=70] (-2,-4) %unterer Torus
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=220] (2.6,-1.5) coordinate (-right);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.2,-6.4) to[bend right] (1.2,-6.4);
}}}
\begin{document}
\begin{tikzpicture}
\pic {handle};
\end{tikzpicture}
\begin{tikzpicture}
\pic (lower) at (0,1) {handle};
\pic[rotate=180] (upper) at (0,-1) {handle};
\draw (lower-left) to[out=130,in=-130] (upper-right);
\draw (lower-right) to[out=50,in=-50] (upper-left);
\end{tikzpicture}
\end{document}
Harald Hanche-Olsen 提醒了我 genus-3 是什么,所以我读错了问题。非常感谢 Harald。
\documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
\usepackage{tikz}
\tikzset{pics/.cd,
handle/.style={code={
\draw (-2.6,-1.5) coordinate (-left) to [out=320, in=70] (-2,-4) %unterer Torus
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=220] (2.6,-1.5) coordinate (-right);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.2,-6.4) to[bend right] (1.2,-6.4);
}}}
\begin{document}
\begin{tikzpicture}
\pic (lower) at (-0.5,0.85) {handle};
\pic[rotate around={120:(120:1)}] (tr) at (-120:1) {handle};
\pic[rotate around={-120:(-120:-1)}] (tl) at (-120:1) {handle};
\end{tikzpicture}
\end{document}
这是一个可以说更美观的替代方案。
\documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
\usepackage{tikz}
\tikzset{pics/.cd,
handle/.style={code={
\draw[fill=gray!20] (-2,0) coordinate (-left)
to [out=260, in=60] (-3,-2)
to [out=240, in=110] (-3,-4)
to [out=290,in=180] (0,-6)
to [out=0,in=250] (3,-4)
to [out=70,in=300] (3,-2)
to [out=120,in=280] (2,0) coordinate (-right);
\pgfgettransformentries{\tmpa}{\tmpb}{\tmp}{\tmp}{\tmp}{\tmp}
\pgfmathsetmacro{\myrot}{-atan2(\tmpb,\tmpa)}
\draw[rotate around={\myrot:(0,-2.5)}] (-1.2,-2.4) to[bend right] (1.2,-2.4);
\draw[fill=white,rotate around={\myrot:(0,-2.5)}] (-1,-2.5) to[bend right] (1,-2.5)
to[bend right] (-1,-2.5);
}}}
\begin{document}
\begin{tikzpicture}
\pic (lower) at (0,-pi) {handle};
\pic[rotate=120] (tr) at (30:pi) {handle};
\pic[rotate=-120] (tl) at (150:pi) {handle};
\fill[gray!20] (lower-right) to[out=100,in=200] (tr-left)--
(tr-right) to[out=-130,in=-40] (tl-left)
-- (tl-right) to[out=-20,in=80] (lower-left) -- cycle;
\draw (lower-right) to[out=100,in=200] (tr-left);
\draw (tr-right) to[out=-130,in=-40] (tl-left);
\draw (tl-right) to[out=-20,in=80] (lower-left);
\end{tikzpicture}
\end{document}
答案2
快速而肮脏
\documentclass[margin=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations, decorations.markings}
\usetikzlibrary{arrows, arrows.meta}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate=180]
\draw (-2.6,-1.5) to [out=320, in=70] (-2,-4) %unterer Torus
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=220] (2.6,-1.5);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.2,-6.4) to[bend right] (1.2,-6.4);
\end{scope}
\begin{scope}[yshift=3cm]
\draw (-2.6,-1.5) to [out=320, in=70] (-2,-4) %unterer Torus
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=220] (2.6,-1.5);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.2,-6.4) to[bend right] (1.2,-6.4);
\end{scope}
\end{tikzpicture}
\end{document}
答案3
编辑一些角度,这就是我得到的
\documentclass[margin=0pt]{standalone}
%---------------------------- Tikz Libraries ------------------------------%
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{decorations, decorations.markings}
\usetikzlibrary{arrows, arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw (-2.6,-1.5) to [out=300, in=70] (-2,-4) %Torus 1
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9.5)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=240] (2.6,-1.5);
\draw (-1,-6.5) to[bend left] (1,-6.5);
\draw (-1.1,-6.43) to[bend right] (1.1,-6.43);
\draw[rotate=120] (-2.6,-1.5) to [out=300, in=70] (-2,-4) %Torus 2
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9.5)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=240] (2.6,-1.5);
\draw[shift={(5.7 cm,9.25 cm)}] (-1,-6.5) to[bend left] (1,-6.5);
\draw[shift={(5.7 cm,9.25 cm)}] (-1.1,-6.43) to[bend right] (1.1,-6.43);
\draw[rotate=240] (-2.6,-1.5) to [out=300, in=70] (-2,-4) %Torus 3
to [out=260, in=60] (-3,-6)
to [out=240, in=110] (-3,-8)
to [out=290,in=175] (0,-9.5)
to [out=5,in=250] (3,-8)
to [out=70,in=300] (3,-6)
to [out=120,in=280] (2,-4)
to [out=110,in=240] (2.6,-1.5);
\draw[shift={(-5.8 cm,10.25 cm)}] (-1,-6.5) to[bend left] (1,-6.5);
\draw[shift={(-5.8 cm,10.25cm)}] (-1.1,-6.43) to[bend right] (1.1,-6.43);
\node[above] (v1) at (0,0) {$x$}; %Beschriftung Basispunkt
\node[below] at (0,-9.5) {1}; %Beschriftung Tori
\node[right] at (8.25,4.7) {2}; %Beschriftung Tori
\node[left] at (-8.25,4.7) {3}; %Beschriftung Tori
\end{tikzpicture}
\end{document}
这产生了