coding UTF-8; // Specify character encoding to prevent garbled text import Math; // Import the library for mathematical functions import GUI; // Import the library for building GUI windows import tool.Graph3D; // Import the library for 3D graph plotting // Variables to store wave parameters double amplitude = 1.0; // Wave amplitude (A) double wavelength = 2.0; // Wavelength of the wave (λ) double period = 1.0; // Period of the wave (T) // Configuration variables for the graph range, number of points, and time increment const int N = 100; // Number of grid points per axis (higher = smoother mesh) const double X_MIN = -5.0; // Minimum value on the X-axis const double X_MAX = 5.0; // Maximum value on the X-axis const double Y_MIN = -5.0; // Minimum value on the Y-axis const double Y_MAX = 5.0; // Maximum value on the Y-axis const double Z_MIN = -1.0; // Minimum value on the Z-axis const double Z_MAX = 1.0; // Maximum value on the Z-axis const double DT = 0.1; // Time increment per loop iteration (when speed = 1.0) const double DX = (X_MAX - X_MIN) / (N-1); // Mesh interval along the X-axis const double DY = (Y_MAX - Y_MIN) / (N-1); // Mesh interval along the Y-axis // Coordinate arrays to pass wave data to the graph double waveX[ N ][ N ]; // X-coordinate array double waveY[ N ][ N ]; // Y-coordinate array double waveZ[ N ][ N ]; // Z-coordinate array // Variables for the GUI (setting window) int window; // Stores the window ID int periodSlider; // Stores the ID of the period slider int wavelengthSlider; // Stores the ID of the wavelength slider int amplitudeSlider; // Stores the ID of the amplitude slider int speedSlider; // Stores the ID of the animation speed slider int infoLabel; // Stores the ID of the label showing current settings int timeLabel; // Stores the ID of the label showing current time int resetButton; // Stores the ID of the reset button for time // Other control variables float speed = 0.7; // Animation speed int graph; // Stores the ID of the graph software bool continuesLoop = true; // Controls whether the animation keeps running double t; // Time variable // ====================================================================== // Main procedure - this function runs automatically on startup // ====================================================================== void main( ){ // Launch the graph window createGraphWindow(); // Build the GUI (setting window) createSettingWindow(); t = 0.0; // Initialize time variable // Animation loop while( continuesLoop ) { // Calculate coordinates for the wave and pass them to the graph for( int yi=0; yi