Initial snark14m import
[snark14.git] / src / snark / anglst.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/anglst.cpp $
5  $LastChangedRevision: 85 $
6  $Date: 2014-07-02 16:07:08 -0400 (Wed, 02 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9
10  anglst.cpp,v 1.3 2008/09/25 13:17:44 jklukowska Exp
11  */
12
13 #include <cstdio>
14 #include <cmath>
15
16 #include "blkdta.h"
17 #include "consts.h"
18
19 #include "anglst.h"
20
21 anglst_class Anglst;
22
23 anglst_class::~anglst_class()
24 {
25         if (pbase != NULL)
26                 delete[] pbase;
27         if (bth != NULL)
28                 delete[] bth;
29         if (bsin != NULL)
30                 delete[] bsin;
31         if (bcos != NULL)
32                 delete[] bcos;
33 }
34
35 void anglst_class::Init(INTEGER prjnum)
36 {
37         bth = new REAL[prjnum];
38         bsin = new REAL[prjnum];
39         bcos = new REAL[prjnum];
40 }
41
42 void anglst_class::InitDiv(REAL* pang, INTEGER prjnum)
43 {
44         REAL theta;
45         REAL dtor;
46         int np;
47
48         dtor = Consts.pi / (REAL) 180.0;
49
50         for (np = 0; np < prjnum; np++)
51         {
52                 theta = pang[np] * dtor;
53                 bth[np] = theta;
54                 bsin[np] = (REAL) sin(theta);
55                 bcos[np] = (REAL) cos(theta);
56 #ifdef FFCOMPARE
57 #endif
58         }
59 }
60
61 /*
62  C.... ESTABLISH SIN AND COSINE TABLES NEEDED FOR DIVERGENT GEOMETRY
63  C.... FOR USE BY POSIT.
64  C.... CALLED BY RDPROJ,  EXALG,  AND EVAL.
65  */
66
67 void anglst_class::genphi()
68 {
69         INTEGER nmax;
70         REAL th;
71
72         nmax = (GeoPar.nrays - 1) / 2;
73         sphi = new REAL[nmax];
74         cphi = new REAL[nmax];
75
76         for (int nr = 0; nr < nmax; nr++)
77         {
78                 if (GeoPar.arc)
79                         th = GeoPar.pinc / GeoPar.stod * (nr + 1);
80                 if (GeoPar.tang)
81                         th = (REAL) atan2((nr + 1) * GeoPar.pinc, GeoPar.stod);
82
83                 sphi[nr] = (REAL) sin(th);
84                 cphi[nr] = (REAL) cos(th);
85         }
86 }
87