绘制曲线的真实交点

绘制曲线的真实交点

我想画这样的东西

    \begin{tikzpicture}[line width=3pt, color=blue!55!black!74, rotate=-0]
    \def\g{360/6}
    \def\r{2.7}
    \coordinate(A1) at(\g:\r);
    \coordinate(A2) at(2*\g:\r);
    \coordinate(A3) at(3*\g:\r);
    \coordinate(A4) at(4*\g:\r);
    \coordinate(A5) at(5*\g:\r);
    \coordinate(A6) at(6*\g:\r);
     
\draw(A1) node[rotate=-30] {\scalebox{13}{$\infty$}};    

\draw(A2) node[rotate=30] {\scalebox{13}{$\infty$}};     
\draw(A3) node[rotate=90] {\scalebox{13}{$\infty$}};     
\draw(A4) node[rotate=150] {\scalebox{13}{$\infty$}};    
\draw(A5) node[rotate=210] {\scalebox{13}{$\infty$}};    
\draw(A6) node[rotate=270] {\scalebox{13}{$\infty$}};    
 
    \end{tikzpicture}

对无穷大符号进行一些修改(仍然是 6 个符号),但曲线的宽度是均匀的,并且应该有一些真正交叉的迹象,如附图所示。

在此处输入图片描述

答案1

这是使用该knots包渲染的图表。该包计算图表各个部分的交点,并重新绘制每个交点附近的线条以获得路径重叠效果。从这个意义上讲,它做的事情与 Juan 的手动计算代码类似。它还做了一件事,当重新渲染路径重叠时,它会仔细处理两个部分(边缘和中间),以确保生成的图像中没有假象(这些在tikz 结库中的“麦田怪圈”问题但在胡安的回答中也可以非常非常隐约地看到)。

\documentclass{article}
%\url{https://tex.stackexchange.com/q/604921/86}
\usepackage{tikz}
% Load the necessary libraries
\usetikzlibrary{knots,spath3,hobby}

% Save the colours in useful aliases to be able to refer to them by number
\colorlet{link0}{red}
\colorlet{link1}{yellow}
\colorlet{link2}{green}
\colorlet{link3}{cyan}
\colorlet{link4}{blue}
\colorlet{link5}{magenta}

% Strands can't be put inside a foreach loop (local/global stuff)
% so this style is a convenient shortcut to make it easy to define
% multiple copies of the symbol.
%
% strand colour makes it possible to reuse the colour in a variety
% of ways
\tikzset{
  infinity path/.style 2 args={
    spath/use={infinity, transform={rotate=180+#1*360/#2,yshift=2.8cm}},
    strand colour=link#1
  },
  strand colour/.initial=black,
}

\begin{document}

% Define and store the basic symbol path
\begin{tikzpicture}[overlay]
\path[use Hobby shortcut,spath/save global=infinity] ([closed]-1.5,1) .. (1.5,-1) .. (1.5,1) .. (-1.5,-1);
\end{tikzpicture}

\begin{tikzpicture}
% Draw the strands in gray to create the shadow effect
\foreach \k in {0,...,4} {
  \draw[
    line width=20pt,
    gray!25,
    infinity path={\k}{5},
  ];
}
\begin{knot}[
  consider self intersections=no splits,%
  end tolerance=1pt,%
  % this ends up being the line width of the outer white edges
  line width=2pt,
  % the "wipeout" path shouldn't be thicker than the original path
  clip width=1,%
  % the paths are quite thick so we need a wide clip radius
  clip radius=20pt,
  % the intersections aren't near the ends of the paths
  ignore endpoint intersections=true,%
  % this turns into the edge colour
  background colour=white,%
  % the list of crossings to flip
  flip crossing/.list={2,5,8,11,14},
  % when rendering an intersection, apply this style
  every intersection/.style={
    % set to the full width of the path, this is used when the
    % wipeout path is drawn
    line width=13pt,
    only when rendering/.style={
      % these are used when redrawing the over-path, only the
      % central part of the path is drawn here;
      % set the colour to the strand colour
      draw=\pgfkeysvalueof{/tikz/strand colour},
      % this is the width of the inner part
      line width=9pt,
      % disable the double feature
      double=none,
    }
  },
  % when drawing the symbol originally, we use this style
  only when rendering/.style={
    % outer colour
    white,
    % width of the outer edge
    line width=2pt,
    % width of the inner path
    double distance=9pt,
    % colour of the inner path
    double=\pgfkeysvalueof{/tikz/strand colour},
  },
]
\strand[infinity path={0}{5}];
\strand[infinity path={1}{5}];
\strand[infinity path={2}{5}];
\strand[infinity path={3}{5}];
\strand[infinity path={4}{5}];
\end{knot}
\end{tikzpicture}

\end{document}

五边形中的无穷符号

5s改为6s,将半径从2.8改为3.3,并添加一条额外的链,得到六边形版本。

六角形符号

答案2

这是使用 的近似值clips。我pic为要绘制的无穷大符号制作了一个,分为两部分(顶部和底部)。然后,我的方法中最重要的事情是使用所需的clips。它们是将每个无穷大符号固定在其他符号上方或下方的关键。

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}

% dimensions
\def\R {2}   % outer radius
\def\r {1}   % inner radius
\def\sp{13}  % centers separation
\pgfmathsetmacro\a{acos((0.5*\R+0.5*\r)/\R)} % intersection angle (between circles)

% styles
\definecolor{color1}{rgb}{0  ,0.4,0  } % green
\definecolor{color2}{rgb}{0  ,0  ,0.4} % blue
\definecolor{color3}{rgb}{1  ,0.4,0  } % orange
\definecolor{color4}{rgb}{1  ,1  ,0  } % yellow
\definecolor{color5}{rgb}{0.7,0  ,0  } % red
\definecolor{color6}{rgb}{0.4,0  ,0.4} % magenta
\tikzset
{%
  pics/infinity/.style={%
    code={%
    \foreach\i in {-1,1}
    {% fill
      \begin{scope}[x={(\i cm,0 cm)}, y={(0 cm,\i cm)}]
        \fill (0.5*\R+1.5*\r,0) arc (360:180:\r)          arc (0:180:0.5*\R-0.5*\r) arc
              (360:180:\r)      arc (0:180:0.5*\R-0.5*\r) arc (180:360-\a:\R) arc
              (180+\a:360:\R) -- cycle;
      \end{scope}
    }
    \foreach\i in {-1,1}
    {% draw
      \begin{scope}[x={(\i cm,0 cm)}, y={(0 cm,\i cm)}]
        \draw (-0.5*\R+0.5*\r,0) arc (-180:180-\a:\R);
        \draw (\R-0.5*\r,0) circle (\r);
      \end{scope}
    }
  }},
}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,line width=0.75mm]
\def\HA{4.3}  % 'hexagon'  apotheme
\def\PA{3.5}  % 'pentagon' apotheme
\useasboundingbox (-1.55*\HA,-1.55*\HA) rectangle (\sp+1.7*\PA,1.55*\HA);
\begin{scope} %  hexagon
\foreach\i in {1,...,6}
  \draw (60*\i-30:\HA) pic[rotate=60*\i+60,draw=gray!15,fill=color\i]{infinity};
\begin{scope}
  \clip (0,0) -- (30:2*\HA) -- (-30:2*\HA) -- cycle;
  \draw (60-30:\HA) pic[rotate=60+60,draw=gray!15,fill=color1]{infinity};
\end{scope}
\clip (0,0) circle (\HA);
\foreach\i in {5,...,1}
  \draw (60*\i-30:\HA) pic[rotate=60*\i+60,draw=gray!15,fill=color\i]{infinity};
\begin{scope}
  \clip (0,0) -- (30:2*\HA) -- (-30:2*\HA) -- cycle;
  \draw (60*6-30:\HA) pic[rotate=60*6+60,draw=gray!15,fill=color6]{infinity};
\end{scope}
\end{scope}
%
\begin{scope}[shift={(\sp,0)}] % pentagon
\foreach\i in {1,...,5}
  \draw (72*\i-18:\PA) pic[rotate=72*\i-108,draw=gray!15,fill=color\i]{infinity};
\begin{scope}
  \clip (0,0) -- (69:2.5*\PA) -- (-3:2.5*\PA) -- cycle;
  \draw (72-18:\PA) pic[rotate=72-108,draw=gray!15,fill=color1]{infinity};
\end{scope}
\clip (0,0) circle (\PA);
\foreach\i in {5,...,1}
  \draw (72*\i-18:\PA) pic[rotate=72*\i-108,draw=gray!15,fill=color\i]{infinity};
\begin{scope}
  \clip (0,0) -- (69:2.5*\PA) -- (-3:2.5*\PA) -- cycle;
  \draw (72*5-18:\PA) pic[rotate=72*5-108,draw=gray!15,fill=color5]{infinity};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:添加了“六边形”。

相关内容