#[derive(Debug, Clone, PartialEq)]
pub struct HeightProfile {
pub samples_m: Vec<f64>,
}
impl HeightProfile {
pub fn new(samples_m: Vec<f64>) -> Self {
Self { samples_m }
}
pub fn min_max(&self) -> (f64, f64) {
let min = self.samples_m.iter().copied().fold(f64::INFINITY, f64::min);
let max = self
.samples_m
.iter()
.copied()
.fold(f64::NEG_INFINITY, f64::max);
(min, max)
}
pub fn roughness_index(&self) -> f64 {
if self.samples_m.len() < 2 {
return 0.0;
}
let total: f64 = self
.samples_m
.windows(2)
.map(|pair| (pair[1] - pair[0]).abs())
.sum();
total / (self.samples_m.len() - 1) as f64
}
}
pub fn ridge_shadow_fraction(solar_elevation_deg: f64, wall_slope_deg: f64) -> f64 {
((wall_slope_deg - solar_elevation_deg) / wall_slope_deg.max(1.0)).clamp(0.0, 1.0)
}