アップレットプログラムですが、以前に作った Tpl10 クラスを継承します。
ソースです。
import java.awt.Graphics2D; import MyCycloid; import Tpl10; public class TestMyCycloid01 extends Tpl10 { int t = 0; MyCycloid mp = new MyCycloid(); public void init() { tr.move(0, getHeight()); tr.set(1,0,0,-1); tr.scale(50); setTimer(10); } public void draw(Graphics2D g2) { double x; x = Math.toRadians(t); // cycloid draw(mp, 0, x); t++; if (x > 12) { t = 0; } } }
画面の左下を原点とします。 y軸は上に向かっています。 目盛りは、50ドットを1とします。 プログラムは次のようになります。
public void init() { tr.move(0, getHeight()); tr.set(1, 0, 0, -1); tr.scale(50); setTimer(10); }
以前つくった、MyCycloidクラスを利用します。 サイクロイドが、時間とともに描かれていくようにします。 そして、後は動く円を重ねていきます。
実行例