forked from: バラ曲線 3D
バラ曲線のリスト
r = sin(θ * n/d)
このリストは横軸がn(1~8) 縦軸がd(1~8)
// forked from 178ep3's バラ曲線リスト
//
// バラ曲線のリスト
// r = sin(θ * n/d)
// このリストは横軸がn(1~8) 縦軸がd(1~8)
package {
import flash.events.*;
import org.papervision3d.core.geom.renderables.*;
import org.papervision3d.core.math.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.view.*;
import org.papervision3d.materials.special.LineMaterial;
import org.papervision3d.core.geom.Lines3D;
[SWF(width = "465", height = "465", frameRate = "60", backgroundColor = "0x000000")]
public class Main extends BasicView {
private var val:Number=0.02;
private var rootNode : DisplayObject3D;
private var line:Lines3D;
public function Main():void
{
rootNode = scene.addChild( new DisplayObject3D( "rootNode" ) );
scene.addChild(rootNode); camera.target = rootNode;
line = new Lines3D();rootNode.addChild(line);
create_Rose3D();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
startRendering();
}
public function create_Rose3D():void {
line.removeAllLines();
Rose3D(250, (8*Math.random()|0) + 1, (8*Math.random()|0) + 1);
}
public function Rose3D(radius:Number,n:uint,d:uint):void{
var c:Number = n / d;
var w:Number = 5 * Math.random();
var p1:Vertex3D = new Vertex3D(0,0,0);
var p2:Vertex3D;
var mat:LineMaterial = new LineMaterial(0xffffff * Math.random(), w);
for(var i:uint=0; i<360*d; i+=3)
{
var rad:Number = i * Math.PI /180;
var v:Number = Math.sin(c * rad);
var r:Number = radius * v;
var x:Number = r * Math.cos(rad);
var y:Number = r * Math.sin(rad);
p2=new Vertex3D(x,y,0);
line.addLine(new Line3D(line,mat,w, p1, p2));
p1=p2;
}
}
private function onEnterFrame(event:Event):void
{
rootNode.rotationX+=3;
rootNode.rotationY+=2;
rootNode.rotationZ += 1;
if (rootNode.scale > 2) val = -val;
if (rootNode.scale < 0) { create_Rose3D(); val = -val };
rootNode.scale += val;
}
}
}