00001 #include "sadie.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 void SINEWAVE (
00014 short nlin,
00015 short npix,
00016 double period,
00017 double phase,
00018 IMAGE **out
00019
00020 ) { register short j, k;
00021 char msg[SLEN];
00022 double factor;
00023
00024 if (TIMES) TIMING(T_SINEWAVE);
00025 if (NAMES) {
00026 MESSAGE('I',"");
00027 MESSAGE('I',"SINEWAVE");
00028 MESSAGE('I',"");
00029 sprintf(msg," Image size: lines: %d",nlin);
00030 MESSAGE('I',msg);
00031 sprintf(msg," pixels: %d",npix);
00032 MESSAGE('I',msg);
00033 sprintf(msg," Period: %12.4e",period);
00034 MESSAGE('I',msg);
00035 sprintf(msg," Phase: %12.4e",phase);
00036 MESSAGE('I',msg);
00037 MESSAGE('I'," ...............");
00038 }
00039
00040
00041 if (nlin <= 0) {
00042 MESSAGE('E'," Number of lines must be greater than zero.");
00043 goto the_end;
00044 } else if (npix <= 0) {
00045 MESSAGE('E'," Number of pixels/line must be greater than zero.");
00046 goto the_end;
00047 } else if (period <= 0.0) {
00048 MESSAGE('E'," Period must be greater than zero.");
00049 goto the_end;
00050 }
00051
00052
00053 if (!CHECKIMG(*out)) GETMEM(1,nlin,npix,out);
00054 if (!*out) goto the_end;
00055
00056
00057 factor = 2.0*PI/period;
00058 phase *= factor;
00059 for (k=0; k<npix; k++) {
00060 (*out)->data[0][0][k] = (PIXEL)((double)(SMAX-SMIN)*(0.5*sin(factor*(double)k+phase)+0.5)+(double)SMIN);
00061 }
00062 for (j=0; j<nlin; j++) {
00063 for (k=0; k<npix; k++) {
00064 (*out)->data[0][j][k] = (*out)->data[0][0][k];
00065 }
00066 }
00067
00068 the_end:
00069 if (TIMES) TIMING(T_EXIT);
00070 }