coding UTF-8; // Load libraries. import Math; import GUI; import tool.Graph2D; // Parameters of the wave. double amplitude = 1.0; double wavelength = 1.0; double period = 1.0; // Paerameters for plotting the graph. const int N = 1024; // The number of points. const double X_MIN = 0.0; // The min value of the x-axis of the graph. const double X_MAX = 4.0; // The max value of the x-axis of the graph. const double Y_MIN = -1.0; // The min value of the y-axis of the graph. const double Y_MAX = 1.0; // The min value of the y-axis of the graph. const double DT = 0.05; // One step of the discrete time (when the speed=1.0) const double DX = (X_MAX - X_MIN) / N; // One step of the discrete x values. // Arrays storing x and y coordinates of points, for plotting the graph double waveX[ N ]; double waveY[ N ]; // Variables for storing IDs of tje GUI components. int window; int periodSlider; int wavelengthSlider; int amplitudeSlider; int speedSlider; int infoLabel; int timeLabel; int resetButton; // Other variables. float speed = 1.0; // The speed of the animation. int graph; // Stores ID of the 2D graph software (RINEARN Graph 2D). bool continuesLoop = true; // The flag representing whether the main loop continues/exits. double t; // The variable representing time. // ================================================================================ // The main function, which will be invoked automatically when the program starts. // ================================================================================ void main( ){ // Ask the user whether input params of the wave, and input them if necessary. inputParameters(); // Launch the 2D graph software (RINEARN Graph 2D). createGraphWindow(); // Create the window, and initializes the GUI components. createSettingWindow(); // The main loop. t = 0.0; while( continuesLoop ) { // Display time on the graph. string roundedTime = round(t, 1, HALF_UP); setGraph2DTitle(graph, "t = " + roundedTime); // Compute coords of points to be plotted on the graph. for( int i=0; i