多语言展示
当前在线:1534今日阅读:19今日分享:20

用Mathematica演示“中点迭代”现象

给出若干随机点,如果依次取相邻点的中点,形成新的点集;重复这个过程,最后会趋向于一个椭圆。下面用Mathematica演示一下这个现象。用Mathematica的Graphics作图的好处是,可以自动的把图形放缩到合适的大小,否则随着迭代深度变大,图形会越来越小。下图,是每隔50次操作,得到的动态图最后的结果是3000次迭代的结果。
工具/原料
1

电脑

2

Mathematica

方法/步骤
1

给出平面上的100个随机点,顺次连接线段,形成一个折线图形:pl = RandomPoint[Disk[], 100];Graphics[{Point[pl],Line[pl]}]

2

依次取各条线段的中点,再顺次连接这些中点,得到新的折线图形:pl1=Table[(RotateRight[pl,n][[1]]+RotateRight[pl,n][[2]])/2,{n,100}];{Graphics[{Point[pl],Line[pl],Point[pl1],Line[pl1]}],     Graphics[{Point[pl1],Line[pl1]}]}

3

再执行一次上面的操作:pl2=Table[(RotateRight[pl1,n][[1]]+RotateRight[pl1,n][[2]])/2,{n,100}];{Graphics[{Point[pl1],Line[pl1],Point[pl2],Line[pl2]}],     Graphics[{Point[pl2],Line[pl2]}]}

4

用Nest对上面的操作进行迭代:pl100=Nest[Table[(RotateRight[#,n][[1]]+RotateRight[#,n][[2]])/2,    {n,100}]&,pl,100];{Graphics[{Point[pl99],Line[pl99],Point[pl100],Line[pl100]}],     Graphics[{Point[pl100],Line[pl100]}]}下图就是第100操作之后得到的图形。

5

再看看迭代到1000次的效果图:pl1000=Nest[Table[(RotateRight[#,n][[1]]+RotateRight[#,n][[2]])/2,    {n,100}]&,pl,1000];{Graphics[{Point[pl999],Line[pl999],Point[pl1000],Line[pl1000]}],     Graphics[{Point[pl1000],Line[pl1000]}]}

6

用一个动画来演示这个过程的效果,迭代深度定为3000次。

注意事项
1

Mathematica的Graphics,可以把图像放缩到合适的大小,且又不失比例,是演示这个现象的有效方法。

2

由于对应的动态图有3000多帧,所以没能够上传。

推荐信息