海龟绘图
AnglePath 通过连续指定相对于前一个点的位移来获取二维点列表. 该列表与 Logo 编程语言的龟标图形路径相对应.
生成简单的龟标图形.
In[1]:=
![Click for copyable input](assets.zh/turtle-graphics/In_64.png)
Graphics[Line[AnglePath[ConstantArray[110 \[Degree], 100]]]]
Out[1]=
![](assets.zh/turtle-graphics/O_57.png)
生成科赫雪花曲線.
In[2]:=
![Click for copyable input](assets.zh/turtle-graphics/In_65.png)
Graphics[Line[AnglePath[Array[ThueMorse, 4096] 2 Pi/3]]]
Out[2]=
![](assets.zh/turtle-graphics/O_58.png)
生成龙形曲线.
In[3]:=
![Click for copyable input](assets.zh/turtle-graphics/In_66.png)
Graphics[Line[
AnglePath[{90 \[Degree], -90 \[Degree]}[[
1 + Nest[Join[#, {0}, Reverse[1 - #]] &, {0}, 10]]]]]]
Out[3]=
![](assets.zh/turtle-graphics/O_59.png)
生成其他有趣曲线.
In[4]:=
![Click for copyable input](assets.zh/turtle-graphics/In_67.png)
Graphics[Line[AnglePath[N@Range[100000]]]]
Out[4]=
![](assets.zh/turtle-graphics/O_60.png)