coding Shift_JIS; // 文字コードの明示(文字化け予防) import Math; // 数学関数の使用に必要なライブラリの読み込み import GUI; // GUI画面の構築に必要なライブラリの読み込み import tool.Graph2D; // 2次元グラフ描画に必要なライブラリの読み込み // 以下、波のパラメータを格納する変数 double amplitudeA = 1.0; // 波Aの振幅(A) double amplitudeB = 1.0; // 波Bの振幅(A) double wavelengthA = 0.35; // 波Aの波長(λ) double wavelengthB = 0.4; // 波Bの波長(λ) double periodA = 1.0; // 波Aの周期(T) double periodB = 0.5; // 波Bの周期(T) // グラフ範囲や点数、時間刻みなどの設定変数 const int N = 1024; // グラフの点数(細かいほど滑らか) const double X_MIN = 0.0; // グラフのX軸の最小値 const double X_MAX = 4.0; // グラフのX軸の最大値 const double Y_MIN = -2.0; // グラフのY軸の最小値 const double Y_MAX = 2.0; // グラフのY軸の最大値 const double DT = 0.05; // 1ループごとの時間進行量(speed=1.0の時の値) const double DX = (X_MAX - X_MIN) / N; // 1頂点ごとのX軸進行量 // グラフに波のデータを渡すための座標値配列 double waveX[ 3 ][ N ]; // X座標の配列 / 波A,波B,合成波の合計3系列 × 座標点数 double waveY[ 3 ][ N ]; // Y座標の配列 / 波A,波B,合成波の合計3系列 × 座標点数 // GUI(設定画面)用の変数 int window; // ウィンドウのIDを格納する int periodSliderA; // 波Aの周期設定スライダーのIDを格納する int periodSliderB; // 波Bの周期設定スライダーのIDを格納する int wavelengthSliderA; // 波Aの波長設定スライダーのIDを格納する int wavelengthSliderB; // 波Bの波長設定スライダーのIDを格納する int amplitudeSliderA; // 波Aの振幅設定スライダーのIDを格納する int amplitudeSliderB; // 波Bの振幅設定スライダーのIDを格納する int speedSlider; // アニメーション速度スライダーのIDを格納する int infoLabelA; // 波Aの設定値を表示するラベルのIDを格納する int infoLabelB; // 波Bの設定値を表示するラベルのIDを格納する int timeLabel; // 時刻表示ラベルのIDを格納する int resetButton; // 時刻リセットボタンのIDを格納する // その他の制御用変数 float speed = 0.5; // アニメーション速度 int graph; // グラフソフトのIDを格納する bool continuesLoop = true; // アニメーションON/OFF制御変数 double t; // 時刻変数 // ================================================== // 中心的な処理 - この関数は起動時に自動で実行されます // ================================================== void main( ){ // 波のパラメータの初期値を数値で入力するか尋ね、必要なら入力して設定 inputParameters(); // グラフを起動 createGraphWindow(); // GUI(設定画面)を構築 createSettingWindow(); t = 0.0; // 時刻を0に設定 // アニメーションのループ while( continuesLoop ) { // グラフのタイトルに時刻を表示する string roundedTime = round(t, 1, HALF_UP); // 時刻を小数点以下1桁に丸める setGraph2DTitle(graph, "t = " + roundedTime); // タイトルを「 t = 時刻 」に設定 // グラフソフトに渡す点列データの座標を計算 for( int i=0; i