1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! All filter implementations are derived from an abstract **Filter**
//! class, which provides the interface for the functions used in
//! filtering.
//!
//! - BoxFilter
//! - GaussianFilter
//! - MitchellFilter
//! - LanczosSincFilter
//! - TriangleFilter
//!
//! ## Box Filter
//!
//! One of the most commonly used filters in graphics is the box
//! filter. The box filter equally weights all samples within a square
//! region of the image. Although computational efficient, it's just
//! about the worst filter possible.
//!
//! ```rust
//! use rs_pbrt::core::pbrt::Float;
//! use rs_pbrt::filters::boxfilter::BoxFilter;
//! use rs_pbrt::core::geometry::Vector2f;
//!
//! fn main() {
//!     let xw: Float = 0.5;
//!     let yw: Float = 0.5;
//!     let box_filter = BoxFilter {
//!         radius: Vector2f { x: xw, y: yw },
//!         inv_radius: Vector2f {
//!             x: 1.0 / xw,
//!             y: 1.0 / yw,
//!         },
//!     };
//!
//!     println!("box_filter = {:?}", box_filter);
//! }
//! ```
//!
//! ## Gaussian Filter
//!
//! Unlike the box and triangle filters, the Gaussian filter gives a
//! reasonably good result in practice. The Gaussian filter does tend
//! to cause slight blurring of the final image compared to some of
//! the other filters, but this blurring can actually help mask any
//! remaining aliasing in the image.
//!
//! ```rust
//! use rs_pbrt::core::pbrt::Float;
//! use rs_pbrt::filters::gaussian::GaussianFilter;
//! use rs_pbrt::core::geometry::Vector2f;
//!
//! fn main() {
//!     let xw: Float = 2.0;
//!     let yw: Float = 2.0;
//!     let alpha: Float = 2.0;
//!     let exp_x: Float = (-alpha * xw * xw).exp();
//!     let exp_y: Float = (-alpha * yw * yw).exp();
//!     let gaussian_filter = GaussianFilter {
//!         alpha: alpha,
//!         exp_x: exp_x,
//!         exp_y: exp_y,
//!         radius: Vector2f { x: xw, y: yw },
//!         inv_radius: Vector2f {
//!             x: 1.0 / xw,
//!             y: 1.0 / yw,
//!         },
//!     };
//!
//!     println!("gaussian_filter = {:?}", gaussian_filter);
//! }
//! ```
//!
//! ## MitchellFilter
//!
//! ```rust
//! use rs_pbrt::core::geometry::Vector2f;
//! use rs_pbrt::core::pbrt::Float;
//! use rs_pbrt::filters::mitchell::MitchellNetravali;
//!
//! fn main() {
//!     let xwidth: Float = 2.0;
//!     let ywidth: Float = 2.0;
//!     let b: Float = 1.0 / 3.0;
//!     let c: Float = 1.0 / 3.0;
//!     let mitchell_filter = MitchellNetravali::new(xwidth, ywidth, b, c);
//!
//!     println!("mitchell_filter = {:?}", mitchell_filter);
//! }
//! ```
//!
//! ## LanczosSincFilter
//!
//! ```rust
//! use rs_pbrt::core::geometry::Vector2f;
//! use rs_pbrt::core::pbrt::Float;
//! use rs_pbrt::filters::sinc::LanczosSincFilter;
//!
//! fn main() {
//!     let xw: Float = 4.0;
//!     let yw: Float = 4.0;
//!     let radius: Vector2f = Vector2f { x: xw, y: yw };
//!     let tau: Float = 3.0;
//!     let sinc_filter = LanczosSincFilter::new(radius, tau);
//!
//!     println!("sinc_filter = {:?}", sinc_filter);
//! }
//! ```
//!
//! ## TriangleFilter
//!
//! ```rust
//! use rs_pbrt::core::geometry::Vector2f;
//! use rs_pbrt::core::pbrt::Float;
//! use rs_pbrt::filters::triangle::TriangleFilter;
//!
//! fn main() {
//!     let xw: Float = 2.0;
//!     let yw: Float = 2.0;
//!     let triangle_filter = TriangleFilter {
//!         radius: Vector2f { x: xw, y: yw },
//!         inv_radius: Vector2f {
//!             x: 1.0 / xw,
//!             y: 1.0 / yw,
//!         },
//!     };
//!
//!     println!("triangle_filter = {:?}", triangle_filter);
//! }
//! ```
//!

pub mod boxfilter;
pub mod gaussian;
pub mod mitchell;
pub mod sinc;
pub mod triangle;