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