Initial snark14m import
[snark14.git] / src / snark / foru_store.cpp
1 /*
2  ***********************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/foru_store.cpp $
5  $LastChangedRevision: 85 $
6  $Date: 2014-07-02 16:07:08 -0400 (Wed, 02 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10
11  PURPOSE: GIVEN THE COORDINATES OF A POINT (IX,IY) AND THE VALUE
12  AT THE POINT (GR,GI) ,WHERE GR IS THE REAL PART AND
13  GI IS THE IMAGINARY PART, STORE THE VALUE IN THE
14  APPROPRIATE PLACE IN THE COMMON BLOCK STARTING AT
15  NFRPLN+1
16  */
17
18 #include <cstdio>
19 #include <cmath>
20
21 #include "blkdta.h"
22 #include "fourie.h"
23 #include "consts.h"
24 #include "uiod.h"
25
26 #include "foru.h"
27
28 void foru_class::store(INTEGER ix, INTEGER iy, REAL gr, REAL gi)
29 {
30
31         REAL y;
32         REAL x;
33         INTEGER i;
34         INTEGER j;
35         INTEGER npos;
36
37         y = (REAL) iy;
38         x = (REAL) ix;
39
40 // FILTERING
41
42         if (ix < 0)
43         {
44
45                 // IX LT 0  THE POINT IS ON THE LEFT HALF PLANE, FIND THE POINT
46                 // WHICH IS CONGRUENT TO IT W.R.T. ORIGIN. THE VALUE AT THAT POINT
47                 // IS (GR,-GI)
48
49                 i = -ix;
50                 j = -iy;
51                 if (j < 0)
52                         j += Fourie.nsize2;
53                 npos = j * (Fourie.nsize2 + 2) + 2 * i;
54                 Fourie.nfrpln[npos] = gr;
55                 Fourie.nfrpln[npos + 1] = -gi;
56                 return;
57         }
58
59         // IX EQ 0  THE POINT IS ON THE Y AXIS, WE NEED POINTS ON BOTH SIDES
60         // OF ORIGIN
61
62         else if (ix == 0)
63         {
64                 i = 0;
65                 j = iy;
66                 if (j < 0)
67                         j += Fourie.nsize2;
68                 npos = j * (Fourie.nsize2 + 2) + 2 * i;
69                 Fourie.nfrpln[npos] = gr;
70                 Fourie.nfrpln[npos + 1] = gi;
71                 i = 0;
72                 j = -iy;
73                 if (j < 0)
74                         j += Fourie.nsize2;
75                 npos = j * (Fourie.nsize2 + 2) + 2 * i;
76                 Fourie.nfrpln[npos] = gr;
77                 Fourie.nfrpln[npos + 1] = -gi;
78                 return;
79         }
80         else
81         {
82                 // IX GT 0  THE POINT IS ON THE RIGHT HALF PLANE
83
84                 i = ix;
85                 j = iy;
86                 if (j < 0)
87                         j += Fourie.nsize2;
88                 npos = j * (Fourie.nsize2 + 2) + 2 * i;
89                 Fourie.nfrpln[npos] = gr;
90                 Fourie.nfrpln[npos + 1] = gi;
91                 return;
92         }
93 }