1 /*****************************************************************************
5 ** Purpose: Display linogram sampling
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: April 2003
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: linogram.cpp,v 1.3 2003/04/01 19:49:41 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
30 enum { O_LABELS, O_VERBOSE, O_HELP, O_VERSION, O_DEBUG };
32 static struct option my_options[] =
34 {"debug", 0, 0, O_DEBUG},
35 {"verbose", 0, 0, O_VERBOSE},
36 {"help", 0, 0, O_HELP},
37 {"version", 0, 0, O_VERSION},
41 static const char* g_szIdStr = "$Id: linogram.cpp,v 1.3 2003/04/01 19:49:41 kevin Exp $";
45 linogram_usage (const char *program)
47 std::cout << "usage: " << fileBasename(program) << " n d [OPTIONS]\n";
48 std::cout << "Imagefile information\n";
49 std::cout << std::endl;
50 std::cout << " infile Name of input IF file\n";
51 std::cout << " --debug Debug mode\n";
52 std::cout << " --verbose Verbose mode\n";
53 std::cout << " --version Print version\n";
54 std::cout << " --help Print this help message\n";
58 linogram_main (int argc, char *const argv[])
65 int c = getopt_long (argc, argv, "", my_options, NULL);
80 std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
82 std::cout << "Unknown version number\n";
87 linogram_usage(argv[0]);
90 linogram_usage(argv[0]);
95 if (optind + 2 != argc) {
96 linogram_usage (argv[0]);
100 const char* in_n = argv[optind];
101 const char* in_d = argv[optind+1];
104 double d = atof (in_d);
105 int size = 4 * n + 3;
106 double theta_base = PI/8;
108 double theta_vec [size];
109 for (int i = 0; i < size; i++) {
110 int m = i - (2 * n + 1);
111 theta_vec[i] = atan (static_cast<double>(2 * m) / size);
115 for (m = 0; m < size; m++) {
116 printf ("%lf: ", theta_vec[m] + theta_base);
117 double step = d * cos(theta_vec[m]);
118 for (int id = 0; id < size; id++) {
119 printf ("%lf ", id * step);
124 for (m = 0; m < size; m++) {
125 printf ("%lf: ", theta_vec[m] + PI/2. + theta_base);
126 double step = d * cos(theta_vec[m]);
127 for (int id = 0; id < size; id++) {
128 printf ("%lf ", id * step);
138 main (int argc, char *const argv[])
143 retval = linogram_main(argc, argv);
144 } catch (exception e) {
145 std::cerr << "Exception: " << e.what() << std::endl;
147 std::cerr << "Unknown exception\n";