[转载] Python中的Phyllotaxis模式| 算法植物学的一个单位
参考链接: Python中的Phyllotaxis模式| 算法植物学的单位
简介| 叶底
Phyllotaxis / phyllotaxy是植物茎上叶子的排列,Phyllotactic螺旋形成自然界中独特的一类模式。这个词本身来自希腊语phullon,意思是“叶子”和出租车,意思是“安排”。基本的花卉叶序安排包括: 螺旋叶状体 -在螺旋叶状体中,个别花器官是在规则的时间间隔内创建的相同的发散角度。具有螺旋叶状花序的花中的发散角近似为137.5度,这表示遵循斐波纳契系列的图案。下图显示具有顺时针和逆时针螺旋图案的螺旋叶状图案。
重点要注意:
Fibonacci系列通常描述自然界中发现的螺旋。它被计算为一系列,其中前一对数字与系列中的下一个数字相加。该系列是1,1,2,3,5,8,13,21,34,55,89 ......。实际上,顺时针方向有一组螺旋,逆时针方向有一组螺旋。花器官螺旋遵循分子和分母组的偏移斐波那契数(1 / 2,1 / 3,2 / 5,3 / 8,5 / 13,8 / 21,13 / 34 ......)。分子是围绕轴返回起始原点的次数或转数。分母表示转弯期间启动的器官数量。因此,2/5表示绕轴旋转2圈,5个器官返回原点。例如 - 在松树中,我们有(2,3),(5,3)和(5,8)个叶状花序,在头状花序中发现的对是(21,34),(55,34),(55,89)和(89,144),并且在具有六边形鳞片的菠萝上,根据样本的大小,发现三联体(8,13,21)或(13,21,34)。植物多样性中斐波那契序列的流行通常被称为“叶序的神秘”。
其他类型的花卉叶序排列是:
2、轮生的Phyllotaxis 3、简单的轮生的Phyllotaxis 4、复杂的轮生的Phyllotaxis 5、不规则的Phyllotaxis
模式的形成:总结
叶子在一些植物中的美丽排列,称为叶序,服从许多微妙的数学关系。例如,向日葵头部的小花形成两个相反方向的螺旋形:顺时针55个,逆时针34个。出奇,
这些数字是连续的斐波纳契数。替代斐波那契数的比率由收敛数给出为φ^( - 2),其中φ是黄金比率,并且据说测量植物茎上连续叶之间的转角分数:例如:榆树和林登的1/2,山毛榉和榛树的1/3,橡木和苹果的2/5,杨树和玫瑰的3/8,柳树和杏仁的5/13等。植物茎上的每个新叶与前一个叶以一定角度定位,并且该叶在叶之间是恒定的:通常约137.5度。
也就是说,如果从上面俯视植物并测量从茎到叶子的线和下一片叶子的相应线之间形成的角度,你会发现通常有一个固定的角度,称为发散角度角度。在这里,我们对Spiral phyllotaxy感兴趣,我们将编码使用龟图形在python中形成Spiral Phyllotaxy模式。
设计守则
我们将编写两个函数,一个用于绘制phyllotaxy图案,另一个用于绘制花瓣。只有在完成叶序图案之后才需要绘制花瓣。因此,我们将从drawPhyllPattern()函数内部调用drawPetal()函数,并在绘制Phyllotaxis图案后访问最后的x和y坐标。drawPetal()函数将使用龟函数和特征绘制花瓣,参考Turtle编程。
要编码叶序模式,我们需要遵循以下等式:
x = r * cos(θ)
y = r * sin(θ)
r,θ也可以变化 - 所以形成叶序模式我们用笛卡尔形式代替
通过极地形式:
r = c * sqrt(n)
θ= n * 137.508°
将问题减少到光盘上的最佳包装,所以
r = c * sqrt(n)来自圆的区域
面积=πr²和n以某些单位填充区域
c1 * n /π=r²,c为1 / sqrt(c1 /π)
所以,r =某个常数c * sqrt(n)
伪代码
进口模块(数学,TURTLE)
功能 - DrawPhyllotaxisPattern(龟,t长度,花瓣开始,角度= 137.508,大小,cspread)
turtleColor( “黑”)
填充颜色('‘橙’)
将角度转换为弧度(Φ)
initialize(xcenter,ycenter)=(0,0)
绘制图案开始:
对于范围(0,t)中的n:
r = cspread * sqrt(n)
θ= n *Φ
x = r * cos(θ)+ xcenter
y = r * sin(θ)+ ycenter
TURTLE POSITION(x,y)
开始绘图():
如果绘图模式结束:
DrawFlowerPetals()
功能 - DrawFlowerPetals(Turtle,x坐标,y坐标)
使用Turtle方法绘制
创建Turtle = gfg
调用DrawPhyllotaxisPattern(gfg,t length,petalstart,angle = 137.508,size,cspread)
结束
实现代码一
import math
import turtle
def drawPhyllPattern(turtle, t, petalstart, angle = 137.508, size = 2, cspread = 4 ):
"""print a pattern of circles using spiral phyllotactic data"""
# initialize position
# turtle.pen(outline=1, pencolor="black", fillcolor="orange")
turtle.color('black')
turtle.fillcolor("orange")
phi = angle * ( math.pi / 180.0 ) #we convert to radian
xcenter = 0.0
ycenter = 0.0
# for loops iterate in this case from the first value until < 4, so
for n in range (0, t):
r = cspread * math.sqrt(n)
theta = n * phi
x = r * math.cos(theta) + xcenter
y = r * math.sin(theta) + ycenter
# move the turtle to that position and draw
turtle.up()
turtle.setpos(x, y)
turtle.down()
# orient the turtle correctly
turtle.setheading(n * angle)
if n > petalstart-1:
turtle.color("yellow")
drawPetal(turtle, x, y)
else: turtle.stamp()
def drawPetal(turtle, x, y ):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.color('black')
turtle.fillcolor('yellow')
turtle.begin_fill()
turtle.right(20)
turtle.forward(70)
turtle.left(40)
turtle.forward(70)
turtle.left(140)
turtle.forward(70)
turtle.left(40)
turtle.forward(70)
turtle.penup()
turtle.end_fill() # this is needed to complete the last petal
gfg = turtle.Turtle()
gfg.shape("turtle")
gfg.speed(0) # make the turtle go as fast as possible
drawPhyllPattern(gfg, 200, 160, 137.508 )
gfg.penup()
gfg.forward(1000)
输出:
代码实现二
import math
import turtle
def drawPhyllotacticPattern( t, petalstart, angle = 137.508, size = 2, cspread = 4 ):
"""print a pattern of circles using spiral phyllotactic data"""
# initialize position
turtle.pen(outline=1, pencolor="black", fillcolor="orange")
# turtle.color("orange")
phi = angle * ( math.pi / 180.0 )
xcenter = 0.0
ycenter = 0.0
# for loops iterate in this case from the first value until < 4, so
for n in range (0, t):
r = cspread * math.sqrt(n)
theta = n * phi
x = r * math.cos(theta) + xcenter
y = r * math.sin(theta) + ycenter
# move the turtle to that position and draw
turtle.up()
turtle.setpos(x, y)
turtle.down()
# orient the turtle correctly
turtle.setheading(n * angle)
if n > petalstart-1:
#turtle.color("yellow")
drawPetal(x, y)
else: turtle.stamp()
def drawPetal( x, y ):
turtle.up()
turtle.setpos(x, y)
turtle.down()
turtle.begin_fill()
#turtle.fill(True)
turtle.pen(outline=1, pencolor="black", fillcolor="yellow")
turtle.right(20)
turtle.forward(100)
turtle.left(40)
turtle.forward(100)
turtle.left(140)
turtle.forward(100)
turtle.left(40)
turtle.forward(100)
turtle.up()
turtle.end_fill() # this is needed to complete the last petal
turtle.shape("turtle")
turtle.speed(0) # make the turtle go as fast as possible
drawPhyllotacticPattern( 200, 160, 137.508, 4, 10 )
turtle.exitonclick() # lets you x out of the window when outside of idle
输出:
转载于:https://www.cnblogs.com/python01/p/10312622.html
[转载] Python中的Phyllotaxis模式| 算法植物学的一个单位相关推荐
- python中forward(200)什么意思_Python中的Phyllotaxis模式| 算法植物学的一个单位
简介| 叶底 Phyllotaxis / phyllotaxy是植物茎上叶子的排列,Phyllotactic螺旋形成自然界中独特的一类模式.这个词本身来自希腊语phullon,意思是"叶子& ...
- python画松树_Python中的Phyllotaxis模式| 算法植物学的一个单位
简介| 叶底 Phyllotaxis / phyllotaxy是植物茎上叶子的排列,Phyllotactic螺旋形成自然界中独特的一类模式.这个词本身来自希腊语phullon,意思是"叶子& ...
- USF MSDS501 计算数据科学中文讲义 2.4 Python 中的编程模式
来源:ApacheCN『USF MSDS501 计算数据科学中文讲义』翻译项目 原文:Programming Patterns in Python 译者:飞龙 协议:CC BY-NC-SA 4.0 现 ...
- monostate 状态_为什么Borg模式比Python中的Singleton模式更好
在python中,如果想要一个可以从任何地方访问的唯一"对象",只需创建一个Unique仅包含静态属性@staticmethods和@classmethods的类:您可以将其称为唯 ...
- [转载] python中for语句用法_详解Python中for循环的使用_python
参考链接: 在Python中将else条件语句与for循环一起使用 这篇文章主要介绍了Python中for循环的使用,来自于IBM官方网站技术文档,需要的朋友可以参考下 for 循环 本系列前面 &q ...
- [转载] python中的for循环对象和循环退出
参考链接: Python中循环 流程控制-if条件 判断条件,1位true,0是flesh,成立时true,不成立flesh,not取反 if 1; print 'hello python' pri ...
- [转载] Python中的memoryview
参考链接: Python memoryview() Python中的memoryview提供了类似C语言指针的功能,有了memoryview,如果某个Object支持buffer protocol,那 ...
- [转载] Python中 hash去重
参考链接: Python hash() 现在有3000条数据,需要插入到数据库中去,使用的是对链接进行MD5加密, hashcode = md5(str(item_url)) 然后在数据库中设置 ha ...
- [转载] python中pass的使用_Python pass详细介绍及实例代码
参考链接: Python pass语句 Python pass详细介绍及实例代码 Python pass的用法: 空语句 do nothing 保证格式完整 保证语义完整 以if语句为例,在c或c++ ...
最新文章
- fprintf()中的stderr解析
- 调用webservice 的时候没法输入参数
- 说一说为什么gethostbyname用完后不用释放内存
- QToolButton设置背景无效的思考
- Python 之 Python2 和 Python3 的区别
- python找不到文件怎么办_python open找不到文件怎么办?
- python中lastch_python复习笔记
- C++之指针探究(二):一级指针和一维数组
- 大同语网站页面资料汇总编书(PDF)
- mysql trim 索引_MySQL常用函数,你真得看看!
- 【PHP学习】—PHP连接数据库(六)
- 在Xcode中制作.a文件
- Socket网络编程——(一)
- linux iometer io
- Typora_Markdown_图片标题(题注)
- 常用DNS列表(电信、网通)
- 我使用的安卓软件名单_我是亲民_新浪博客
- 卧式铣床升降台主传动系统设计
- WLS(适用于Windows的Linux子系统)的安装
- Javascript中引用数据类型
热门文章
- 2020 CTF暑假夏令营培训Day2 密码学Crypto 部分笔记
- 【HNOI2009】【BZOJ1008】越狱(组合,方案数,水题)
- USACO1.1.3 - Friday the Thirteenth
- java发布rest服务器_ArcGIS Server 10 Java 版的Rest服务的部署方法
- linux 7 打开22端口号,Centos 7 修改 SSH 默认端口号
- rsa 公 填充模式的_RSA加密的填充模式
- Python入门--字符串的分割操作,split,rsplit
- 管家婆支持mysql_开放多接口,支持对接管家婆等第三方应用
- OpenGL基础3:渲染管线
- 牛客练习赛23: D. 托米的咒语(暴力)