三角関数 極座標/媒介変数表示された円運動: ActionScript
三角関数使い円運動をActionScript2.0で実現するメモ。
三角関数については三角比・三角関数 : 数学に詳しく記載している。
大まかな手順
- 円の描画
- 幅:10,高さ:10の円を描画する(Shift+ドラッグで真丸の円)。
- 円をシンボルへ
-
F8でムービークリップシンボルへ変換(シンボルの中心を基準点にする)。変換ダイアログのオプションを下記のように設定。
名前: point
識別子: point
リンケージ:「ActionScriptへ書き出し」,「最初のフレームへ書き出し」をチェック - 描画した円(インスタンス)を削除
- 円はActionScriptのattachMovie関数で動的に書き出すため、ステージから削除。
- ActionScriptの設定
- 1フレーム目ににActionScriptを設定。
ActionScript2.0ソースコード
// 円オブジェクト
function PointClip(startDegree,radius,centerX,centerY) {
// 度数
var degree = startDegree;
// 径
var radius = radius;
// 円中心
var centerX = centerX;
var centerY = centerY;
/* onEnterFrame */
this.onEnterFrame = function(){
// 弧度
var radian = Math.PI/180*degree;
// 位置(極座標変換)
this._x = centerX +radius*Math.cos(radian);
this._y = centerY +radius*Math.sin(radian);
degree += 5;
}
}
// 開始角度,半径,中心のX座標,Y座標
var o = new PointClip(0,50,100,100);
_root.attachMovie('point','point_mc',0,o);
関連記事
- 三角関数 極座標/媒介変数表示した楕円運動: ActionScript
- 三角関数(回転行列を用いた円運動) : ActionScript2.0
- 三角関数 八の字運動 : ActionScript
- 双曲螺旋 : ActionScript
- 三角関数 座標変換を用いた円運動 : ActionScript
コメント
コメントはまだありません。
コメントの投稿
改行と段落タグは自動で挿入されます。
メールアドレスは表示されません。
トラックバックURL
http://www.findxfine.com/flash/actionscript/80.html/trackback