linear transformation
一次変換を使って円周運動を表現する
♥0 |
Line 43 |
Modified 2010-06-05 23:00:31 |
MIT License
archived:2017-03-20 15:22:46
ActionScript3 source code
/**
* Copyright 883108 ( http://wonderfl.net/user/883108 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3nIg
*/
package{
//一次変換を使って円周運動を表現する
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class UzumakiTest extends MovieClip{
private var _ball:Sprite;
private var _base:Sprite;
private var _radius = 200;
private var _radian:Number = Math.PI * 2 / 32;
private var _timer:Timer;
public function UzumakiTest(){
init();
}
private function init():void{
_base = new Sprite;
_base.x = stage.stageWidth / 2;
_base.y = stage.stageHeight / 2;
_base.graphics.clear();
_base.graphics.beginFill(0x000000);
_base.graphics.drawRect(-stage.stageWidth/2,-stage.stageHeight/2,stage.stageWidth, stage.stageHeight);
_base.graphics.endFill();
addChild(_base);
_base.addChild(_ball = new Sprite);
_ball.graphics.clear();
_ball.graphics.beginFill(0xffccee);
_ball.graphics.drawCircle(0, 0, 20);
_ball.graphics.endFill();
_ball.x = _radius;
_ball.y = 0;
_timer = new Timer(33);
_timer.addEventListener(TimerEvent.TIMER, loop);
_timer.start();
}
private function loop($event:TimerEvent):void{
var tmpX:Number = _ball.x;
var tmpY:Number = _ball.y;
_ball.x = tmpX * Math.cos(_radian) - tmpY * Math.sin(_radian);
_ball.y = tmpX * Math.sin(_radian) + tmpY * Math.cos(_radian);
//trace(tmpX * Math.cos(_radian) - tmpY * Math.sin(_radian), tmpX * Math.sin(_radian) + tmpY * Math.cos(_radian));
}
}
}