コッホ雪片(コッホせっぺん)は、上記のコッホ曲線をつなぎ合わせ、始点と終点を一致させたものである。
コッホ雪片は、有限の面積であるにもかかわらず、無限の周囲を持つ。 ※Wikipediaより
Wikipedia引用しすぎですねww
コッホ曲線の応用編
ただコッホ曲線三つくっつけただけだけどねw
有限の面積なのに無限の周囲ってすごいね、あくまで理論上だけど。
余談だけど人間の肺と腸もフラクタルになってるらしい
限られた場所の中でできるだけ多くの酸素や栄養素を取り込むには、有限の面積で無限の周囲をもつフラクタルが一番効率がいいみたい
単純な構造の繰り返しだからフラクタル構造を作るための遺伝子情報も少なくてすむし ってことらしい
うーん人間ってすごい
※クリックでstart
Flash Player 10 にしてください
例によって拡大版をどうぞ
コッホ雪片拡大版
Lineクラスは前回と同じ
KochSnow.as
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.Point;
public class KochSnow extends Sprite {
private var list:Array = [];
private var endPoint:Point;
private var count:int=0;
private const N:int=6;
private const W:int = 300;
private const H:int = 300;
private const L:int = 150;
function KochSnow() {
var p1:Point = new Point(W/2, H/2 - L);
var p2:Point = new Point(L * Math.cos(Math.PI/6) + W/2, L * Math.sin(Math.PI/6) + H/2);
var p3:Point = new Point(L * Math.cos(Math.PI/6*5) + W/2, L * Math.sin(Math.PI/6) + H/2);
var line:Line=new Line(p1, p2);
list.push(line);
stage.addChild(line);
line = new Line(p2, p3);
list.push(line);
stage.addChild(line);
line = new Line(p3, p1);
list.push(line);
stage.addChild(line);
endPoint = p1;
stage.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME,onEnterFrameHandler);
stage.removeEventListener(MouseEvent.CLICK,onClick);
}
}
private function onEnterFrameHandler(event:Event):void {
var line:Line=list[0];
stage.removeChild(line);
list.splice(0, 1);
var p1:Point=new Point();
p1.x=Math.cos(line.angle) * line.distance / 3 + line.startP.x;
p1.y=Math.sin(line.angle) * line.distance / 3 + line.startP.y;
var p2:Point=new Point();
p2.x=Math.cos(line.angle - Math.PI / 3) * line.distance / 3 + p1.x;
p2.y=Math.sin(line.angle - Math.PI / 3) * line.distance / 3 + p1.y;
var p3:Point=new Point();
p3.x=Math.cos(line.angle + Math.PI / 3) * line.distance / 3 + p2.x;
p3.y=Math.sin(line.angle + Math.PI / 3) * line.distance / 3 + p2.y;
var newLine:Line=new Line(line.startP,p1);
stage.addChild(newLine);
list.push(newLine);
newLine=new Line(p1,p2);
stage.addChild(newLine);
list.push(newLine);
newLine=new Line(p2,p3);
stage.addChild(newLine);
list.push(newLine);
newLine=new Line(p3,line.endP);
stage.addChild(newLine);
list.push(newLine);
if (line.endP == endPoint) {
count++;
if (count == N) {
stage.removeEventListener(Event.ENTER_FRAME,onEnterFrameHandler);
}
}
}
}
}
