flash on 2009-11-22
下記サイトとパラメータ同じ。投げはじめの高さは1m, 時間間隔は0.1秒,
xは6dotで1m, yは50dotで1m.
赤が普通の斜方投射(放物線), 青がフリスビー
@see http://www.tenchi.ne.jp/~rszk/FAQ/Sci/vtol-principle.txt
@see http://homepage3.nifty.com/wanpark/sakusaku/throwing8.htm
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wex5
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.getTimer;
import flash.events.*;
import com.bit101.components.*;
// 下記サイトとパラメータ同じ。投げはじめの高さは1m, 時間間隔は0.1秒,
// xは6dotで1m, yは50dotで1m.
// 赤が普通の斜方投射(放物線), 青がフリスビー
// @see http://www.tenchi.ne.jp/~rszk/FAQ/Sci/vtol-principle.txt
// @see http://homepage3.nifty.com/wanpark/sakusaku/throwing8.htm
public class Test extends Sprite {
private var _tf : TextField;
private var _vsl : HUISlider;
private var _anglesl : HUISlider;
private var _text : Text;
public function Test() {
_tf = new TextField();
_tf.width = 465;
_tf.height = 465;
addChild(_tf);
_vsl = new HUISlider(this, 10, 10, "V", onChange);
_anglesl = new HUISlider(this, 10, 30, "angle", onChange);
_vsl.minimum = 0;
_vsl.maximum = 15;
_vsl.value = 10;
_anglesl.minimum = -15.0;
_anglesl.maximum = 15.0;
_anglesl.value = 0.0;
_text = new Text(this, 10, 50, "");
onChange();
}
private function onChange(e : Event = null) : void
{
graphics.clear();
graphics.lineStyle(2, 0x000000);
graphics.moveTo(20, 440); graphics.lineTo(465, 440);
graphics.moveTo(20, 440 - 50); graphics.lineTo(465, 440 - 50);
_text.text = "";
simulate(1, 0xff0000);
simulate(10, 0x0000ff);
}
private function simulate(omega : Number, color : uint) : void
{
var x : Number = 0;
var y : Number = 1;
var vx : Number = _vsl.value * Math.cos(_anglesl.value / 180 * Math.PI);
var vy : Number = _vsl.value * Math.sin(_anglesl.value / 180 * Math.PI);
var T : Number = 0.1;
var mu : Number = Math.pow(0.95, T);
var omu : Number = Math.pow(0.7, T);
var G : Number = 9.8;
graphics.lineStyle(1, color);
var t : int = 0;
var maxy : Number = 1.0;
while(y > 0){
var theta : Number = Math.atan(vy / vx) / Math.PI * 180;
var v2 : Number = vx * vx + vy * vy;
var L : Number = (1.0 - 1 / omega) * vx / Math.sqrt(v2);
omega *= omu;
if(omega < 1.0)omega = 1.0;
vx *= mu;
vy += (L - 1.0) * G * T * T;
vy *= mu;
x += vx * T;
y += vy * T;
// tr(x, y, vx, vy, L, M);
graphics.drawCircle(20 + x * 6, 440 - y * 50, 1);
t++;
if(maxy < y)maxy = y;
}
_text.text += "" +
x + "m\n" +
(t * T) + "s\n" +
"maxY : " + maxy + "m\n";
}
private function tr(...o : Array) : void
{
_tf.appendText(o + "\n");
}
}
}