#[derive(Clone, Debug)]
pub struct Angles(pub Vec<f32>);
impl Angles {
pub fn uniform(nang: usize, ang1: f32, ang2: f32) -> Self {
if nang == 0 {
return Angles(Vec::new());
}
let step = (ang2 - ang1) / nang as f32;
Angles((0..nang).map(|i| ang1 + step * i as f32).collect())
}
pub fn len(&self) -> usize {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
#[derive(Clone, Debug)]
pub enum Center {
Scalar(f32),
PerRow(Vec<f32>),
}
impl Center {
pub fn at(&self, row: usize) -> f32 {
match self {
Center::Scalar(c) => *c,
Center::PerRow(v) => v[row],
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Beam {
Parallel,
Cone {
source_dist: f32,
},
Laminography {
phi: f32,
},
}
#[derive(Clone, Copy, Debug)]
pub struct Detector {
pub width: usize,
pub height: usize,
pub pixel_size: f32,
}
#[derive(Clone, Debug)]
pub struct Geometry {
pub angles: Angles,
pub center: Center,
pub beam: Beam,
pub detector: Detector,
}
impl Geometry {
pub fn parallel(angles: Angles, width: usize, height: usize, pixel_size: f32) -> Self {
Geometry {
center: Center::Scalar(width as f32 / 2.0),
angles,
beam: Beam::Parallel,
detector: Detector {
width,
height,
pixel_size,
},
}
}
}