蜥蜴镶嵌平面

蜥蜴镶嵌平面

我想要绘制下面的镶嵌图案。

\documentclass[10pt]{standalone}
\usepackage{pgf,tikz}
\begin{document}

\begin{tikzpicture}[scale=.6]%
\tikzset{scale=1.30341}
\newcommand\lizard[1]{%
\begin{scope}[#1]
  \filldraw (13.422918137345045,13.680978525125255)-- (13.659953556507825,13.846185029390224)-- (15.12526342042319,13.264370818717946)-- (15.391030405545093,11.777512280333239)-- (15.67116317364656,11.72004914841499)-- (16.579817341897726,12.425703855507482)-- (16.3646984930814,12.79140589849524)-- (15.84841325592221,12.866697495580956)-- (15.855161459468931,13.94010548381755)-- (16.668860668412805,13.917291487305105)-- (17.144152262422075,13.213859928171386)-- (17.752525502753944,12.552254029310484)-- (16.597341279799362,11.197766370466836)-- (17.410102311005424,10.35027196185881)-- (17.792169462427076,11.135246291143293)-- (18.792490731603767,11.934113971388562)-- (20.142686568606667,11.576169106938247)-- (21.087525279275397,11.588029007072164)-- (20.94915977771303,11.010847200554867)-- (20.81898250767505,10.852366908234124)-- (20.805528357695607,10.704371258460256)-- (20.676368517892957,10.51332232875217)-- (18.876203250643528,10.820076948283461)-- (18.59420516307783,9.915506925354336)-- (18.193025228305295,9.164206320234863)-- (18.6379702468712,8.427494076379846)-- (18.844666925808617,6.904818820144172)-- (17.95862112841492,5.901748106113575)-- (18.192670961688727,6.932681895533911)-- (17.624264223738052,8.141939367448574)-- (17.18402763258018,8.336980895176746)-- (16.208819993939315,7.963615684954246)
-- (15.634840640910692,8.147511982526522)-- (14.922287521677037,7.623232424645655)-- (15.261696345666758,7.3517053654538795)-- (15.60110516965648,7.088663526861846)-- (15.8,6.8)-- (15.818151045174377,6.433008174003308)-- (15.725830225603188,6.0054170096735975)-- (15.686958301573215,5.636133731388847)-- (14.91923780198123,5.947109123628637)-- (14.788045058380069,6.501034041055762)-- (14.,7.2)-- (13.952298691735633,7.71578166699244)-- (14.438197742110306,8.303719517945792)-- (14.783186067876324,8.85278544486917)-- (15.685514906635822,9.085791062307269)-- (14.299779078148498,9.369847714130154)-- (13.09445760960274,8.36413362254102)-- (12.771872470843727,8.600141859203525)-- (12.509763327084142,8.722053088859145)-- (12.2,9.)
-- (11.979449478082195,8.566616271048229)-- (11.537521270580571,8.551377367341278)-- (11.264191606843669,9.519220185870521)-- (11.468789386562122,9.912844780375393)-- (12.36318613741914,9.693238435298893)-- (12.930169791980285,9.473632090222395)-- (14.171943852321949,10.300150516237583)-- (14.116876121116597,10.778510755204247)-- (12.907128162651231,11.952908935662506)-- (13.422918137345045,13.680978525125255);

\end{scope}
}

\lizard{shift={(0,0)}, fill=white};
\lizard{shift={(8,0)}, fill=cyan};
\lizard{shift={(16,0)}, fill=white};
\lizard{shift={(24,0)}, fill=cyan};
\end{tikzpicture}
\end{document}

答案1

您只是在寻找rotate around={<angle>:<coordinate>}语法吗?

\documentclass[10pt]{standalone}
\usepackage{pgf,tikz}
\begin{document}
\begin{tikzpicture}[scale=.6]%
\tikzset{scale=1.30341}
\newcommand\lizard[1]{%
\begin{scope}[#1]
  \filldraw (13.422918137345045,13.680978525125255)-- (13.659953556507825,13.846185029390224)-- (15.12526342042319,13.264370818717946)-- (15.391030405545093,11.777512280333239)-- (15.67116317364656,11.72004914841499)-- (16.579817341897726,12.425703855507482)-- (16.3646984930814,12.79140589849524)-- (15.84841325592221,12.866697495580956)-- (15.855161459468931,13.94010548381755)-- (16.668860668412805,13.917291487305105)-- (17.144152262422075,13.213859928171386)-- (17.752525502753944,12.552254029310484)-- (16.597341279799362,11.197766370466836)-- (17.410102311005424,10.35027196185881)-- (17.792169462427076,11.135246291143293)-- (18.792490731603767,11.934113971388562)-- (20.142686568606667,11.576169106938247)-- (21.087525279275397,11.588029007072164) -- (20.94915977771303,11.010847200554867)-- (20.81898250767505,10.852366908234124)-- (20.805528357695607,10.704371258460256)-- (20.676368517892957,10.51332232875217)-- (18.876203250643528,10.820076948283461)-- (18.59420516307783,9.915506925354336)-- (18.193025228305295,9.164206320234863)-- (18.6379702468712,8.427494076379846)-- (18.844666925808617,6.904818820144172)-- (17.95862112841492,5.901748106113575)-- (18.192670961688727,6.932681895533911)-- (17.624264223738052,8.141939367448574)-- (17.18402763258018,8.336980895176746)-- (16.208819993939315,7.963615684954246)
-- (15.634840640910692,8.147511982526522)-- (14.922287521677037,7.623232424645655)-- (15.261696345666758,7.3517053654538795)-- (15.60110516965648,7.088663526861846)-- (15.8,6.8)-- (15.818151045174377,6.433008174003308)-- (15.725830225603188,6.0054170096735975)-- (15.686958301573215,5.636133731388847)-- (14.91923780198123,5.947109123628637)-- (14.788045058380069,6.501034041055762)-- (14.,7.2) -- (13.952298691735633,7.71578166699244)-- (14.438197742110306,8.303719517945792)-- (14.783186067876324,8.85278544486917)-- (15.685514906635822,9.085791062307269)-- (14.299779078148498,9.369847714130154)-- (13.09445760960274,8.36413362254102)-- (12.771872470843727,8.600141859203525)-- (12.509763327084142,8.722053088859145)-- (12.2,9.)
-- (11.979449478082195,8.566616271048229)-- (11.537521270580571,8.551377367341278)-- (11.264191606843669,9.519220185870521)-- (11.468789386562122,9.912844780375393)-- (12.36318613741914,9.693238435298893)-- (12.930169791980285,9.473632090222395)-- (14.171943852321949,10.300150516237583)-- (14.116876121116597,10.778510755204247)-- (12.907128162651231,11.952908935662506) -- (13.422918137345045,13.680978525125255);

\end{scope}
}

\lizard{fill=yellow};
\lizard{rotate around={120:(12.907128162651231,11.952908935662506)}, fill=cyan};
\lizard{rotate around={-120:(12.907128162651231,11.952908935662506)}, fill=violet};
\lizard{shift={(30:10.3)}, rotate around={-120:(12.907128162651231,11.952908935662506)}, fill=violet};
\end{tikzpicture}
\end{document}

您可以使用编程方式进行平移和旋转,\foreach以镶嵌更大的区域。

另外,你的形状似乎没有完全镶嵌。你也在寻找解决这个问题的方法吗?

编辑:建议修复形状,使其镶嵌成镶嵌状。

为了固定形状,您需要 a) 三个蜥蜴相遇的角以形成六角形格子(可能是常规格子)和 b) 应该组合在一起以实际上形成相同形状的路径段。

您可以通过计算角点相对于彼此的位置来实现 (a)。您的路径似乎接近边长为 3.35 的正六边形,因此我刚刚将角点修正为正六边形。

实现 (b) 比较棘手。每条路径有两个不同版本,所以我只选择了一个用于两侧。要使六边形的两个互锁边“具有相同的形状”,需要旋转,但由于您可以rotate around为路径的一部分指定范围,因此实现起来并不难。棘手的是,为了绕六边形走,您需要向前遍历每个部分一次,然后再次旋转和后退。可能有比我做的更好的方法,那就是复制路径的一部分并反转坐标的顺序(参见这个帖子以寻求更好的解决方案)。

我的最终(但相当草率的)解决方案如下:

\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\newcommand{\patha}{
  (20.14268656860666,11.576169106938247)--
  (21.087525279275397,11.588029007072164)--
  (20.94915977771303,11.010847200554867)--
  (20.81898250767505,10.852366908234124)--
  (20.805528357695607,10.704371258460256)--
  (20.676368517892957,10.51332232875217)--
  (18.876203250643528,10.820076948283461)--
  (18.59420516307783,9.915506925354336)--
  (18.193025228305295,9.164206320234863)
  }
\newcommand{\patharev}{
  (18.193025228305295,9.164206320234863)--
  (18.59420516307783,9.915506925354336)--
  (18.876203250643528,10.820076948283461)--
  (20.676368517892957,10.51332232875217)--
  (20.805528357695607,10.704371258460256)--
  (20.81898250767505,10.852366908234124)--
  (20.94915977771303,11.010847200554867)--
  (21.087525279275397,11.588029007072164)--
  (20.14268656860666,11.576169106938247)
}
\newcommand{\pathb}{
  (18.844666925808617,6.904818820144172)--
  (17.95862112841492,5.901748106113575)--
  (18.192670961688727,6.932681895533911)--
  (17.624264223738052,8.141939367448574)--
  (17.18402763258018,8.336980895176746) --
  (16.208819993939315,7.963615684954246)--
  (15.634840640910692,8.147511982526522)--
  (14.922287521677037,7.623232424645655)--
  (15.261696345666758,7.3517053654538795)--
  (15.60110516965648,7.088663526861846)
}
\newcommand{\pathbrev}{
  (15.60110516965648,7.088663526861846)--
  (15.261696345666758,7.3517053654538795)--
  (14.922287521677037,7.623232424645655)--
  (15.634840640910692,8.147511982526522)--
  (16.208819993939315,7.963615684954246)--
  (17.18402763258018,8.336980895176746) --
  (17.624264223738052,8.141939367448574)--
  (18.192670961688727,6.932681895533911)--
  (17.95862112841492,5.901748106113575)--
  (18.844666925808617,6.904818820144172)
}
\newcommand{\pathc}{
  (12.771872470843727,8.600141859203525)--
  (12.509763327084142,8.722053088859145)--
  (12.2,9.)--
  (11.979449478082195,8.566616271048229)--
  (11.537521270580571,8.551377367341278)--
  (11.264191606843669,9.519220185870521) --
  (11.468789386562122,9.912844780375393)--
  (12.36318613741914,9.693238435298893)--
  (12.930169791980285,9.473632090222395)--
  (14.171943852321949,10.300150516237583)--
  (14.116876121116597,10.778510755204247)
}
\newcommand{\pathcrev}{
  (14.116876121116597,10.778510755204247) --
  (14.171943852321949,10.300150516237583)--
  (12.930169791980285,9.473632090222395)--
  (12.36318613741914,9.693238435298893)--
  (11.468789386562122,9.912844780375393)--
  (11.264191606843669,9.519220185870521) --
  (11.537521270580571,8.551377367341278)--
  (11.979449478082195,8.566616271048229)--
  (12.2,9.)--
  (12.509763327084142,8.722053088859145)--
  (12.771872470843727,8.600141859203525)
}
\newcommand\lizard[1]{%
\begin{scope}[#1, thick]
  \filldraw (18.7,11.93) coordinate (b) -- \patha --
  ($(b)+(-90:3.35)$) coordinate (c) -- \pathb --
  ($(c) + (-150:3.35)$) coordinate (d) {[rotate around={120:(d)}] -- \pathbrev} --
  ($(d)+(150:3.35)$) coordinate (e) -- \pathc --
  ($(e)+(90:3.35)$) coordinate (f) {[rotate around={120:(f)}] -- \pathcrev} --
  ($(f)+(30:3.35)$) coordinate (a) {[rotate around={-120:(18.7,11.93)}] -- \patharev} --cycle;
\end{scope}
}

\lizard{fill=yellow};
\lizard{rotate around={120:(f)}, fill=cyan};
\lizard{rotate around={-120:(f)}, fill=violet};
\lizard{rotate around={-120:(f)}, shift={(150:10.05)}, fill=red};
\end{tikzpicture}
\end{document}

请注意,宏\patha\patharev等是相当多余的,但我保留了它们的名称,以便更清楚地了解绘制镶嵌时发生的情况。

可能如果您是从头开始执行此操作而不是从跟踪的图片执行此操作,您会希望将形状定位在坐标系上,以便其中一个角是(0,0),但现在修复此问题需要大量的算术(您可能能够自动化)。

答案2

不完全是,但有点像:

\documentclass[tikz,border=5]{standalone}
\tikzset{pics/.cd, lizard/.style={code={
\path [every lizard/.try, #1]
 (  0, 20) -- ( 10, 27) -- ( 14, 27) -- ( 15, 20) --
 (  7, 11) -- ( 10, 10) -- ( 14, 10) -- ( 16, 13) -- ( 15, 15) -- ( 22, 22) --
 ( 24, 19) -- ( 20, 11) -- ( 20,  7) -- ( 15,  5) -- (  8,  3) -- (  5, -5) --
 ( 12, -1) -- ( 15,  0) -- ( 20,  0) -- ( 20, -5) -- ( 21, -7) -- ( 25,-10) --
 ( 17,-15) -- ( 15,-10) -- ( 13, -7) -- (  9,-11) -- (  1,-16) -- ( -2,-20) --
 ( -9,-28) -- (-18,-33) -- ( -7,-20) -- ( -7,-15) -- (-12,-15) -- (-13,-12) --
 (-18,-12) -- (-20,-20) -- (-28,-26) -- (-28,-21) -- (-25,-17) -- (-25,-12) --
 (-20, -7) -- ( -7, -5) -- (-12, -1) -- (-20, -2) -- (-20,  5) -- (-23,  4) --
 (-24,  6)  --(-20, 10) -- (-16, 13) -- (-15,  5) -- ( -7,  6) -- ( -3, 10) --
 cycle;
}}}
\begin{document}
\begin{tikzpicture}[x=(330:5pt),y=(90:5pt)]
\pic at (  0,  0) {lizard={fill=red}};
\pic at (-20, 20) {lizard={fill=yellow, rotate=240}};
\pic at ( 20, 40) {lizard={fill=pink,   rotate=120}};
\pic at ( 40, 20) {lizard={fill=green,  rotate=240}};
\pic at ( 20,-20) {lizard={fill=orange, rotate=120}};
\pic at (-20,-40) {lizard={fill=purple, rotate=240}};
\pic at (-40,-20) {lizard={fill=blue,   rotate=120}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容