doc: Make table of contents output more flexible. This re-introduces the indentation...
[Ale.git] / d2 / filter / sinc.h
blob14c598ba09eceba8e98a4b010e3ff2c907db285d
1 // Copyright 2004 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __sinc_h__
22 #define __sinc_h__
25 * A filtering class for the sinc function.
27 * Notes on Lanczos and Sinc by Dave Martindale et alia are available here:
29 * http://www.binbooks.com/books/photo/i/l/57186AF8DE
30 * http://www.binbooks.com/books/photo/i/l/57186AE7E6&orig=1
33 class sinc : public filter {
34 public:
37 * Sinc filter.
39 * Width is infinite.
41 static double _sinc(ale_pos p) {
42 if (fabs(p) < 0.001)
43 return 1;
44 return sin(M_PI * p) / (M_PI * p);
47 static double _sinc(point p) {
48 return _sinc(p[0]) * _sinc(p[1]);
51 virtual int equals(const filter *f) const {
52 if (typeid(*f) == typeid(*this))
53 return 1;
54 return 0;
58 * Size of filter support, in number of half-cycles to each side of the
59 * filter center.
61 virtual ale_real support() const {
62 double zero = 0;
63 double infinity = 1 / zero;
64 assert (!isnan(infinity));
65 assert (1 < infinity);
66 return (ale_real) infinity;
70 * Response of filter at point p
72 virtual ale_real response(point p) const {
73 return _sinc(p);
76 #endif