coding UTF-8; import Math; import Text; import GUI; import File; import tool.Graph3D; /** The default value of the expression x(t) to plot graph */ const string DEFAULT_X_EXPRESSION = "cos(t*4*PI)"; /** The default value of the expression y(t) to plot graph */ const string DEFAULT_Y_EXPRESSION = "sin(t*2*PI)"; /** The default value of the expression z(t) to plot graph */ const string DEFAULT_Z_EXPRESSION = "sin(t*PI)"; /** The default value of the maximum value of the parameter variable t. */ const string DEFAULT_T_MAX = "1.0"; /** The default value of the minimum value of the parameter variable t. */ const string DEFAULT_T_MIN = "-1.0"; /** The default value of the number of the point of the graph. */ const string DEFAULT_T_N = "300"; // Followings are variables to store IDs of the graph and GUI components. /** Stores the ID of the graph. */ int graph; /** Stores the ID of the input-window. */ int window; /** Stores the ID of the text-field of the expression of x(t). */ int xExpressionField; /** Stores the ID of the text-field of the expression of y(t). */ int yExpressionField; /** Stores the ID of the text-field of the expression of z(t). */ int zExpressionField; /** Stores the ID of the text-field of the maximum value of the parameter variable t. */ int tMaxField; /** Stores the ID of the text-field of the minimum value of the parameter variable t. */ int tMinField; /** Stores the ID of the text-field of the number of points of the graph. */ int tNField; /** Stores the ID of the PLOT button. */ int plotButton; /** Stores the ID of the CLEAR button. */ int clearButton; /** Stores the ID of the ANIMATION button. */ int animationButton; /** Stores the ID of the EXPORT button. */ int exportButton; /** Stores the ID of the EXIT button. */ int exitButton; /** * Invoked automatically when this program have started. */ void main(){ // Set the console window invisible because it is not necessary for GUI program. hide(); // Create (or get from the system) a 2D graph window. graph = getGraph3D(); // Set the size and the location of the graph-window. setGraph3DLocation(graph, 350, 0); setGraph3DSize(graph, 720, 600); // Set options to the graph. setGraph3DOption( graph, "WITH_POINTS", true ); setGraph3DOption( graph, "WITH_LINES", true ); setGraph3DOption( graph, "WITH_MEMBRANES", false ); setGraph3DOption( graph, "WITH_MESHES", false ); // Create and launch the input-window. createSettingWindow(); // If you want to read processings after when the user click PLOT button, // see "onButtonClick" function at near the bottom of this code. } /** * Plots the expression to the 3D graph. * * @param xExpression The expression of x(t). * @param yExpression The expression of y(t). * @param zExpression The expression of z(t). * @param tMin The minimum value of the parameter variable t. * @param tMax The maximum value of the parameter variable t. * @param n The number of points of the graph. */ void plotGraph( string xExpression, string yExpression, string zExpression, double tMax, double tMin, int n ){ // Arrays storing vertices data to transfer the graph. double xArray[n]; double yArray[n]; double zArray[n]; // coordinate variables of a point. double x; double y; double z; double t; // Check the syntax of the expression x(t), y(t), z(t). if( !evaluable(xExpression, 0.0) ){ alert("The form of the expression of \"x(t)\" is wrong."); return; } if( !evaluable(yExpression, 0.0) ){ alert("The form of the expression of \"y(t)\" is wrong."); return; } if( !evaluable(zExpression, 0.0) ){ alert("The form of the expression of \"z(t)\" is wrong."); return; } // Evaluate coordinate values (x,y,z) with n-1 equally divided values of between t-max and t-min, // and store them to arrays. float dt = (tMax-tMin)/(n-1); for( int i=0; i