Forgot password
 Register account
View 150|Reply 3

L系統

[Copy link]

3200

Threads

7827

Posts

52

Reputation

Show all posts

hbghlyj posted 2022-8-19 13:35 |Read mode
L-Systems Turtle Graphics Renderer - HTML5 Canvas - by Kevin Roast

zh.wikipedia.org/zh-hans/L系統
L系统与分形图 - 木匣子的博客


L-system指的是带参数的L-system,定义如下:

G={V,S,ω,P},

V:变量符号集合
S:常量符号集合
ω:初始状态串
P:产生式规则

L-system在一次迭代中可同时套用许多不同的文法规则。


例1:海藻的生长

Lindenmayer研究海藻生长模式时提出的最早的L-系统:

    变量 : A B
    常量 : 无
    公理  : A
    规则  : (A → AB), (B → A)

迭代过程:

    n = 0 : A
    n = 1 : AB
    n = 2 : ABA
    n = 3 : ABAAB
    n = 4 : ABAABABA
    n = 5 : ABAABABAABAAB
    n = 6 : ABAABABAABAABABAABABA
    n = 7 : ABAABABAABAABABAABABAABAABABAABAAB

例1的解释

n=0:         A           开始 (公理/起始点)
            / \
n=1:       A   B         根据规则A→AB起点A拓展成AB,由于起始点无B,规则B→A未被用到
          /|    \
n=2:     A B     A       AB中的A拓展成AB,B变成A,于是得到了ABA
        /| |     |\
n=3:   A B A     A B     可以看到每个A都是一个子树的根,由此引发出和整体结构同构的子结构。
      /| | |\    |\ \
n=4: A B A A B   A B A   


如果我们观察这个序列的长度就会发现这是一个斐波那契数列—— 1 2 3 5 8 13 21 34 55 89 ...

673

Threads

110K

Posts

218

Reputation

Show all posts

kuing posted 2022-8-19 13:55
我记得 tikz 也有 L-系统 的 library

3200

Threads

7827

Posts

52

Reputation

Show all posts

original poster hbghlyj posted 2022-8-19 21:00
kuing 发表于 2022-8-19 06:55
我记得 tikz 也有 L-系统 的 library
找到了
tikz.dev/library-lsystems

3200

Threads

7827

Posts

52

Reputation

Show all posts

original poster hbghlyj posted 2022-8-19 21:05
TikZ手册cover page的两棵树是这样画的:
  1. \foreach \where in {-9cm,9cm} {
  2. \nodeshadowed [at={(\where,5cm)}] { \tikz
  3. \draw [green!20!black, rotate=90,
  4. l-system={rule set={F -> FF-[-F+F]+[+F-F]},
  5. axiom=F, order=4,step=2pt,
  6. randomize step percent=50, angle=30,
  7. randomize angle percent=5}] l-system; }}
Copy the Code

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-15 14:52 GMT+8

Powered by Discuz!

Processed in 0.013663 seconds, 22 queries