/************************************************************** * Program to demonstrate the Acceleration Shock Spectrum * * * * C++ version by J-P Moreau, Paris * * (www.jpmoreau.fr) * * * * (use with tgfft.mak, graph2d.cpp, basis_r.cpp(*) * * and vmblock.cpp(*)). * * * * (*) to be found in MATRICES directory. * * ----------------------------------------------------------- * * SAMPLE RUN: * * * * Input data file (tfft.dat): * * * * (The test signal contains 3 frequencies: 50, 250, 500 hz) * * * * 1024 * * 0.00000000000000E+0000 0.00000000000000E+0000 * * 1.95503421309917E-0004 3.53914399999776E+0001 * * 3.91006842619834E-0004 5.95684899999760E+0001 * * 5.86510263929974E-0004 6.54621699999552E+0001 * * 7.82013685239669E-0004 5.24038399999845E+0001 * * ... ... * * 1.98826979472187E-0001 2.77372500000183E-0001 * * 1.99022482893497E-0001 -2.43361500000174E+0000 * * 1.99217986314807E-0001 -4.84236799999780E+0000 * * 1.99413489736116E-0001 -6.02247899999929E+0000 * * 1.99608993157426E-0001 -5.45615399999951E+0000 * * 1.99804496578736E-0001 -3.22824200000105E+0000 * * 2.00000000000045E-0001 -2.96010699999982E-0003 * * * * Output file (tshocksp.lst): * * * * Frequency Shock Spectrum Shock Spectrum * * (Hz) negative positive * * ------------------------------------------------------- * * 10.00 -3.037656 3.602233 * * 20.00 -6.422721 9.166994 * * 30.00 -16.325201 13.674868 * * 40.00 -27.368246 27.100563 * * 50.00 -41.964013 42.437765 * * 60.00 -27.828617 26.667987 * * ... ... ... * * 740.00 -109.784192 112.831489 * * 750.00 -109.242479 110.265918 * * 760.00 -108.338595 108.819857 * * 770.00 -107.086906 108.976530 * * 780.00 -105.503821 110.103584 * * 790.00 -103.607643 110.830962 * * 800.00 -101.418411 109.903625 * * * * Note: the shock spectrum shows 3 peaks around 50, 250 and * * 500 hz. * **************************************************************/ #include #include #include // ABS, MACH_EPS, REAL, WriteEnd(), WriteHead() #include // dynamic allocations #include HDC hdc; RECT rect; HPEN hpen, hpenOld; //Functions used here of Graph2D.cpp void Initwindow(int,double,double,double,double); void MinMax(int,float *,double *,double *); void TracerXY(int,float *,double,double); 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; double dx,dy; if (ix2maxi) maxi=response[j]; } // store mini in SP1[i] and maxi in SP2[i] SP1[i]=(float) mini; SP2[i]=(float) maxi; f+=df; } // print shock spectrum (negative and positive) to output file f=fbegin; fprintf(f_out,"\n"); fprintf(f_out," Frequency Shock Spectrum Shock Spectrum \n"); fprintf(f_out," (Hz) negative positive \n"); fprintf(f_out," -------------------------------------------------------\n"); for (i=1; i