ハイポサイクロイド

最初の画面

アップレットプログラムですが、以前に作った Tpl10 クラスを継承します。

画面の座標

MyShapeクラスを使います。 ですから、画面の左下が原点です。 y軸も上に向かっています。 目盛りは、40ドットを1とします。 プログラムは次のようになります。

public void init() {
	tr.move(getWidth() / 2, getHeight() / 2);
	tr.set(1,0,0,-1);
	tr.scale(40);
	setTimer(10);
}

TestMyHypoCycloid01.java

ここまでのソースです。

import java.awt.Graphics2D;

import myMath.MyHypoCycloid;
import myMath.Tpl10;

public class TestMyHypoCycloid01 extends Tpl10 {

	int t = 0;
	double rc = 2.5; // 定円
	double rm = 1.0; // 動円

	public void init() {
		tr.move(getWidth() / 2, getHeight() / 2);
		tr.set(1,0,0,-1);
		tr.scale(40);
		setTimer(10);
	}

	public void draw(Graphics2D g2) {
		double x;
		MyHypoCycloid mp = new MyHypoCycloid();

		mp.set(rc, rm);

		x = Math.toRadians(t);

		draw(mp, 0, x);

		if (t > 360 * 2) {
			t = 0;
		}
		t++;
	}
}

[戻る] [次へ]