科赫雪花反雪花的面积为多少

canvas绘制科赫雪花 - 绅士精灵 - ITeye技术网站
博客分类:
&title&JS&/title&
&canvas id="square" width=500 height=500&&/canvas&
var deg = Math.PI/180;
function snowflake(c, n, x, y, len) {
// Save current transformation
c.translate(x,y);
// Translate origin to starting point
c.moveTo(0,0);
// Begin a new subpath at the new origin
// Draw the first leg of the snowflake
c.rotate(-120*deg); // Now rotate 120 degrees counterclockwise
// Draw the second leg
c.rotate(-120*deg); // Rotate again
// Draw the final leg
c.closePath();
// Close the subpath
c.restore();
// And restore original transformation
// Draw a single leg of a level-n Koch snowflake.
// This function leaves the current point at the end of the leg it has
// drawn and translates the coordinate system so the current point is (0,0).
// This means you can easily call rotate() after drawing a leg.
function leg(n) {
// Save the current transformation
if (n == 0) {
// Nonrecursive case:
c.lineTo(len, 0);
Just draw a horizontal line
// Recursive case: draw 4 sub-legs like:
c.scale(1/3,1/3);
// Sub-legs are 1/3rd the size of this leg
// Recurse for the first sub-leg
c.rotate(60*deg);
// Turn 60 degrees clockwise
// Second sub-leg
c.rotate(-120*deg); // Rotate 120 degrees back
// Third sub-leg
c.rotate(60*deg);
// Rotate back to our original heading
// Final sub-leg
c.restore();
// Restore the transformation
c.translate(len, 0);
// But translate to make end of leg (0,0)
var canvas = document.getElementById("square");
c2 = canvas.getContext("2d");
snowflake(c2,4,150,115,125);
c2.stroke();
&linearGradient id="fade"&
&stop offset="0%" stop-color="#008"/&
&stop offset="100%" stop-color="#ccf"/&
&/linearGradient&
&rect x="100" y="100" width="300" height="200" stroke="black" stroke-width="25" fill="url(#fade)"/&
&input type="button" value="input" onclick="aaa()"/&
浏览: 16989 次
来自: 绍兴java分形绘制科赫雪花曲线代码分享-android100学习网
java分形绘制科赫雪花曲线代码分享
 部分与整体以某种形式相似的形,称为分形,科赫曲线是一种外形像雪花的几何曲线,所以又称为雪花曲线,它是分形曲线中的一种,画法如下首先我们举个例子:我们可以看到西兰花一小簇是整个花簇的一个分支,
&部分与整体以某种形式相似的形,称为分形,科赫曲线是一种外形像雪花的几何曲线,所以又称为雪花曲线,它是分形曲线中的一种,画法如下
首先我们举个例子:
我们可以看到西兰花一小簇是整个花簇的一个分支,而在不同尺度下它们具有自相似的外形。换句话说,较小的分支通过放大适当的比例后可以得到一个与整体几乎完全一致的花簇。因此我们可以说西兰花簇是一个分形的实例。
分形一般有以下特质:
在任意小的尺度上都能有精细的结构; 太不规则,以至难以用传统欧氏几何的语言描述; (至少是大略或任意地)自相似豪斯多夫维数会大於拓扑维数; 有著简单的递归定义。
(i)分形集都具有任意小尺度下的比例细节,或者说它具有精细的结构。
(ii)分形集不能用传统的几何语言来描述,它既不是满足某些条件的点的轨迹,也不是某些简单方程的解集。
(iii)分形集具有某种自相似形式,可能是近似的自相似或者统计的自相似。
(iv)一般,分形集的“分形维数”,严格大于它相应的拓扑维数。
(v)在大多数令人感兴趣的情形下,分形集由非常简单的方法定义,可能以变换的迭代产生。
用java写分形时,不同的图形根据不同的画法调用递归来实现,如:
科赫曲线:
public void draw1(int x1, int y1, int x2, int y2,int depth) {//科赫曲线 &
& & & & g.drawLine(x1, y1, x2, y2); &
& & & & if (depth&=1) &
& & & & & & &
& & & & else {//得到三等分点 &
& & & & & & double x11 = (x1 * 2 &+ x2) &/ 3; &
& & & & & & double y11 = (y1 * 2 &+ y2) / 3; &
& & & & & & double x22 = (x1 + x2 * 2) / 3; &
& & & & & & double y22 = (y1 + y2 * 2) / 3; &
& & & & & & double x33 = (x11 + x22) / 2 - (y11 - y22) * Math.sqrt(3) / 2; &
& & & & & & double y33 = (y11 + y22) / 2 - (x22 - x11) * Math.sqrt(3) / 2; &
& & & & & & g.setColor(j.getBackground()); &
& & & & & & g.drawLine((int) x1, (int) y1, (int) x2, (int) y2); &
& & & & & & g.setColor(Color.black); &
& & & & & & draw1((int) x1, (int) y1, (int) x11, (int) y11,depth-1); &
& & & & & & draw1((int) x11, (int) y11, (int) x33, (int) y33,depth-1); &
& & & & & & draw1((int) x22, (int) y22, (int) x2, (int) y2,depth-1); &
& & & & & & draw1((int) x33, (int) y33, (int) x22, (int) y22,depth-1); &
& & & & } &
public void draw2(int x1, int y1, int m,int depth) {//正方形
& & & & g.fillRect(x1, y1, m, m); &
& & & & m = m / 3; &
& & & & if (depth&=1) &
& & & & & & &
& & & & else{ &
& & & & double x11 = x1 - 2 * &
& & & & double y11 = y1 - 2 * &
& & & & double x22 = x1 + &
& & & & double y22 = y1 - 2 * &
& & & & double x33 = x1 + 4 * &
& & & & double y33 = y1 - 2 * &
& & & & double x44 = x1 - 2 * &
& & & & double y44 = y1 + &
& & & & double x55 = x1 + 4 * &
& & & & double y55 = y1 + &
& & & & double x66 = x1 - 2 * &
& & & & double y66 = y1 + 4 * &
& & & & double x77 = x1 + &
& & & & double y77 = y1 + 4 * &
& & & & double x88 = x1 + 4 * &
& & & & double y88 = y1 + 4 * &
& & & & draw2((int) x11, (int) y11, (int) m,depth-1); &
& & & & draw2((int) x22, (int) y22, (int) m,depth-1); &
& & & & draw2((int) x33, (int) y33, (int) m,depth-1); &
& & & & draw2((int) x44, (int) y44, (int) m,depth-1); &
& & & & draw2((int) x55, (int) y55, (int) m,depth-1); &
& & & & draw2((int) x66, (int) y66, (int) m,depth-1); &
& & & & draw2((int) x77, (int) y77, (int) m,depth-1); &
& & & & draw2((int) x88, (int) y88, (int) m,depth-1); &
& & & & } &
谢冰斯基三角形:
public void draw3(int x1,int y1,int x2,int y2,int x3,int y3,int depth){//三角形 &
& & & & double s = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); &
& & & & g.drawLine(x1,y1,x2,y2); &
& & & & g.drawLine(x2,y2,x3,y3); &
& & & & g.drawLine(x1,y1,x3,y3); &
// & & &if(s&3) &
// & & & & & &
& & & & if (depth&=1) &
& & & & & & &
& & & & else &
& & & & { &
& & & & /*&
& & & & &* 上面的三角形&
& & & & &*/ &
& & & & double x11=(x1*3+x2)/4; &
& & & & double y11=y1-(s/4)*Math.sqrt(3); &
& & & & double x12=(x1+x2*3)/4; &
& & & & double y12=y11; &
& & & & double x13=(x1+x2)/2; &
& & & & double y13=y1; &
& & & & /*&
& & & & &* 左边的三角形&
& & & & &*/ &
& & & & double x21=x1-s/4; &
& & & & double y21=(y1+y3)/2; &
& & & & double x22=x1+s/4; &
& & & & double y22=y21; &
& & & & double x23=x1; &
& & & & double y23=y3; &
& & & & /*&
& & & & &* 右边的三角形&
& & & & &*/ &
& & & & double x31=x2+s/4; &
& & & & double y31=(y1+y3)/2; &
& & & & double x32=x2-s/4; &
& & & & double y32=y21; &
& & & & double x33=x2; &
& & & & double y33=y3; &
& & & & &&
& & & & draw3((int)x11,(int)y11,(int)x12,(int)y12, (int)x13, (int)y13, depth-1); &
& & & & draw3((int)x21,(int)y21,(int)x22,(int)y22, (int)x23, (int)y23, depth-1); &
& & & & draw3((int)x31,(int)y31,(int)x32,(int)y32, (int)x33, (int)y33, depth-1); &
& & & & } &
科赫曲线是一种外形像雪花的几何曲线,所以又称为雪花曲线,它是分形曲线中的一种,具体画法如下:
1、任意画一个正三角形,并把每一边三等分;
2、取三等分后的一边中间一段为边向外作正三角形,并把这“中间一段”擦掉;
3、重复上述两步,画出更小的三角形。
4、一直重复,直到无穷,所画出的曲线叫做科赫曲线。
小结:分形是个很好玩的东西,根据自己的奇妙想象可以画出很多很好看的图形,不仅仅是已经存在的,你可以创造出属于你自己的图形!推荐到广播
282784 人聚集在这个小组
(blackcherry)
(有种你爱我)
(有种你爱我)
(Arabesque.)
(Dan 大大!)
第三方登录:初中数学 COOCO.因你而专业 !
你好!请或
如图是瑞典人科赫(Koch)在1906年构造的能够描述雪花形状的科赫雪花图案
使用次数:0
入库时间:
如图是瑞典人科赫(Koch)在1906年构造的能够描述雪花形状的科赫雪花图案.图形的作法是,从一个正三角形开始,把每条边分成三等份,然后以各边的中间长度为底边.分别向外作正三角形,再把“底边”线段抹掉.反复进行这一过程,就会得到一个“雪花”样子的曲线.这是一个极有特色的图形:在图形不断变换的过程中,它的周长趋于无穷大,而其面积却趋于定值.如果假定原正三角形边长为,则可算出下图每步变换后科赫雪花的周长:=3,=&&&&
,…,则=&&&&急求!!“科赫雪花”面积的规律?
急求!!“科赫雪花”面积的规律?
[1]科赫雪花曲线是分形曲线,随着N增大,长度趋向于无穷大. 
周长和面积只有给出具体的N才有意义, 
我下面给出它的计算式 
边长通项an=a*(1/3)^(n-1) 
边数通项bn=3*(1/4)^(n-1) 
面积通项S(n+1)=S(n)+6*(1/4)*√3an^2 S1=(1/4)*√3a1^2 
周长通项c(n)=an*bn=3a*(4/3)^n 

的感言:很不错 相关知识
相关知识等待您来回答
理工学科领域专家

我要回帖

更多关于 科赫雪花 的文章

 

随机推荐