我在 Tikzpicture 中制作了下图:
\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
\newcommand{\whiteSpace}[1]{
\draw[white, ultra thick, rotate=#1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
%(1.1,-3.41) -- (1.25,-3.417)
%(0.9,-3.52) -- (1.25,-3.526)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
\draw[white, ultra thick, rotate=#1, xscale=-1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
%(1.1,-3.41) -- (1.25,-3.417)
%(0.9,-3.52) -- (1.25,-3.526)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
}
\begin{tikzpicture}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
\whiteSpace{0}
\whiteSpace{90}
\whiteSpace{180}
\whiteSpace{270}
\end{tikzpicture}
为了使线条断开,使其看起来像是线条在自身上下移动,我只是在上面添加了一些白线。但我真的不喜欢这个解决方案,我想知道,是否有一种简单的方法可以让线条在特定点停止并再次开始,同时仍然遵循我已经制作的曲线?
独立文档(MWE)中的完整代码:
\documentclass[a0paper,titlepage,11pt]{standalone}
% Usepackage:
\usepackage{pgfplots}
\usepackage{allrunes}
% Commands:
\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
\newcommand{\whiteSpace}[1]{
\draw[white, ultra thick, rotate=#1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
\draw[white, ultra thick, rotate=#1, xscale=-1]
(0.4,-3.308) -- (0.6,-3.35)
(0.3,-3.395) -- (0.5,-3.45)
(1.11,-3.41) -- (0.99,-3.52)
(1.29,-3.41) -- (1.155,-3.52)
(2.24,-2.9) -- (2.2,-3.0)
(2.358,-2.89) -- (2.32,-3.0)
(1.55,-2.91) -- (1.75,-2.9)
(1.45,-3.025) -- (1.75,-3.0127)
;
}
\begin{document}
\begin{tikzpicture}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
\whiteSpace{0}
\whiteSpace{90}
\whiteSpace{180}
\whiteSpace{270}
\end{tikzpicture}
\end{document}
答案1
新答案
正如 Paul Gaborit 指出的,翻转某些段落是必要的。这可以通过键flip crossing/.list={}
或\flipcrossings{}
宏来完成,两者的作用是一样的。需要训练有素的眼睛才能注意到!
确实,你原来的基本绘图是这样的:
不返回一些段落所获得的绘图是:
当您切换到 时draft mode=crossings
,您会发现要返回的数字,并且您会发现 Paul Gaborit 列出的数字:\flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
最后的结果和你一开始想要得到的结果是一样的。
\documentclass[border=5mm]{standalone}
% Usepackage:
\usepackage{pgfplots}
\usetikzlibrary{calc,knots}
%\usepackage{allrunes}
% Commands:
\newcommand{\yggDra}[3]{
\strand[ultra thick, xscale=#1, yscale=#2, rotate=#3]
({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
%\newcommand{\whiteSpace}[1]{
%\draw[white, ultra thick, rotate=#1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%\draw[white, ultra thick, rotate=#1, xscale=-1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%}
\begin{document}
\begin{tikzpicture}
\begin{knot}[consider self intersections,end tolerance=.4pt,
flip crossing/.list={2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16},
% draft mode=crossings
]
%\flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
%\whiteSpace{0}
%\whiteSpace{90}
%\whiteSpace{180}
%\whiteSpace{270}
\end{knot}
\end{tikzpicture}
\end{document}
使用 www.DeepL.com/Translator 翻译(免费版)
旧答案
套餐knots
包含spath3@LoopSpace 编写的程序可以让你自动完成你想要做的事情。以下是使用此包对你的代码的改编。
\documentclass[border=5mm]{standalone}
% Usepackage:
\usepackage{pgfplots}
\usetikzlibrary{calc,knots}
%\usepackage{allrunes}
% Commands:
\newcommand{\yggDra}[3]{
\strand[ultra thick, xscale=#1, yscale=#2, rotate=#3]
({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
%\newcommand{\whiteSpace}[1]{
%\draw[white, ultra thick, rotate=#1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%\draw[white, ultra thick, rotate=#1, xscale=-1]
%(0.4,-3.308) -- (0.6,-3.35)
%(0.3,-3.395) -- (0.5,-3.45)
%(1.11,-3.41) -- (0.99,-3.52)
%(1.29,-3.41) -- (1.155,-3.52)
%(2.24,-2.9) -- (2.2,-3.0)
%(2.358,-2.89) -- (2.32,-3.0)
%(1.55,-2.91) -- (1.75,-2.9)
%(1.45,-3.025) -- (1.75,-3.0127)
%;
%}
\begin{document}
\begin{tikzpicture}
\begin{knot}[consider self intersections,end tolerance=.4pt,
flip crossing/.list={2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
%draft mode=crossings
]
%\flipcrossings{2,3,38,39,50,51,20,21,33,34,54,55,66,67,15,16}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
%\whiteSpace{0}
%\whiteSpace{90}
%\whiteSpace{180}
%\whiteSpace{270}
\end{knot}
\end{tikzpicture}
\end{document}
答案2
您可以直接使用dash pattern
。确实,您需要手动调整on
和off
尺寸,但此代码不会透支任何内容。
\documentclass[tikz,border=3mm]{standalone}
% Commands:
\newcommand{\yggDra}[3]{
\draw[ultra thick, xscale=#1, yscale=#2, rotate=#3,
dash pattern=on 13pt off 5pt on 51pt off 5pt on 66pt off 6pt on 76pt off 6pt on 35pt] ({cos(-44.8)*3.92},{sin(-44.8)*3.92})
.. controls ({cos(-55)*4},{sin(-55)*4}) and ({cos(-75)*2.5},{sin(-75)*2.5}) .. ({cos(-89)*3.9},{sin(-89)*3.9})
.. controls ({cos(-75)*4.2},{sin(-75)*4.2}) and ({cos(-60)*3.1},{sin(-60)*3.1}) .. ({cos(-44)*3.2},{sin(-44)*3.4})
.. controls ({cos(-55)*4.5},{sin(-55)*4.5}) and ({cos(-75)*3.7},{sin(-75)*3.7}) .. ({cos(-87)*3.3},{sin(-87)*3.3}) .. controls ({cos(-90)*3.26},{sin(-90)*3.26}) .. ({cos(-93)*3.3},{sin(-93)*3.3});
}
\begin{document}
\begin{tikzpicture}
\yggDra{1}{1}{0}
\yggDra{-1}{1}{0}
\yggDra{1}{-1}{0}
\yggDra{-1}{-1}{0}
\yggDra{1}{-1}{90}
\yggDra{-1}{-1}{-90}
\yggDra{1}{-1}{-90}
\yggDra{-1}{-1}{90}
\end{tikzpicture}
\end{document}