/************************************************************** * Draw a real function F(x) by giving its equation * * ----------------------------------------------------------- * * Ref.: Analyse numérique en C By Alain Reverchon and * * Marc Ducamp, Armand Colin Editor, Paris, 1990". * * (for files armath.h, fonction.cpp) [BIBLI 14]. * * ----------------------------------------------------------- * * SAMPLE RUN: * * * * * * Equation of Function f(x): "sin(x)/x" * * * * Begin x: -16 * * End x : 16 * * Number of points: 100 * * * * * * (A graph of the function f(x) is displayed). * * * * C++ version by J-P Moreau, Paris. * * (www.jpmoreau.fr) * * ----------------------------------------------------------- * * Note: this program demonstrates the capability of the module* * Fonction.cpp to compile a user defined real function * * F(x), given by its equation, and to evaluate a current* * point. * * * * Accepted signs and operators: * * ---------------------------- * * 0,1,2,3,4,5,6,7,8,9,(,),-,+,*,/,^,SIN,COS,TAN,ARCSIN,ARCCOS,* * ARCTAN,SH,CH,TH,ARGSH,ARGCH,ARGTH,ABS,INT,FRAC,FACT,EXP,LN, * * SQR (^ for power, SQRT for square root). * *************************************************************** uses functions ar_anal_fonction, ar_eval_f of fonction.cpp. here no use is made of optional type ar_nombre. --------------------------------------------------------------- Used files: grfunct1.mak, armath.h, fonction.cpp, graph2d.cpp, graph2d.h. -------------------------------------------------------------*/ #include "armath.h" #include #define REAL double #define SQRT sqrt HDC hdc; RECT rect; HPEN hpen, hpenOld; //Functions used here of graph2D.cpp void CourbeXY(int,int,float *,REAL,REAL); void Legendes (int,char *,char *,char *,int,int,char *,int,int,char *); //"home made" graphic commands for hdc environment used by above functions void DrawPixel(int ix,int iy) { //sorry, no other available command found Rectangle(hdc,rect.left+ix,rect.top+iy, rect.left+ix+2,rect.top+iy+1); } void Swap(int *i1,int *i2) { int it; it=*i1; *i1=*i2; *i2=it; } void DrawLine(int ix1,int iy1,int ix2,int iy2) { int i,il,ix,iy; REAL dx,dy; if (ix2